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
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Import libs
const { shallow } = require("enzyme");
const { createFactory } = require("react");
const {
setupStore,
} = require("resource://devtools/client/application/test/node/helpers.js");
const {
MANIFEST_SIMPLE,
} = require("resource://devtools/client/application/test/node/fixtures/data/constants.js");
const ManifestPage = createFactory(
require("resource://devtools/client/application/src/components/manifest/ManifestPage.js")
);
/**
* Test for ManifestPage.js component
*/
describe("ManifestPage", () => {
function buildStoreWithManifest(manifest, isLoading = false) {
return setupStore({
manifest: {
manifest,
errorMessage: "",
isLoading,
},
});
}
it("renders the expected snapshot when there is a manifest", () => {
const store = buildStoreWithManifest(MANIFEST_SIMPLE);
const wrapper = shallow(ManifestPage({ store })).dive();
expect(wrapper).toMatchSnapshot();
});
it("renders the expected snapshot when the manifest needs to load", () => {
const store = buildStoreWithManifest(undefined);
const wrapper = shallow(ManifestPage({ store })).dive();
expect(wrapper).toMatchSnapshot();
});
it("renders the expected snapshot when the manifest is loading", () => {
const store = buildStoreWithManifest(undefined, true);
const wrapper = shallow(ManifestPage({ store })).dive();
expect(wrapper).toMatchSnapshot();
});
it("renders the expected snapshot when there is no manifest", () => {
const store = buildStoreWithManifest(null);
const wrapper = shallow(ManifestPage({ store })).dive();
expect(wrapper).toMatchSnapshot();
});
});
|