-
-
Notifications
You must be signed in to change notification settings - Fork 59
/
file.test.ts
41 lines (36 loc) · 1.29 KB
/
file.test.ts
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
import { describe, it, expect } from 'vitest';
import '../';
describe('File', () => {
it('should be an instanceof Blob', () => {
const file = new File([], 'file.txt');
expect(file).toBeInstanceOf(Blob);
});
it('should allow empty files', () => {
const file = new File([], 'file.txt');
expect(file.size).toEqual(0);
expect(file.type).toEqual('');
expect(file.name).toEqual('file.txt');
expect(file.lastModified).toBeGreaterThan(0);
});
it('should set the type', () => {
const file = new File([], 'file.txt', { type: 'text/plain' });
expect(file.size).toEqual(0);
expect(file.type).toEqual('text/plain');
expect(file.name).toEqual('file.txt');
expect(file.lastModified).toBeGreaterThan(0);
});
it('should init with string', () => {
const file = new File(['hello'], 'file.txt', { type: 'text/plain' });
expect(file.size).toEqual(5);
expect(file.type).toEqual('text/plain');
expect(file.name).toEqual('file.txt');
expect(file.lastModified).toBeGreaterThan(0);
});
it('should set lastModified', () => {
const file = new File([], 'file.txt', { lastModified: 123 });
expect(file.size).toEqual(0);
expect(file.type).toEqual('');
expect(file.name).toEqual('file.txt');
expect(file.lastModified).toEqual(123);
});
});