-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathcontainer.unit.test.js
136 lines (122 loc) · 3.64 KB
/
container.unit.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// Copyright (c) 2014 - 2023 UNICEF. All rights reserved.
import { fromJS } from "immutable";
import MUIDataTable, { TableBodyRow } from "mui-datatables";
import IndexTable from "../../index-table";
import PageContainer, { PageHeading, PageContent } from "../../page";
import { ListHeaderRecord } from "../../user/records";
import { setupMountedComponent } from "../../../test";
import { FieldRecord } from "../../record-form";
import { mapEntriesToRecord } from "../../../libs";
import DisableOffline from "../../disable-offline";
import { ExportRecord } from "./records";
import ExportList from "./container";
describe("<ExportList />", () => {
let component;
const initialState = fromJS({
records: {
bulk_exports: {
data: [
ExportRecord({
id: "d5e1a4a019ec727efd34a35d1d9a271e",
file_name: "PRIMERO-CHILD-UNHCR.CSV",
record_type: "Case",
started_on: "2020-02-04T20:32:50.078Z"
}),
ExportRecord({
id: "d5e1a4a019ec727efd34a35d1d9a272e",
file_name: "PRIMERO - CHILD.PDF",
record_type: "Case",
started_on: "2020-02-03T20:32:50.078Z"
}),
ExportRecord({
id: "d5e1a4a019ec727efd34a35d1d9a273e",
file_name: "PRIMERO - CHILD.JSON",
record_type: "Case",
started_on: "2020-02-02T20:32:50.078Z"
})
],
metadata: {
total: 15,
per: 20,
page: 1
},
errors: false
}
},
user: {
listHeaders: {
bulk_exports: [
ListHeaderRecord({
name: "file_name",
field_name: "file_name",
id_search: false
}),
ListHeaderRecord({
name: "record_type",
field_name: "record_type",
id_search: false
}),
ListHeaderRecord({
name: "started_on",
field_name: "started_on",
id_search: false
})
]
},
permissions: {
exports: ["manage"],
bulk_exports: ["manage"]
}
},
forms: {
fields: mapEntriesToRecord(
{
1: {
name: "name_first",
type: "text_field"
}
},
FieldRecord
),
options: {
lookups: [
{
id: 1,
unique_id: "lookup-location-type",
values: [
{ id: "country", display_text: "Country" },
{ id: "region", display_text: "Region" }
]
}
]
}
}
});
beforeEach(() => {
({ component } = setupMountedComponent(ExportList, {}, initialState));
});
it("should render a table with three rows", () => {
expect(component.find(MUIDataTable).find(TableBodyRow)).to.have.lengthOf(3);
});
it("should render <PageContainer>", () => {
expect(component.find(PageContainer)).to.have.lengthOf(1);
});
it("should render <PageHeading>", () => {
expect(component.find(PageHeading)).to.have.lengthOf(1);
});
it("should render <PageContent>", () => {
expect(component.find(PageContent)).to.have.lengthOf(1);
});
it("should render <IndexTable>", () => {
expect(component.find(IndexTable)).to.have.lengthOf(1);
});
describe("when offline", () => {
const stateOffline = initialState.setIn(["application", "online"], false);
beforeEach(() => {
({ component } = setupMountedComponent(ExportList, {}, stateOffline));
});
it("should render DisabledOffline components for each row", () => {
expect(component.find(DisableOffline)).to.have.lengthOf(9);
});
});
});