forked from firefox-devtools/profiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Home.test.js
78 lines (61 loc) · 2.39 KB
/
Home.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// @flow
import * as React from 'react';
import Home from '../../components/app/Home';
import renderer from 'react-test-renderer';
import { Provider } from 'react-redux';
import createStore from '../../app-logic/create-store';
// Provide a mechanism to overwrite the navigator.userAgent, which can't be set.
const FIREFOX_WEBEXT =
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:55.0) Gecko/20100101 Firefox/55.0';
const FIREFOX_LEGACY =
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:53.0) Gecko/20100101 Firefox/53.0';
const SAFARI =
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8';
let userAgent;
// Flow doesn't understand Object.defineProperty. Use the "any" type to use it anyway.
(Object.defineProperty: any)(window.navigator, 'userAgent', {
get: () => userAgent,
});
describe('app/Home', function() {
it('renders the install screen for the extension', () => {
userAgent = FIREFOX_WEBEXT;
const home = renderer.create(
<Provider store={createStore()}>
<Home specialMessage="This is a special message" />
</Provider>
);
expect(home.toJSON()).toMatchSnapshot();
});
it('renders the install screen for the legacy add-on', () => {
userAgent = FIREFOX_LEGACY;
const home = renderer.create(
<Provider store={createStore()}>
<Home specialMessage="This is a special message" />
</Provider>
);
expect(home.toJSON()).toMatchSnapshot();
});
it('renders the information screen for other browsers', () => {
userAgent = SAFARI;
const home = renderer.create(
<Provider store={createStore()}>
<Home specialMessage="This is a special message" />
</Provider>
);
expect(home.toJSON()).toMatchSnapshot();
});
it('renders the usage instructions for pages with the extension installed', () => {
userAgent = FIREFOX_WEBEXT;
window.isGeckoProfilerAddonInstalled = true;
const home = renderer.create(
<Provider store={createStore()}>
<Home specialMessage="This is a special message" />
</Provider>
);
expect(home.toJSON()).toMatchSnapshot();
delete window.isGeckoProfilerAddonInstalled;
});
});