|
|
|
@ -1,4 +1,5 @@ |
|
|
|
|
import { getCredentials, api, request, credentials } from '../../data/api-data.js'; |
|
|
|
|
import { createRoom } from '../../data/rooms.helper'; |
|
|
|
|
|
|
|
|
|
describe('[Subscriptions]', function() { |
|
|
|
|
this.retries(0); |
|
|
|
@ -63,11 +64,38 @@ describe('[Subscriptions]', function() { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('[/subscriptions.read]', () => { |
|
|
|
|
let testChannel; |
|
|
|
|
it('create a channel', (done) => { |
|
|
|
|
createRoom({ type: 'c', name: `channel.test.${ Date.now() }` }) |
|
|
|
|
.end((err, res) => { |
|
|
|
|
testChannel = res.body.channel; |
|
|
|
|
done(); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
let testGroup; |
|
|
|
|
it('create a group', (done) => { |
|
|
|
|
createRoom({ type: 'p', name: `channel.test.${ Date.now() }` }) |
|
|
|
|
.end((err, res) => { |
|
|
|
|
testGroup = res.body.group; |
|
|
|
|
done(); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
let testDM; |
|
|
|
|
it('create a DM', (done) => { |
|
|
|
|
createRoom({ type: 'd', username: 'rocket.cat' }) |
|
|
|
|
.end((err, res) => { |
|
|
|
|
testDM = res.body.room; |
|
|
|
|
done(); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should mark public channels as read', (done) => { |
|
|
|
|
request.post(api('subscriptions.read')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.send({ |
|
|
|
|
rid: 'foobar123-somechannel', |
|
|
|
|
rid: testChannel._id, |
|
|
|
|
}) |
|
|
|
|
.expect(200) |
|
|
|
|
.expect((res) => { |
|
|
|
@ -80,7 +108,7 @@ describe('[Subscriptions]', function() { |
|
|
|
|
request.post(api('subscriptions.read')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.send({ |
|
|
|
|
rid: 'foobar123-somegroup', |
|
|
|
|
rid: testGroup._id, |
|
|
|
|
}) |
|
|
|
|
.expect(200) |
|
|
|
|
.expect((res) => { |
|
|
|
@ -93,7 +121,7 @@ describe('[Subscriptions]', function() { |
|
|
|
|
request.post(api('subscriptions.read')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.send({ |
|
|
|
|
rid: 'foobar123-somedm', |
|
|
|
|
rid: testDM._id, |
|
|
|
|
}) |
|
|
|
|
.expect(200) |
|
|
|
|
.expect((res) => { |
|
|
|
@ -102,6 +130,48 @@ describe('[Subscriptions]', function() { |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should fail on mark inexistent public channel as read', (done) => { |
|
|
|
|
request.post(api('subscriptions.read')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.send({ |
|
|
|
|
rid: 'foobar123-somechannel', |
|
|
|
|
}) |
|
|
|
|
.expect(400) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', false); |
|
|
|
|
expect(res.body).to.have.property('error'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should fail on mark inexistent group as read', (done) => { |
|
|
|
|
request.post(api('subscriptions.read')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.send({ |
|
|
|
|
rid: 'foobar123-somegroup', |
|
|
|
|
}) |
|
|
|
|
.expect(400) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', false); |
|
|
|
|
expect(res.body).to.have.property('error'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should fail on mark inexistent DM as read', (done) => { |
|
|
|
|
request.post(api('subscriptions.read')) |
|
|
|
|
.set(credentials) |
|
|
|
|
.send({ |
|
|
|
|
rid: 'foobar123-somedm', |
|
|
|
|
}) |
|
|
|
|
.expect(400) |
|
|
|
|
.expect((res) => { |
|
|
|
|
expect(res.body).to.have.property('success', false); |
|
|
|
|
expect(res.body).to.have.property('error'); |
|
|
|
|
}) |
|
|
|
|
.end(done); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should fail on invalid params', (done) => { |
|
|
|
|
request.post(api('subscriptions.read')) |
|
|
|
|
.set(credentials) |
|
|
|
|