2021-08-04 22:23:57 +02:00
|
|
|
import assert from 'assert';
|
2018-03-18 15:15:10 +00:00
|
|
|
import React from 'react';
|
2018-09-15 19:52:58 -04:00
|
|
|
import TestRenderer from 'react-test-renderer';
|
2024-05-20 10:54:13 +01:00
|
|
|
|
2024-05-03 19:03:40 -04:00
|
|
|
import { Header } from '../../components/Header';
|
2024-06-07 23:54:14 -04:00
|
|
|
import SelfTest from '../../screen/settings/SelfTest';
|
2024-05-20 10:54:13 +01:00
|
|
|
import Settings from '../../screen/settings/Settings';
|
2021-08-04 22:23:57 +02:00
|
|
|
|
2023-03-04 13:51:11 -04:00
|
|
|
jest.mock('../../blue_modules/BlueElectrum', () => {
|
|
|
|
return {
|
|
|
|
connectMain: jest.fn(),
|
|
|
|
};
|
2021-08-04 22:23:57 +02:00
|
|
|
});
|
|
|
|
|
2024-05-03 19:03:40 -04:00
|
|
|
it('Header works', () => {
|
|
|
|
const rendered = TestRenderer.create(<Header />).toJSON();
|
2018-03-18 15:15:10 +00:00
|
|
|
expect(rendered).toBeTruthy();
|
|
|
|
});
|
|
|
|
|
2023-07-25 14:50:04 +01:00
|
|
|
// eslint-disable-next-line jest/no-disabled-tests
|
2019-03-31 02:15:02 +01:00
|
|
|
it.skip('Settings work', () => {
|
2018-09-15 19:52:58 -04:00
|
|
|
const rendered = TestRenderer.create(<Settings />).toJSON();
|
2018-03-18 15:15:10 +00:00
|
|
|
expect(rendered).toBeTruthy();
|
|
|
|
});
|
2018-03-24 20:12:59 +00:00
|
|
|
|
2024-05-25 07:44:43 -04:00
|
|
|
it('SelfTest work', () => {
|
|
|
|
const component = TestRenderer.create(<SelfTest />);
|
2018-03-24 20:12:59 +00:00
|
|
|
const root = component.root;
|
|
|
|
const rendered = component.toJSON();
|
|
|
|
expect(rendered).toBeTruthy();
|
|
|
|
// console.log((root.findAllByType('Text')[0].props));
|
|
|
|
|
|
|
|
let okFound = false;
|
2020-06-01 15:54:23 +03:00
|
|
|
const allTests = [];
|
2021-05-08 09:41:45 +03:00
|
|
|
for (const v of root.findAllByType('Text')) {
|
2018-03-24 20:12:59 +00:00
|
|
|
let text = v.props.children;
|
|
|
|
if (text.join) {
|
|
|
|
text = text.join('');
|
|
|
|
}
|
|
|
|
if (text === 'OK') {
|
|
|
|
okFound = true;
|
|
|
|
}
|
|
|
|
allTests.push(text);
|
|
|
|
// console.log(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
assert.ok(okFound, 'OK not found. Got: ' + allTests.join('; '));
|
|
|
|
});
|