-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaccept.test.js
52 lines (43 loc) · 1.63 KB
/
accept.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
'use strict';
const expect = require('chai').expect;
const validators = require('../src/common-validators');
describe('accept', function() {
const fileList = {
0: {
lastModified: 1459437496451,
lastModifiedDate: 'Thu Mar 31 2016 18:18:16 GMT+0300 (MSK)',
name: '0123456789.png',
size: '1000',
type: 'image/png'
},
1: {
lastModified: 1459437496459,
lastModifiedDate: 'Thu Mar 31 2016 18:18:16 GMT+0300 (MSK)',
name: '01234567890123456789.jpeg',
size: '2000',
type: 'image/jpeg'
},
length: 2
};
it('empty is valid', function() {
expect(validators.accept(undefined, 'image/jpeg,image/png,.webp,video/*')).to.be.undefined;
});
it('separate file object is invalid', function() {
expect(validators.min(fileList[0], 'image/jpeg,image/png,.webp,video/*')).to.have.property('error');
});
it('image/jpeg, image/png is valid', function() {
expect(validators.accept(fileList, 'image/jpeg,image/png,.webp,video/*')).to.be.undefined;
});
it('image is invalid', function() {
expect(validators.accept(fileList, 'image/*')).to.be.undefined;
});
it('.png, .jpeg is valid', function() {
expect(validators.accept(fileList, '.png, .jpg, .jpeg')).to.be.undefined;
});
it('.doc is invalid', function() {
expect(validators.accept(fileList, '.doc')).to.have.property('error');
});
it('image is invalid for video', function() {
expect(validators.accept(fileList, 'video/*')).to.have.property('error');
});
});