|
1 | | -// import { shallow } from "enzyme"; |
2 | | -// import { createElement } from "react"; |
| 1 | +import { shallow } from "enzyme"; |
| 2 | +import { createElement } from "react"; |
3 | 3 |
|
4 | | -// import Select from "react-select"; |
5 | | -// import { Label } from "../../../SharedResources/components/Label"; |
6 | | -// import { DropdownReference, DropdownReferenceProps } from "../DropdownReference"; |
7 | | -// import { Alert } from "../../../SharedResources/components/Alert"; |
| 4 | +import Select from "react-select"; |
| 5 | +import { Label } from "../../../SharedResources/components/Label"; |
| 6 | +import { DropdownReference, DropdownReferenceProps } from "../DropdownReference"; |
| 7 | +import { Alert } from "../../../SharedResources/components/Alert"; |
8 | 8 |
|
9 | | -// describe("DropdownReference", () => { |
10 | | -// const render = (props: DropdownReferenceProps) => shallow(createElement(DropdownReference, props)); |
11 | | -// const ReferenceProps: DropdownReferenceProps = { |
12 | | -// emptyOptionCaption: "Select city", |
13 | | -// labelWidth: 3, |
14 | | -// data: [ { value: "KampalaId" , label: "kampala" }, { value: "AmsterdamId" , label: "Amsterdam" } ], |
15 | | -// value: "Kampala", |
16 | | -// labelCaption: "City", |
17 | | -// loaded: false, |
18 | | -// showLabel: true, |
19 | | -// isClearable: true, |
20 | | -// isReadOnly: false, |
21 | | -// selectType: "normal", |
22 | | -// selectedValue: { value: "Kampala" , label: "kampalaId" } || null, |
23 | | -// handleOnchange: jasmine.createSpy("onClick"), |
24 | | -// readOnlyStyle: "control", |
25 | | -// labelOrientation: "horizontal", |
26 | | -// alertMessage: "No text", |
27 | | -// searchText: "search", |
28 | | -// loadingText: "loading", |
29 | | -// minimumCharacter: 1 |
30 | | -// }; |
| 9 | +describe("DropdownReference", () => { |
| 10 | + const render = (props: DropdownReferenceProps) => shallow(createElement(DropdownReference, props)); |
| 11 | + const ReferenceProps: DropdownReferenceProps = { |
| 12 | + emptyOptionCaption: "Select city", |
| 13 | + labelWidth: 3, |
| 14 | + data: [ { value: "KampalaId" , label: "kampala" }, { value: "AmsterdamId" , label: "Amsterdam" } ], |
| 15 | + value: "Kampala", |
| 16 | + labelCaption: "City", |
| 17 | + showLabel: true, |
| 18 | + isClearable: true, |
| 19 | + isReadOnly: false, |
| 20 | + selectType: "normal", |
| 21 | + selectedValue: { value: "Kampala" , label: "kampalaId" } || null, |
| 22 | + handleOnchange: jasmine.createSpy("onClick"), |
| 23 | + readOnlyStyle: "control", |
| 24 | + labelOrientation: "horizontal", |
| 25 | + alertMessage: "No text", |
| 26 | + searchText: "search", |
| 27 | + loadingText: "loading", |
| 28 | + minimumCharacter: 1 |
| 29 | + }; |
31 | 30 |
|
32 | | -// it("renders the structure correctly", () => { |
33 | | -// const DropdownReferenceComponent = render(ReferenceProps); |
34 | | -// DropdownReferenceComponent.setProps({ loaded: true }); |
| 31 | + it("renders the structure correctly", () => { |
| 32 | + const DropdownReferenceComponent = render(ReferenceProps); |
| 33 | + DropdownReferenceComponent.setProps({ loaded: true }); |
35 | 34 |
|
36 | | -// expect(DropdownReferenceComponent).toBeElement( |
37 | | -// createElement(Label, { label: "City" , orientation: "horizontal" , weight: 3 }, |
38 | | -// createElement("div", { className: "widget-dropdown-reference" }, |
39 | | -// createElement(Select, { |
40 | | -// clearable: true, |
41 | | -// noResultsText: "", |
42 | | -// disabled: false, |
43 | | -// value: { value: "Kampala" , label: "kampalaId" }, |
44 | | -// onChange: jasmine.any(Function) as any, |
45 | | -// clearValueText: "", |
46 | | -// options: [ { value: "Kampala" , label: "kampalaId" } ], |
47 | | -// onInputChange: jasmine.any(Function) as any |
48 | | -// }), |
49 | | -// createElement(Alert, { className: "widget-dropdown-type-ahead-alert", bootstrapStyle: "danger" }, "No text")) |
50 | | -// ) |
51 | | -// ); |
52 | | -// }); |
| 35 | + expect(DropdownReferenceComponent).toBeElement( |
| 36 | + createElement(Label, { label: "City" , orientation: "horizontal" , weight: 3 }, |
| 37 | + createElement("div", { className: "widget-dropdown-reference", onClick: jasmine.any(Function) }, |
| 38 | + createElement(Select, { |
| 39 | + clearable: true, |
| 40 | + noResultsText: "No results found", |
| 41 | + disabled: false, |
| 42 | + value: { value: "Kampala" , label: "kampalaId" }, |
| 43 | + onChange: jasmine.any(Function) as any, |
| 44 | + clearValueText: "Clear value", |
| 45 | + options: [ { value: "KampalaId" , label: "kampala" }, { value: "AmsterdamId" , label: "Amsterdam" } ] |
| 46 | + }), |
| 47 | + createElement(Alert, { className: "widget-dropdown-type-ahead-alert", bootstrapStyle: "danger" }, "No text")) |
| 48 | + ) |
| 49 | + ); |
| 50 | + }); |
53 | 51 |
|
54 | | -// it("with no label caption renders the structure correctly", () => { |
55 | | -// const DropdownReferenceComponent = render(ReferenceProps); |
56 | | -// DropdownReferenceComponent.setProps({ loaded: true }); |
| 52 | + it("with no label caption renders the structure correctly", () => { |
| 53 | + const DropdownReferenceComponent = render(ReferenceProps); |
| 54 | + DropdownReferenceComponent.setProps({ loaded: true }); |
57 | 55 |
|
58 | | -// DropdownReferenceComponent.setProps({ labelCaption: "", showLabel: false }); |
59 | | -// expect(DropdownReferenceComponent).toBeElement( |
60 | | -// createElement("div", { className: "widget-dropdown-reference" }, |
61 | | -// createElement(Select, { |
62 | | -// clearable: true, |
63 | | -// noResultsText: "", |
64 | | -// disabled: false, |
65 | | -// value: { value: "Kampala" , label: "kampalaId" }, |
66 | | -// onChange: jasmine.any(Function) as any, |
67 | | -// clearValueText: "", |
68 | | -// options: [ { value: "Kampala" , label: "kampalaId" } ], |
69 | | -// onInputChange: jasmine.any(Function) as any |
70 | | -// }), |
71 | | -// createElement(Alert, { className: "widget-dropdown-type-ahead-alert", bootstrapStyle: "danger" }, "No text")) |
72 | | -// ); |
73 | | -// }); |
74 | | - |
75 | | -// it("that is still loading renders with the structure", () => { |
76 | | -// const DropdownReferenceComponent = render(ReferenceProps); |
77 | | -// DropdownReferenceComponent.setProps({ loaded: false }); |
78 | | - |
79 | | -// expect(DropdownReferenceComponent).toBeElement(createElement("div", { className: "loading-data" })); |
80 | | -// }); |
81 | | - |
82 | | -// describe("with readOnlyStyle as 'text'", () => { |
83 | | -// it("renders with the structure with a selected value", () => { |
84 | | -// const DropdownReferenceComponent = render(ReferenceProps); |
85 | | -// DropdownReferenceComponent.setProps({ readOnlyStyle: "text" }); |
86 | | - |
87 | | -// // tslint:disable-next-line:no-console |
88 | | -// console.log(DropdownReferenceComponent.html()); |
89 | | - |
90 | | -// expect(DropdownReferenceComponent).toBeElement(createElement("div", { className: "loading-data" })); |
91 | | -// }); |
92 | | - |
93 | | -// it("renders with the structure with a no value", () => { |
94 | | -// const DropdownReferenceComponent = render(ReferenceProps); |
95 | | -// DropdownReferenceComponent.setProps({ readOnlyStyle: "text", selectedValue: null }); |
96 | | - |
97 | | -// expect(DropdownReferenceComponent).toBeElement(createElement("div", { className: "loading-data" })); |
98 | | -// }); |
99 | | -// }); |
100 | | -// }); |
| 56 | + DropdownReferenceComponent.setProps({ labelCaption: "", showLabel: false }); |
| 57 | + expect(DropdownReferenceComponent).toBeElement( |
| 58 | + createElement("div", { className: "widget-dropdown-reference", onClick: jasmine.any(Function) }, |
| 59 | + createElement(Select, { |
| 60 | + clearable: true, |
| 61 | + noResultsText: "No results found", |
| 62 | + disabled: false, |
| 63 | + value: { value: "Kampala" , label: "kampalaId" }, |
| 64 | + onChange: jasmine.any(Function) as any, |
| 65 | + clearValueText: "Clear value", |
| 66 | + options: [ { value: "KampalaId" , label: "kampala" }, { value: "AmsterdamId" , label: "Amsterdam" } ] |
| 67 | + }), |
| 68 | + createElement(Alert, { className: "widget-dropdown-type-ahead-alert", bootstrapStyle: "danger" }, "No text")) |
| 69 | + ); |
| 70 | + }); |
| 71 | +}); |
0 commit comments