|
@@ -631,20 +631,27 @@ describe('src/Core', () => {
|
|
|
it('should not allow a file that does not meet the restrictions', () => {
|
|
|
const core = new Core({
|
|
|
restrictions: {
|
|
|
- allowedFileTypes: ['image/gif']
|
|
|
+ allowedFileTypes: ['image/gif', 'video/webm']
|
|
|
}
|
|
|
})
|
|
|
- try {
|
|
|
+
|
|
|
+ expect(() => {
|
|
|
core.addFile({
|
|
|
source: 'jest',
|
|
|
name: 'foo.jpg',
|
|
|
type: 'image/jpeg',
|
|
|
data: new File([sampleImage], { type: 'image/jpeg' })
|
|
|
})
|
|
|
- throw new Error('File was allowed through')
|
|
|
- } catch (err) {
|
|
|
- expect(err.message).toEqual('You can only upload: image/gif')
|
|
|
- }
|
|
|
+ }).toThrow('You can only upload: image/gif, video/webm')
|
|
|
+
|
|
|
+ expect(() => {
|
|
|
+ core.addFile({
|
|
|
+ source: 'jest',
|
|
|
+ name: 'foo.webm',
|
|
|
+ type: 'video/webm; codecs="vp8, opus"',
|
|
|
+ data: new File([sampleImage], { type: 'video/webm; codecs="vp8, opus"' })
|
|
|
+ })
|
|
|
+ }).not.toThrow()
|
|
|
})
|
|
|
|
|
|
it('should not allow a dupicate file, a file with the same id', () => {
|