Added tests for network utils

pull/26/head
Vladimir Volek 6 years ago
parent bd86bb22f9
commit 2cfb955e62

@ -7,6 +7,7 @@ module.exports = {
modulePathIgnorePatterns: [ modulePathIgnorePatterns: [
'node_modules', 'node_modules',
'utils/windowUtils.js', 'utils/windowUtils.js',
'utils/promiseUtils.js',
], ],
collectCoverageFrom: [ collectCoverageFrom: [
'utils/**.js', 'utils/**.js',

@ -58,7 +58,7 @@
"styled-components": "^3.3.3", "styled-components": "^3.3.3",
"styled-media-query": "^2.0.2", "styled-media-query": "^2.0.2",
"styled-normalize": "^8.0.0", "styled-normalize": "^8.0.0",
"trezor-connect": "5.0.30", "trezor-connect": "../connect/src/index.js",
"web3": "^0.19.0", "web3": "^0.19.0",
"webpack": "^4.16.3", "webpack": "^4.16.3",
"webpack-bundle-analyzer": "^2.13.1", "webpack-bundle-analyzer": "^2.13.1",

@ -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",
}
`;

@ -5,11 +5,15 @@ describe('network utils', () => {
fetch.resetMocks(); 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();
}); });
}); });

Loading…
Cancel
Save