Skip to content

Commit 17e4dd5

Browse files
committed
update tests to actually work right
1 parent f555c4d commit 17e4dd5

File tree

2 files changed

+71
-55
lines changed

2 files changed

+71
-55
lines changed

packages/client/lib/commands/XREAD.spec.ts

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,32 @@ describe('XREAD', () => {
9090
});
9191
});
9292

93-
// TODO
94-
// testUtils.testAll('client.xRead', async client => {
95-
// const message = { field: 'value' },
96-
// [, reply] = await Promise.all([
97-
// client.xAdd('key', '*', message),
98-
// client.xRead({
99-
// key: 'key',
100-
// id: '0-0'
101-
// })
102-
// ])
103-
// assert.equal(
104-
// await client.xRead({
105-
// key: 'key',
106-
// id: '0'
107-
// }),
108-
// null
109-
// );
110-
// }, GLOBAL.SERVERS.OPEN);
93+
94+
testUtils.testAll('client.xRead', async client => {
95+
const message = { field: 'value' },
96+
[id, reply] = await Promise.all([
97+
client.xAdd('key', '*', message),
98+
client.xRead({
99+
key: 'key',
100+
id: '0-0'
101+
}),
102+
])
103+
assert.deepEqual(reply, [{
104+
name: 'key',
105+
messages: [{
106+
id,
107+
message: Object.create(null, {
108+
field: {
109+
value: 'value',
110+
configurable: true,
111+
enumerable: true
112+
}
113+
})
114+
}]
115+
}]
116+
);
117+
}, {
118+
client: GLOBAL.SERVERS.OPEN,
119+
cluster: GLOBAL.CLUSTERS.OPEN
120+
});
111121
});

packages/client/lib/commands/XREADGROUP.spec.ts

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -94,44 +94,50 @@ describe('XREADGROUP', () => {
9494
});
9595
});
9696

97-
// testUtils.testAll('xReadGroup - null', async client => {
98-
// const [, readGroupReply] = await Promise.all([
99-
// client.xGroupCreate('key', 'group', '$', {
100-
// MKSTREAM: true
101-
// }),
102-
// client.xReadGroup('group', 'consumer', {
103-
// key: 'key',
104-
// id: '>'
105-
// })
106-
// ]);
97+
testUtils.testAll('xReadGroup - null', async client => {
98+
const [, readGroupReply] = await Promise.all([
99+
client.xGroupCreate('key', 'group', '$', {
100+
MKSTREAM: true
101+
}),
102+
client.xReadGroup('group', 'consumer', {
103+
key: 'key',
104+
id: '>'
105+
})
106+
]);
107107

108-
// assert.equal(readGroupReply, null);
109-
// }, GLOBAL.SERVERS.OPEN);
108+
assert.equal(readGroupReply, null);
109+
}, {
110+
client: GLOBAL.SERVERS.OPEN,
111+
cluster: GLOBAL.CLUSTERS.OPEN
112+
});
110113

111-
// testUtils.testAll('xReadGroup - with a message', async client => {
112-
// const [, id, readGroupReply] = await Promise.all([
113-
// client.xGroupCreate('key', 'group', '$', {
114-
// MKSTREAM: true
115-
// }),
116-
// client.xAdd('key', '*', { field: 'value' }),
117-
// client.xReadGroup('group', 'consumer', {
118-
// key: 'key',
119-
// id: '>'
120-
// })
121-
// ]);
114+
testUtils.testAll('xReadGroup - with a message', async client => {
115+
const [, id, readGroupReply] = await Promise.all([
116+
client.xGroupCreate('key', 'group', '$', {
117+
MKSTREAM: true
118+
}),
119+
client.xAdd('key', '*', { field: 'value' }),
120+
client.xReadGroup('group', 'consumer', {
121+
key: 'key',
122+
id: '>'
123+
})
124+
]);
122125

123-
// assert.deepEqual(readGroupReply, [{
124-
// name: 'key',
125-
// messages: [{
126-
// id,
127-
// message: Object.create(null, {
128-
// field: {
129-
// value: 'value',
130-
// configurable: true,
131-
// enumerable: true
132-
// }
133-
// })
134-
// }]
135-
// }]);
136-
// }, GLOBAL.SERVERS.OPEN);
126+
assert.deepEqual(readGroupReply, [{
127+
name: 'key',
128+
messages: [{
129+
id,
130+
message: Object.create(null, {
131+
field: {
132+
value: 'value',
133+
configurable: true,
134+
enumerable: true
135+
}
136+
})
137+
}]
138+
}]);
139+
}, {
140+
client: GLOBAL.SERVERS.OPEN,
141+
cluster: GLOBAL.CLUSTERS.OPEN
142+
});
137143
});

0 commit comments

Comments
 (0)