This commit is contained in:
Chenyang Liu 2018-09-07 14:38:21 +08:00
Родитель 7dfef554a0
Коммит 6e74dad7d5
5 изменённых файлов: 32 добавлений и 4 удалений

3
client/jest.setup.ts Normal file
Просмотреть файл

@ -0,0 +1,3 @@
import { Constant } from "./tests/constant";
jest.setTimeout(Constant.timeout);

24
client/package-lock.json сгенерированный
Просмотреть файл

@ -973,6 +973,14 @@
"safer-buffer": "2.1.2"
}
},
"ecdsa-sig-formatter": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.10.tgz",
"integrity": "sha1-HFlQAPBKiJffuFAAiSoPTDOvhsM=",
"requires": {
"safe-buffer": "5.1.2"
}
},
"error-ex": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz",
@ -3151,6 +3159,22 @@
"resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz",
"integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc="
},
"njwt": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/njwt/-/njwt-0.4.0.tgz",
"integrity": "sha1-cyTtnXap1UteJly3tqPFXxRv08c=",
"requires": {
"ecdsa-sig-formatter": "1.0.10",
"uuid": "2.0.3"
},
"dependencies": {
"uuid": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.3.tgz",
"integrity": "sha1-Z+LoY3lyFVMN/zGOW/nc6/1Hsho="
}
}
},
"node-int64": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz",

Просмотреть файл

@ -5,6 +5,7 @@
"test": "jest"
},
"jest": {
"setupTestFrameworkScriptFile": "./jest.setup.ts",
"transform": {
"^.+\\.tsx?$": "ts-jest"
},

Просмотреть файл

@ -15,5 +15,5 @@ export class Constant {
public static readonly host = `http://localhost:${Constant.port}`;
public static readonly url = `${Constant.host}/chat`;
public static readonly delay = Number(process.env.DELAY || 200);
public static readonly timeout = 60000 // Timeout for each test
public static readonly timeout = Number(process.env.TIMEOUT || 60000); // Timeout for each test
}

Просмотреть файл

@ -31,7 +31,7 @@ test('join and leave group', async () => {
await connections[0].invoke(Constant.sendGroup, 'connection0', groupName, testMessage);
await delay(Constant.delay);
expect(callback[1]).not.toHaveBeenCalledWith('connection0', testMessage);
}, Constant.timeout);
});
test('send group / groups / group except', async () => {
let connectionId1 : string;
@ -78,7 +78,7 @@ test('send group / groups / group except', async () => {
await delay(Constant.delay);
expect(callback[0]).toHaveBeenCalledWith('connection1', testMessage);
expect(callback[1]).not.toHaveBeenCalledWith('connection1', testMessage);
}, Constant.timeout);
});
test('send others in group', async () => {
let connectionId0 : string;
@ -110,4 +110,4 @@ test('send others in group', async () => {
expect(callback[1]).toHaveBeenCalledWith('connection0', testMessage);
expect(callback[2]).toHaveBeenCalledWith('connection0', testMessage);
expect(callback[1]).toHaveBeenCalledTimes(3);
}, Constant.timeout);
});