diff --git a/jest.config.js b/jest.config.js index 3017fba1..beda6ad6 100644 --- a/jest.config.js +++ b/jest.config.js @@ -7,6 +7,7 @@ module.exports = { modulePathIgnorePatterns: [ 'node_modules', 'utils/windowUtils.js', + 'utils/promiseUtils.js', ], collectCoverageFrom: [ 'utils/**.js', diff --git a/package.json b/package.json index 3467d307..1fe60c8a 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "styled-components": "^3.3.3", "styled-media-query": "^2.0.2", "styled-normalize": "^8.0.0", - "trezor-connect": "5.0.30", + "trezor-connect": "../connect/src/index.js", "web3": "^0.19.0", "webpack": "^4.16.3", "webpack-bundle-analyzer": "^2.13.1", diff --git a/src/utils/__tests__/__snapshots__/networkUtils.test.js.snap b/src/utils/__tests__/__snapshots__/networkUtils.test.js.snap new file mode 100644 index 00000000..514a0f3d --- /dev/null +++ b/src/utils/__tests__/__snapshots__/networkUtils.test.js.snap @@ -0,0 +1,13 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`network utils JSONRequest ok 1`] = ` +Object { + "test_json": "01234", +} +`; + +exports[`network utils httpRequest json ok response 1`] = ` +Object { + "test_json": "12345", +} +`; diff --git a/src/utils/__tests__/networkUtils.test.js b/src/utils/__tests__/networkUtils.test.js index 190707ce..b5b00116 100644 --- a/src/utils/__tests__/networkUtils.test.js +++ b/src/utils/__tests__/networkUtils.test.js @@ -5,11 +5,15 @@ describe('network utils', () => { fetch.resetMocks(); }); - it('httpRequest', () => { - + it('httpRequest json ok response', async () => { + fetch.mockResponse(JSON.stringify({ test_json: '12345' })); + const result = await networkUtils.httpRequest('/test/', 'json'); + expect(result).toMatchSnapshot(); }); - it('JSONRequest', () => { - + it('JSONRequest ok', async () => { + fetch.mockResponse(JSON.stringify({ test_json: '01234' })); + const result = await networkUtils.JSONRequest('/test/'); + expect(result).toMatchSnapshot(); }); });