1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-12-25 08:28:08 +00:00

Added tests for network utils

This commit is contained in:
Vladimir Volek 2018-09-13 13:08:25 +02:00
parent bd86bb22f9
commit 2cfb955e62
4 changed files with 23 additions and 5 deletions

View File

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

View File

@ -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",

View File

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

View File

@ -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();
});
});