You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trezor-wallet/src/utils/__tests__/device.test.js

90 lines
2.2 KiB

import * as dUtils from 'utils/device';
describe('device utils', () => {
it('get status', () => {
const deviceMock = [
{
connected: false,
},
{
connected: true,
available: false,
},
{
connected: true,
available: false,
type: null,
},
{
connected: true,
available: true,
type: 'acquired',
},
{
connected: true,
available: true,
type: 'unacquired',
},
{
connected: true,
available: true,
type: 'acquired',
status: 'occupied',
},
];
deviceMock.forEach((device) => {
expect(dUtils.getStatus(device)).toMatchSnapshot();
});
});
it('get version', () => {
const deviceMock = [
{ },
{ features: {} },
{ features: { major_version: null } },
{ features: { major_version: 0 } },
{ features: { major_version: 1 } },
{ features: { major_version: 2 } },
];
deviceMock.forEach((device) => {
expect(dUtils.getVersion(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();
});
});
});