mirror of
https://github.com/trezor/trezor-wallet
synced 2024-11-24 09:18:09 +00:00
Added more tests
This commit is contained in:
parent
2cfb955e62
commit
fc9adc95a4
@ -1,13 +1,21 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`network utils JSONRequest ok 1`] = `
|
||||
exports[`network utils JSONRequest 1`] = `
|
||||
Object {
|
||||
"test_json": "01234",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`network utils httpRequest json ok response 1`] = `
|
||||
exports[`network utils JSONRequest error 1`] = `[Error: jsonRequest error: [object Object]]`;
|
||||
|
||||
exports[`network utils httpRequest error (500) 1`] = `[Error: /test/ Internal Server Error]`;
|
||||
|
||||
exports[`network utils httpRequest json ok response binary 1`] = `Promise {}`;
|
||||
|
||||
exports[`network utils httpRequest json ok response json 1`] = `
|
||||
Object {
|
||||
"test_json": "12345",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`network utils httpRequest json ok response text 1`] = `Promise {}`;
|
||||
|
@ -5,15 +5,45 @@ describe('network utils', () => {
|
||||
fetch.resetMocks();
|
||||
});
|
||||
|
||||
it('httpRequest json ok response', async () => {
|
||||
it('httpRequest json ok response json', async () => {
|
||||
fetch.mockResponse(JSON.stringify({ test_json: '12345' }));
|
||||
const result = await networkUtils.httpRequest('/test/', 'json');
|
||||
const result = await networkUtils.httpRequest('/http-request-test-response-json/', 'json');
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('JSONRequest ok', async () => {
|
||||
it('httpRequest json ok response text', async () => {
|
||||
fetch.mockResponse(JSON.stringify({ test_json: '12345' }));
|
||||
const result = networkUtils.httpRequest('/http-request-test-response-text/', 'text');
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('httpRequest json ok response binary', async () => {
|
||||
fetch.mockResponse(1);
|
||||
const result = networkUtils.httpRequest('/http-request-test-response-binary/', 'binary');
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('httpRequest error (500)', async () => {
|
||||
fetch.mockResponse(JSON.stringify({ test_json: '12345' }), { status: 500 });
|
||||
try {
|
||||
await networkUtils.httpRequest('/test/', 'json');
|
||||
} catch (err) {
|
||||
expect(err).toMatchSnapshot();
|
||||
}
|
||||
});
|
||||
|
||||
it('JSONRequest', async () => {
|
||||
fetch.mockResponse(JSON.stringify({ test_json: '01234' }));
|
||||
const result = await networkUtils.JSONRequest('/test/');
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('JSONRequest error', async () => {
|
||||
fetch.mockResponse(JSON.stringify({ test_json: '12345' }), { status: 500 });
|
||||
try {
|
||||
await networkUtils.JSONRequest('/test/', 'json');
|
||||
} catch (err) {
|
||||
expect(err).toMatchSnapshot();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user