2020-03-20 11:46:11 +00:00
|
|
|
/* global it, expect, jest */
|
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';
|
2019-06-08 13:57:44 +01:00
|
|
|
import Settings from '../../screen/settings/settings';
|
|
|
|
import Selftest from '../../screen/selftest';
|
|
|
|
import { BlueHeader } from '../../BlueComponents';
|
2020-06-01 15:54:23 +03:00
|
|
|
const assert = require('assert');
|
2019-02-14 00:15:56 -05:00
|
|
|
jest.mock('react-native-qrcode-svg', () => 'Video');
|
2018-07-07 22:15:14 +01:00
|
|
|
jest.useFakeTimers();
|
2019-07-21 17:40:25 +01:00
|
|
|
|
|
|
|
jest.mock('amplitude-js', () => ({
|
2020-06-01 15:54:23 +03:00
|
|
|
getInstance: function () {
|
2019-07-21 17:40:25 +01:00
|
|
|
return {
|
|
|
|
init: jest.fn(),
|
|
|
|
logEvent: jest.fn(),
|
|
|
|
};
|
|
|
|
},
|
|
|
|
}));
|
|
|
|
|
2018-03-18 15:15:10 +00:00
|
|
|
it('BlueHeader works', () => {
|
2018-09-15 19:52:58 -04:00
|
|
|
const rendered = TestRenderer.create(<BlueHeader />).toJSON();
|
2018-03-18 15:15:10 +00:00
|
|
|
expect(rendered).toBeTruthy();
|
|
|
|
});
|
|
|
|
|
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
|
|
|
|
|
|
|
it('Selftest work', () => {
|
2018-09-15 19:52:58 -04:00
|
|
|
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 = [];
|
2018-03-24 20:12:59 +00:00
|
|
|
for (var v of root.findAllByType('Text')) {
|
|
|
|
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('; '));
|
|
|
|
});
|