-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathfile.model.test.ts
More file actions
50 lines (40 loc) · 1.38 KB
/
file.model.test.ts
File metadata and controls
50 lines (40 loc) · 1.38 KB
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
import {UrlFile} from './file.model';
describe('file.model', () => {
test('canary verifies test infrastructure', () => {
expect(true).toBe(true);
});
describe('given UrlFile', () => {
describe('when url is null', () => {
test('then should throw error', async () => {
const name = 'test.out';
const file = new UrlFile({name, url: undefined as any});
return file.contents.then(
result => expect(result).toBeUndefined(),
err => expect(err.message).toEqual('Url is missing for file: ' + name)
);
});
});
describe('when url is invalid', () => {
test('then should throw error', async () => {
const name = 'test.out';
const url = 'https://bogus-url.com';
const file = new UrlFile({name, url});
return file.contents.then(
result => expect(result).toBeUndefined(),
err => expect(err.message).toEqual('Error retrieving file ' + name + ' from url: ' + url)
);
});
});
describe('when url is valid', () => {
test('then should return contents', async () => {
const name = 'test.out';
const url = 'https://google.com';
const file = new UrlFile({name, url});
return file.contents.then(
result => expect(result).toBeDefined(),
err => expect(err).toBeUndefined(),
);
});
});
});
})