Testing #307
2 changed files with 11 additions and 16 deletions
|
@ -1,7 +1,7 @@
|
||||||
const chai = require('chai');
|
const chai = require('chai');
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
const chaiHttp = require('chai-http');
|
const chaiHttp = require('chai-http');
|
||||||
const host = 'http://dev1.spee.ch';
|
const { host } = require('../../config/speechConfig.js').site;
|
||||||
|
|
||||||
chai.use(chaiHttp);
|
chai.use(chaiHttp);
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,26 @@
|
||||||
const assert = require('assert');
|
const chai = require('chai');
|
||||||
|
const expect = chai.expect;
|
||||||
|
|
||||||
describe('publishHelpers.js', function () {
|
describe('publishHelpers.js', function () {
|
||||||
const publishHelpers = require('../../helpers/publishHelpers.js');
|
const publishHelpers = require('../../helpers/publishHelpers.js');
|
||||||
|
|
||||||
describe('#parsePublishApiRequestBody()', function () {
|
describe('#parsePublishApiRequestBody()', function () {
|
||||||
it('should throw an error if no body', function () {
|
it('should throw an error if no body', function () {
|
||||||
assert.throws(publishHelpers.parsePublishApiRequestBody.bind(this, null), Error);
|
expect(publishHelpers.parsePublishApiRequestBody.bind(this, null)).to.throw();
|
||||||
});
|
});
|
||||||
it('should throw an error if no body.name', function () {
|
it('should throw an error if no body.name', function () {
|
||||||
const bodyNoName = {};
|
const bodyNoName = {};
|
||||||
assert.throws(publishHelpers.parsePublishApiRequestBody.bind(this, bodyNoName), Error);
|
expect(publishHelpers.parsePublishApiRequestBody.bind(this, bodyNoName)).to.throw();
|
||||||
});
|
|
||||||
it('should throw an error if no body.name', function () {
|
|
||||||
const body = {
|
|
||||||
name: 'bob',
|
|
||||||
};
|
|
||||||
assert.doesNotThrow(publishHelpers.parsePublishApiRequestBody.bind(this, body), Error);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#parsePublishApiRequestFiles()', function () {
|
describe('#parsePublishApiRequestFiles()', function () {
|
||||||
it('should throw an error if no files', function () {
|
it('should throw an error if no files', function () {
|
||||||
assert.throws(publishHelpers.parsePublishApiRequestFiles.bind(this, null), Error);
|
expect(publishHelpers.parsePublishApiRequestFiles.bind(this, null)).to.throw();
|
||||||
});
|
});
|
||||||
it('should throw an error if no files.file', function () {
|
it('should throw an error if no files.file', function () {
|
||||||
const filesNoFile = {};
|
const filesNoFile = {};
|
||||||
assert.throws(publishHelpers.parsePublishApiRequestFiles.bind(this, filesNoFile), Error);
|
expect(publishHelpers.parsePublishApiRequestFiles.bind(this, filesNoFile)).to.throw();
|
||||||
});
|
});
|
||||||
it('should throw an error if file.size is too large', function () {
|
it('should throw an error if file.size is too large', function () {
|
||||||
const filesTooBig = {
|
const filesTooBig = {
|
||||||
|
@ -36,10 +31,10 @@ describe('publishHelpers.js', function () {
|
||||||
size: 10000001,
|
size: 10000001,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
assert.throws(publishHelpers.parsePublishApiRequestFiles.bind(this, filesTooBig), Error);
|
expect(publishHelpers.parsePublishApiRequestFiles.bind(this, filesTooBig)).to.throw();
|
||||||
});
|
});
|
||||||
it('should throw error if not an accepted file type', function () {
|
it('should throw error if not an accepted file type', function () {
|
||||||
const filesNoProblems = {
|
const filesWrongType = {
|
||||||
file: {
|
file: {
|
||||||
name: 'file.jpg',
|
name: 'file.jpg',
|
||||||
path: '/path/to/file.jpg',
|
path: '/path/to/file.jpg',
|
||||||
|
@ -47,7 +42,7 @@ describe('publishHelpers.js', function () {
|
||||||
size: 10000000,
|
size: 10000000,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
assert.throws(publishHelpers.parsePublishApiRequestFiles.bind(this, filesNoProblems), Error);
|
expect(publishHelpers.parsePublishApiRequestFiles.bind(this, filesWrongType)).to.throw();
|
||||||
});
|
});
|
||||||
it('should throw NO error if no problems', function () {
|
it('should throw NO error if no problems', function () {
|
||||||
const filesNoProblems = {
|
const filesNoProblems = {
|
||||||
|
@ -58,7 +53,7 @@ describe('publishHelpers.js', function () {
|
||||||
size: 10000000,
|
size: 10000000,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
assert.doesNotThrow(publishHelpers.parsePublishApiRequestFiles.bind(this, filesNoProblems), Error);
|
expect(publishHelpers.parsePublishApiRequestFiles.bind(this, filesNoProblems)).to.not.throw();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue