-
Notifications
You must be signed in to change notification settings - Fork 4
/
BookDetailsContainer-test.tsx
68 lines (60 loc) · 1.94 KB
/
BookDetailsContainer-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
import { expect } from "chai";
import { stub } from "sinon";
import * as React from "react";
import { shallow } from "enzyme";
import buildStore from "../../store";
import BookDetailsContainer from "../BookDetailsContainer";
import BookDetailsTabContainer from "../BookDetailsTabContainer";
import BookDetails from "../BookDetails";
class DefaultBookDetails extends React.Component<any, any> {
render() {
return <div></div>;
}
}
describe("BookDetailsContainer", () => {
let wrapper;
let store;
let context;
let refreshCatalog;
const bookData = {
id: "book id",
url: "book url",
title: "book title",
};
beforeEach(() => {
store = buildStore();
context = {
editorStore: store,
csrfToken: "token",
library: stub(),
admin: { isLibraryManager: () => true },
};
refreshCatalog = stub();
wrapper = shallow(
<BookDetailsContainer
book={bookData}
bookUrl="book url"
collectionUrl="collection url"
refreshCatalog={refreshCatalog}
>
<DefaultBookDetails book={bookData} anotherProp="anotherProp" />
</BookDetailsContainer>,
{ context }
);
});
it("renders BookDetails with its child's props", () => {
const bookDetails = wrapper.find(BookDetails);
expect(bookDetails.prop("book")).to.equal(bookData);
expect(bookDetails.prop("anotherProp")).to.equal("anotherProp");
});
it("shows a tab container with initial tab", () => {
const tabContainer = wrapper.find(BookDetailsTabContainer);
expect(tabContainer).to.be.ok;
expect(tabContainer.props().bookUrl).to.equal("book url");
expect(tabContainer.props().collectionUrl).to.equal("collection url");
expect(tabContainer.props().library).to.equal(context.library);
expect(tabContainer.props().csrfToken).to.equal("token");
expect(tabContainer.props().refreshCatalog).to.equal(refreshCatalog);
expect(tabContainer.props().store).to.equal(store);
});
});