set height on new publishes to current height in Claim db
This commit is contained in:
parent
d2eaaae759
commit
e2a3039e4e
10 changed files with 141 additions and 87 deletions
server/controllers/api/claim/publish
|
@ -0,0 +1,15 @@
|
|||
const chai = require('chai');
|
||||
const expect = chai.expect;
|
||||
|
||||
describe('#parsePublishApiRequestBody()', function () {
|
||||
const parsePublishApiRequestBody = require('./parsePublishApiRequestBody.js');
|
||||
|
||||
it('should throw an error if no body', function () {
|
||||
expect(parsePublishApiRequestBody.bind(this, null)).to.throw();
|
||||
});
|
||||
|
||||
it('should throw an error if no body.name', function () {
|
||||
const bodyNoName = {};
|
||||
expect(parsePublishApiRequestBody.bind(this, bodyNoName)).to.throw();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,51 @@
|
|||
const chai = require('chai');
|
||||
const expect = chai.expect;
|
||||
|
||||
describe('#parsePublishApiRequestFiles()', function () {
|
||||
const parsePublishApiRequestFiles = require('./parsePublishApiRequestFiles.js');
|
||||
|
||||
it('should throw an error if no files', function () {
|
||||
expect(parsePublishApiRequestFiles.bind(this, null)).to.throw();
|
||||
});
|
||||
|
||||
it('should throw an error if no files.file', function () {
|
||||
const filesNoFile = {};
|
||||
expect(parsePublishApiRequestFiles.bind(this, filesNoFile)).to.throw();
|
||||
});
|
||||
|
||||
it('should throw an error if file.size is too large', function () {
|
||||
const filesTooBig = {
|
||||
file: {
|
||||
name: 'file.jpg',
|
||||
path: '/path/to/file.jpg',
|
||||
type: 'image/jpg',
|
||||
size: 10000001,
|
||||
},
|
||||
};
|
||||
expect(parsePublishApiRequestFiles.bind(this, filesTooBig)).to.throw();
|
||||
});
|
||||
|
||||
it('should throw error if not an accepted file type', function () {
|
||||
const filesWrongType = {
|
||||
file: {
|
||||
name: 'file.jpg',
|
||||
path: '/path/to/file.jpg',
|
||||
type: 'someType/ext',
|
||||
size: 10000000,
|
||||
},
|
||||
};
|
||||
expect(parsePublishApiRequestFiles.bind(this, filesWrongType)).to.throw();
|
||||
});
|
||||
|
||||
it('should throw NO error if no problems', function () {
|
||||
const filesNoProblems = {
|
||||
file: {
|
||||
name: 'file.jpg',
|
||||
path: '/path/to/file.jpg',
|
||||
type: 'image/jpg',
|
||||
size: 10000000,
|
||||
},
|
||||
};
|
||||
expect(parsePublishApiRequestFiles.bind(this, filesNoProblems)).to.not.throw();
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue