1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-28 03:08:30 +00:00

Added unit tests for device

This commit is contained in:
Vladimir Volek 2018-08-25 12:59:12 +02:00
parent 4b2dabde38
commit 630c55ad4c
4 changed files with 98 additions and 3 deletions

View File

@ -22,7 +22,7 @@
"lint": "run-s lint:*",
"lint:js": "eslint ./src/js ./webpack",
"lint:css": "stylelint './src/js/**/*.js'",
"test:*": "run-s test:*",
"test": "run-s test:*",
"test:unit": "jest",
"test-unit:watch": "jest -o --watchAll"
},

View File

@ -0,0 +1,41 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`device utils get status 1`] = `"Status unknown"`;
exports[`device utils get status 2`] = `"Status unknown"`;
exports[`device utils get status 3`] = `"Status unknown"`;
exports[`device utils get status 4`] = `"Status unknown"`;
exports[`device utils get status color 1`] = `"#494949"`;
exports[`device utils get status color 2`] = `"#494949"`;
exports[`device utils get status color 3`] = `"#494949"`;
exports[`device utils get status color 4`] = `"#EB8A00"`;
exports[`device utils get status color 5`] = `"#01B757"`;
exports[`device utils get status color 6`] = `"#EB8A00"`;
exports[`device utils get status color 7`] = `"#ED1212"`;
exports[`device utils get status color 8`] = `"#ED1212"`;
exports[`device utils get status name 1`] = `"Status unknown"`;
exports[`device utils get status name 2`] = `"Status unknown"`;
exports[`device utils get status name 3`] = `"Status unknown"`;
exports[`device utils get status name 4`] = `"Used in other window"`;
exports[`device utils get status name 5`] = `"Connected"`;
exports[`device utils get status name 6`] = `"Used in other window"`;
exports[`device utils get status name 7`] = `"Disconnected"`;
exports[`device utils get status name 8`] = `"Unavailable"`;

View File

@ -0,0 +1,56 @@
import * as dUtils from 'utils/device';
describe('device utils', () => {
it('get status', () => {
const deviceMock = [
{
device: {
connected: false,
type: 'acquired',
status: 'occupied',
},
},
{ device: { connected: true } },
{ device: { available: false } },
{ device: { available: true } },
];
deviceMock.forEach((device) => {
expect(dUtils.getStatusName(device)).toMatchSnapshot();
});
});
it('get status color', () => {
const entry = [
0,
null,
'sdsdsdsd',
'used-in-other-window',
'connected',
'unacquired',
'disconnected',
'unavailable',
];
entry.forEach((status) => {
expect(dUtils.getStatusColor(status)).toMatchSnapshot();
});
});
it('get status name', () => {
const entry = [
0,
null,
'sdsdsdsd',
'used-in-other-window',
'connected',
'unacquired',
'disconnected',
'unavailable',
];
entry.forEach((status) => {
expect(dUtils.getStatusName(status)).toMatchSnapshot();
});
});
});

View File

@ -37,8 +37,6 @@ const AppWrapper = styled.div`
background: ${colors.BACKGROUND};
&.resized {
// to make sure that unpacked coin menu will not overflow main container
// 512 dropdown height + 50 header + 30 margin + 64 topnav height
min-height: 680px;
}
`;