added some tests for the publish api
This commit is contained in:
parent
b60e760b6e
commit
61b4480d2b
1 changed files with 37 additions and 9 deletions
|
@ -110,18 +110,49 @@ describe('end-to-end', function () {
|
|||
const fileName = 'byrd.jpeg';
|
||||
const channelName = testChannel;
|
||||
const channelPassword = testChannelPassword;
|
||||
const date = new Date();
|
||||
const name = `test-publish-${date.getFullYear()}-${date.getMonth()}-${date.getDate()}-${date.getTime()}`;
|
||||
|
||||
describe('anonymous publishes', function () {
|
||||
it(`should receive a status code 200 within ${publishTimeout}ms @usesLbc`, function (done) {
|
||||
const date = new Date();
|
||||
const name = `test-publish-${date.getFullYear()}-${date.getMonth()}-${date.getDate()}-${date.getTime()}`;
|
||||
describe('api/claim/publish', function () {
|
||||
|
||||
it(`should receive a status code 400 if username does not exist`, function (done) {
|
||||
chai.request(host)
|
||||
.post(publishUrl)
|
||||
.type('form')
|
||||
.attach('file', fs.readFileSync(filePath), fileName)
|
||||
.field('name', name)
|
||||
.field('channelName', `@${name}`)
|
||||
.field('channelPassword', channelPassword)
|
||||
.end(function (err, res) {
|
||||
expect(res).to.have.status(400);
|
||||
done();
|
||||
});
|
||||
}).timeout(publishTimeout);
|
||||
|
||||
it(`should receive a status code 400 if wrong password`, function (done) {
|
||||
chai.request(host)
|
||||
.post(publishUrl)
|
||||
.type('form')
|
||||
.attach('file', fs.readFileSync(filePath), fileName)
|
||||
.field('name', name)
|
||||
.field('channelName', channelName)
|
||||
.field('channelPassword', 'xxxxx')
|
||||
.end(function (err, res) {
|
||||
expect(res).to.have.status(400);
|
||||
done();
|
||||
});
|
||||
}).timeout(publishTimeout);
|
||||
|
||||
});
|
||||
|
||||
describe('anonymous publishes', function () {
|
||||
it(`should receive a status code 200 within ${publishTimeout}ms @usesLbc`, function (done) {
|
||||
chai.request(host)
|
||||
.post(publishUrl)
|
||||
.type('form')
|
||||
.attach('file', fs.readFileSync(filePath), fileName)
|
||||
.field('name', `${name}-anonymous`)
|
||||
.end(function (err, res) {
|
||||
// expect(err).to.be.null;
|
||||
expect(res).to.have.status(200);
|
||||
done();
|
||||
});
|
||||
|
@ -130,17 +161,14 @@ describe('end-to-end', function () {
|
|||
|
||||
describe('in-channel publishes', function () {
|
||||
it(`should receive a status code 200 within ${publishTimeout}ms @usesLbc`, function (done) {
|
||||
const date = new Date();
|
||||
const name = `test-publish-${date.getFullYear()}-${date.getMonth()}-${date.getDate()}-${date.getTime()}`;
|
||||
chai.request(host)
|
||||
.post(publishUrl)
|
||||
.type('form')
|
||||
.attach('file', fs.readFileSync(filePath), fileName)
|
||||
.field('name', name)
|
||||
.field('name', `${name}-channel`)
|
||||
.field('channelName', channelName)
|
||||
.field('channelPassword', channelPassword)
|
||||
.end(function (err, res) {
|
||||
// expect(err).to.be.null;
|
||||
expect(res).to.have.status(200);
|
||||
done();
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue