Skip to content

Commit 3288d02

Browse files
committed
fix backend tests
1 parent f8431fd commit 3288d02

13 files changed

+5108
-6694
lines changed

backend/.babelrc

+20-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
11
{
22
"presets": [
3-
["env", {
4-
"targets": {
5-
"node": "current"
3+
[
4+
"@babel/preset-env",
5+
{
6+
"targets": {
7+
"node": "current"
8+
}
69
}
7-
}]
10+
]
811
],
912
"plugins": [
10-
"transform-decorators-legacy",
11-
"transform-class-properties",
12-
"transform-object-rest-spread"
13+
[
14+
"@babel/plugin-proposal-decorators",
15+
{
16+
"legacy": true
17+
}
18+
],
19+
[
20+
"@babel/plugin-proposal-class-properties",
21+
{
22+
"loose": true
23+
}
24+
],
25+
"@babel/plugin-proposal-object-rest-spread"
1326
],
1427
"sourceMaps": "both"
1528
}

backend/__tests__/integration/library.test.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import path from 'path';
22
import { createTestDatabaseConnection } from '../setup';
33
import { get, post } from '../request';
4-
// import { rmdir } from '../../src/utils/fs';
5-
// import { getConfiguration } from '../../src/get-configuration';
64
import { createTokenFor } from '../../src/utils/auth';
75

86
describe('/library', () => {
@@ -19,22 +17,22 @@ describe('/library', () => {
1917
await connection.close();
2018
});
2119

22-
describe('/upload', () => {
20+
describe('/upload/zip', () => {
2321
describe('POST', () => {
2422
it('should process ZIP archives containing HTML files', () => {
25-
return post('/library/upload')
23+
return post('/library/upload/zip')
2624
.set('Authorization', 'Bearer ' + authToken)
2725
.attach('file', path.resolve(__dirname, '../dummy-project.zip'))
2826
.expect(200);
2927
});
3028
it('should handle dupes', () => {
31-
return post('/library/upload')
29+
return post('/library/upload/zip')
3230
.set('Authorization', 'Bearer ' + authToken)
3331
.attach('file', path.resolve(__dirname, '../dummy-project.zip'))
3432
.expect(200);
3533
});
3634
it('should return HTTP 400 if no file was attached', () => {
37-
return post('/library/upload')
35+
return post('/library/upload/zip')
3836
.set('Authorization', 'Bearer ' + authToken)
3937
.expect(400);
4038
});

backend/__tests__/integration/projects.test.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { createTokenFor } from '../../src/utils/auth';
55
async function createAndGetTestProject(testProjectName, authToken) {
66
const res = await post('/projects')
77
.set('Authorization', 'Bearer ' + authToken)
8-
.send({ name: testProjectName })
8+
.send({ projectName: testProjectName })
99
.expect(200);
1010
return res.body;
1111
}
@@ -89,9 +89,7 @@ describe('/projects', () => {
8989
.expect(200)
9090
.then(fetchRes => {
9191
expect(fetchRes.body.length).toBeGreaterThan(0);
92-
expect(fetchRes.body.pop().name).toEqual(
93-
'Default Whiteboard'
94-
);
92+
expect(fetchRes.body.pop().name).toEqual('First Whiteboard');
9593
})
9694
));
9795
});

backend/__tests__/setup.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import { View } from '../src/orm/entity/view';
22
import { Asset } from '../src/orm/entity/asset';
3-
import { InteractionElement } from '../src/orm/entity/interaction-element';
3+
import { Image } from '../src/orm/entity/image';
4+
import { ViewImageInteractionElement } from '../src/orm/entity/view-image-interaction-element';
45
import { Project } from '../src/orm/entity/project';
56
import { Whiteboard } from '../src/orm/entity/whiteboard';
67
import { getConnectionManager } from 'typeorm';
78
import { Page } from '../src/orm/entity/page';
89
import { Directory } from '../src/orm/entity/directory';
910
import { User } from '../src/orm/entity/user';
11+
import { ViewLink } from '../src/orm/entity/view-link';
12+
import { ViewAnnotation } from '../src/orm/entity/view-annotation';
1013

1114
export const createTestDatabaseConnection = () => {
1215
const connectionManager = getConnectionManager();
@@ -16,12 +19,15 @@ export const createTestDatabaseConnection = () => {
1619
dropSchema: true,
1720
entities: [
1821
Asset,
22+
Image,
1923
Directory,
20-
InteractionElement,
24+
ViewImageInteractionElement,
2125
Page,
2226
Project,
2327
User,
2428
View,
29+
ViewLink,
30+
ViewAnnotation,
2531
Whiteboard
2632
]
2733
});

backend/__tests__/unit/auth-util.test.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ describe('AuthUtil', () => {
66
expect(await createHash('haash')).toBeTruthy();
77
});
88
});
9-
describe('hashMatches', async () => {
10-
const hash = await createHash('haash');
11-
expect(await hashMatches(hash, 'haash')).toBeTruthy();
9+
describe('hashMatches', () => {
10+
it('should return true for equal strings', async () => {
11+
const hash = await createHash('haash');
12+
expect(await hashMatches(hash, 'haash')).toBeTruthy();
13+
});
1214
});
1315
});

backend/__tests__/unit/markup-util.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { readFileSync } from 'fs';
33
import { resolve as resolvePath } from 'path';
44

55
describe('MarkupUtil', () => {
6-
describe('extractScriptAssets', async () => {
6+
describe('extractScriptAssets', () => {
77
it('should return all script assets defined in an HTML document', async () => {
88
const markup = readFileSync(
99
resolvePath(__dirname, '../dummy-page.html')
@@ -13,7 +13,7 @@ describe('MarkupUtil', () => {
1313
expect(scriptAssets.filter(asset => asset.isInline).length).toEqual(1);
1414
});
1515
});
16-
describe('extractStyleAssets', async () => {
16+
describe('extractStyleAssets', () => {
1717
it('should return all style assets defined in an HTML document', async () => {
1818
const markup = readFileSync(
1919
resolvePath(__dirname, '../dummy-page.html')

0 commit comments

Comments
 (0)