-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathapp.test.ts
More file actions
64 lines (52 loc) · 1.6 KB
/
Copy pathapp.test.ts
File metadata and controls
64 lines (52 loc) · 1.6 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import supertest from 'supertest';
import { ImportMock } from 'ts-mock-imports';
import { pprint } from './src/helpers';
import * as Ledger from './src/ledger';
import app from './app';
// TODO
// - isolate test env (pass outDir as a param to app, create a specific outDir
// for test)
// - test that an existing file is returned
// - test that an existing dotFile is not returned
describe('The file endpoint', () => {
it('should 404 if the file doesnt exist.', async () => {
// return supertest(app)
// .get('/file/foo')
// .then(response => {
// expect(response.status).toBe(500);
// });
});
it('should 200 with the file if it exists', () => {
// create a file in the test dir
// ask for it
// file is returned
});
it('should not return an existing dot file', () => {
// create a dot file in the test dir
// ask for it
// file is not returned
});
});
describe('The history endpoint', () => {
afterEach(() => {
ImportMock.restore();
});
it("should use the ledger's history API", () => {
const result = { foo: 'bar' };
const getListHistoryMock = ImportMock.mockFunction(
Ledger,
'listDocHistory',
Promise.resolve(result)
);
const name = 'foo';
return supertest(app)
.get(`/history/${name}`)
.then(response => {
expect(getListHistoryMock.calledOnce).toBe(true);
expect(getListHistoryMock.calledWith(name)).toBe(true);
expect(response.status).toBe(200);
expect(response.text).toBe(pprint(result));
});
});
});
describe('The export-copy endpoint', () => {});