Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
Upgrade jest
Browse files Browse the repository at this point in the history
Had to do this sooner or later: done() signature changed; any argument
will be treated as a failure.

Note: coverage broken until we/they update istanbul-coverage
(jestjs/jest#5772)
  • Loading branch information
bryfox committed Apr 13, 2018
1 parent 55f5864 commit 5901483
Show file tree
Hide file tree
Showing 13 changed files with 8,956 additions and 5,912 deletions.
14,753 changes: 8,905 additions & 5,848 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"fs-extra": "3.0.1",
"html-webpack-plugin": "^2.30.1",
"icon-gen": "^1.0.7",
"jest": "20.0.4",
"jest": "^22.4.3",
"jest-fetch-mock": "^1.4.2",
"jsdoc": "^3.4.3",
"jsdoc-babel": "^0.3.0",
Expand Down
15 changes: 6 additions & 9 deletions src/main/data-managers/__tests__/DeviceManager-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('the DeviceManager', () => {
it('creates a new device', (done) => {
deviceManager.createDeviceDocument(mockSaltHex, mockSecretHex)
.then(doc => expect(doc).toHaveProperty('_id'))
.then(done);
.then(() => done());
});

it('will not create without a valid salt', async () => {
Expand All @@ -31,13 +31,10 @@ describe('the DeviceManager', () => {
it('will not create with a short secret');
it('will not create with a short salt');

it('loads all devices', (done) => {
deviceManager.createDeviceDocument(mockSaltHex, mockSecretHex)
.then(() => deviceManager.fetchDeviceList())
.then((devices) => {
expect(devices).toBeInstanceOf(Array);
expect(devices.length).toBe(1);
})
.then(done);
it('loads all devices', async () => {
await deviceManager.createDeviceDocument(mockSaltHex, mockSecretHex);
const devices = await deviceManager.fetchDeviceList();
expect(devices).toBeInstanceOf(Array);
expect(devices.length).toBe(1);
});
});
8 changes: 3 additions & 5 deletions src/main/worker/__tests__/DeviceAPI-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ jest.mock('../pairingRequestService');

describe('the DeviceAPI', () => {
const dataDir = '';
// let mockPairingDbRecord;
// const send = 'json'; // the send method used in restify response handlers

describe('out-of-band IPC delegate', () => {
let consoleError;
Expand Down Expand Up @@ -45,11 +43,11 @@ describe('the DeviceAPI', () => {

beforeEach((done) => {
deviceApi = new DeviceAPI(dataDir, mockDelegate);
deviceApi.listen(testPortNumber).then(done);
deviceApi.listen(testPortNumber).then(() => done());
});

afterEach((done) => {
deviceApi.close().then(done);
deviceApi.close().then(() => done());
});

describe('GET /devices/new', () => {
Expand All @@ -68,7 +66,7 @@ describe('the DeviceAPI', () => {

describe('POST /devices', () => {
beforeEach(() => {
// Note: mockReturnValue(Promise.reject(...)) triggers UnhandledPromiseRejectionWarning
// Note: mockRejectedValue() triggers UnhandledPromiseRejectionWarning
deviceApi.requestService.verifyRequest.mockImplementation(() => (
Promise.reject(new RequestError())
));
Expand Down
3 changes: 1 addition & 2 deletions src/main/worker/__tests__/Server-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ describe('Server', () => {
beforeEach((done) => {
server = new Server();
deviceService = new DeviceService({});
deviceService.start()
.then(done);
deviceService.start().then(() => done());
});

afterEach(() => deviceService.stop());
Expand Down
6 changes: 3 additions & 3 deletions src/main/worker/__tests__/adminService-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('the AdminService', () => {
});

afterEach((done) => {
adminService.stop().then(done);
adminService.stop().then(() => done());
});

it('defines an API', () => {
Expand All @@ -52,7 +52,7 @@ describe('the AdminService', () => {
let otherService;

beforeEach((done) => {
otherService = new net.Server().listen(testPortNumber, 'localhost', done);
otherService = new net.Server().listen(testPortNumber, 'localhost', () => done());
});

afterEach(() => {
Expand All @@ -68,7 +68,7 @@ describe('the AdminService', () => {
});

describe('running', () => {
beforeEach(done => adminService.start(testPortNumber).then(done));
beforeEach(done => adminService.start(testPortNumber).then(() => done()));

describe('/health', () => {
const endpoint = makeUrl('/health', apiBase);
Expand Down
9 changes: 3 additions & 6 deletions src/main/worker/__tests__/pairingCodeFactory-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
const Factory = require('../pairingCodeFactory');

describe('the PairingCodeFactory', () => {
it('can generate a pairing code', (done) => {
Factory.generatePairingCodeAsync()
.then((code) => {
expect(code).toEqual(expect.any(String));
})
.then(done);
it('can generate a pairing code', async () => {
const code = await Factory.generatePairingCodeAsync();
expect(code).toEqual(expect.any(String));
});
});
9 changes: 4 additions & 5 deletions src/main/worker/__tests__/pairingRequestService-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ describe('PairingRequest Service', () => {
});
});

it('verifies an existing request', (done) => {
reqSvc.createRequest()
.then(req => reqSvc.verifyRequest(req._id, req.pairingCode))
.then(resp => expect(resp))
.then(done);
it('verifies an existing request', async () => {
const req = await reqSvc.createRequest();
expect(reqSvc.verifyRequest(req._id, req.pairingCode)).resolves
.toMatchObject({ pairingCode: expect.any(String) });
});

it('rejects a missing or expired request', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ ShallowWrapper {
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <MenuItem
action={[Function]}
>
>
Foo
</MenuItem>,
</MenuItem>,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
"getNode": [Function],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ShallowWrapper {
Symbol(enzyme.__unrendered__): <PanelItem
label="foo"
value="bar"
/>,
/>,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
"getNode": [Function],
Expand All @@ -23,14 +23,14 @@ ShallowWrapper {
"children": Array [
<div
className="panel-item__label"
>
>
foo
</div>,
</div>,
<div
className="panel-item__value"
>
>
bar
</div>,
</div>,
],
"className": "panel-item",
},
Expand Down Expand Up @@ -72,14 +72,14 @@ ShallowWrapper {
"children": Array [
<div
className="panel-item__label"
>
>
foo
</div>,
</div>,
<div
className="panel-item__value"
>
>
bar
</div>,
</div>,
],
"className": "panel-item",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ ShallowWrapper {
Symbol(enzyme.__unrendered__): <ServerPanel
className=""
serverOverview={
Object {
"clients": 0,
"ip": "x.x.x.x",
"publicKey": "",
"uptime": 0,
}
Object {
"clients": 0,
"ip": "x.x.x.x",
"publicKey": "",
"uptime": 0,
}
}
/>,
/>,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
"getNode": [Function],
Expand All @@ -31,15 +31,15 @@ ShallowWrapper {
<PanelItem
label="Server Public IP"
value="\\"x.x.x.x\\""
/>,
/>,
<PanelItem
label="Uptime"
value={0}
/>,
/>,
<PanelItem
label="Server Public Key"
value=""
/>,
/>,
],
"className": "server-panel ",
},
Expand Down Expand Up @@ -94,15 +94,15 @@ ShallowWrapper {
<PanelItem
label="Server Public IP"
value="\\"x.x.x.x\\""
/>,
/>,
<PanelItem
label="Uptime"
value={0}
/>,
/>,
<PanelItem
label="Server Public Key"
value=""
/>,
/>,
],
"className": "server-panel ",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ ShallowWrapper {
Symbol(enzyme.__unrendered__): <Expandable
className="foo"
open={false}
>
>
Bar
</Expandable>,
</Expandable>,
Symbol(enzyme.__renderer__): Object {
"batchedUpdates": [Function],
"getNode": [Function],
Expand Down
11 changes: 4 additions & 7 deletions src/renderer/utils/__tests__/adminApiClient-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,12 @@ describe('an AdminApiClient', () => {
fetch.resetMocks();
});

it('can get the server status', (done) => {
it('can get the server status', async () => {
const mockStatus = { uptime: 100 };
fetch.mockResponse(JSON.stringify({ serverStatus: mockStatus }));
client.get('/health')
.then((data) => {
expect(data).toHaveProperty('serverStatus');
expect(data.serverStatus).toMatchObject(mockStatus);
})
.then(done);
const data = await client.get('/health');
expect(data).toHaveProperty('serverStatus');
expect(data.serverStatus).toMatchObject(mockStatus);
});

it('can post data', async () => {
Expand Down

0 comments on commit 5901483

Please sign in to comment.