-
Notifications
You must be signed in to change notification settings - Fork 4
/
MetadataServices-test.tsx
70 lines (63 loc) · 1.54 KB
/
MetadataServices-test.tsx
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
import { expect } from "chai";
import { stub } from "sinon";
import * as React from "react";
import { mount } from "enzyme";
import { MetadataServices } from "../MetadataServices";
describe("MetadataServices", () => {
let wrapper;
let fetchData;
let editItem;
const data = {
metadata_services: [
{
id: 2,
protocol: "test protocol",
name: "sample name",
settings: {
test_setting: "test setting",
},
libraries: [{ short_name: "nypl" }],
},
],
protocols: [
{
name: "test protocol",
label: "test protocol label",
sitewide: false,
settings: [],
},
],
allLibraries: [
{
short_name: "nypl",
},
],
};
const pause = () => {
return new Promise<void>((resolve) => setTimeout(resolve, 0));
};
beforeEach(() => {
fetchData = stub();
editItem = stub().returns(
new Promise<void>((resolve) => resolve())
);
wrapper = mount(
<MetadataServices
data={data}
fetchData={fetchData}
editItem={editItem}
csrfToken="token"
isFetching={false}
/>
);
});
it("shows metadata service list", () => {
const metadataService = wrapper.find("li");
expect(metadataService.length).to.equal(1);
expect(metadataService.at(0).text()).to.contain(
"sample name: test protocol"
);
const editLink = metadataService.at(0).find("a").at(0);
expect(editLink.props().href).to.equal("/admin/web/config/metadata/edit/2");
});
});