orc-shared 5.10.1-dev.7 → 5.10.1-dev.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Authenticate.js +41 -17
- package/dist/components/ErrorPlaceholder.js +8 -24
- package/dist/components/{Icon.js → Form/Inputs/MultiSelector.js} +33 -20
- package/dist/components/Form/Inputs/index.js +1 -1
- package/dist/components/LoadingIcon.js +6 -16
- package/dist/components/MaterialUI/Inputs/Select.js +10 -0
- package/dist/components/MaterialUI/Inputs/SelectProps.js +3 -1
- package/dist/components/MaterialUI/Navigation/DropDownMenu.js +2 -4
- package/dist/components/Provision.js +30 -13
- package/dist/components/Routing/SegmentPage.js +115 -56
- package/dist/components/Scope/ScopeNode.js +68 -45
- package/dist/components/Sidepanel.js +57 -23
- package/dist/components/Spritesheet.js +33 -17
- package/dist/components/Text.js +1 -60
- package/dist/components/Treeview/Branch.js +82 -20
- package/dist/components/Treeview/Label.js +108 -31
- package/dist/components/Treeview/Leaf.js +56 -12
- package/dist/components/Treeview/Node.js +22 -9
- package/dist/components/Treeview/index.js +7 -1
- package/dist/components/Treeview/settings.js +7 -5
- package/dist/utils/index.js +0 -4
- package/dist/utils/testUtils.js +1 -12
- package/package.json +1 -1
- package/src/components/ApplicationModuleLoader.test.js +14 -27
- package/src/components/Authenticate.js +29 -21
- package/src/components/Authenticate.test.js +18 -27
- package/src/components/ErrorPlaceholder.js +4 -21
- package/src/components/ErrorPlaceholder.test.js +7 -14
- package/src/components/Form/InputField.test.js +2 -1
- package/src/components/Form/Inputs/MultiSelector.js +23 -0
- package/src/components/Form/Inputs/MultiSelector.test.js +112 -0
- package/src/components/Form/Inputs/index.js +1 -1
- package/src/components/Loader.test.js +21 -33
- package/src/components/LoadingIcon.js +2 -15
- package/src/components/LoadingIcon.test.js +2 -20
- package/src/components/MaterialUI/DataDisplay/Table.test.js +1 -1
- package/src/components/MaterialUI/Inputs/Select.js +7 -0
- package/src/components/MaterialUI/Inputs/Select.test.js +45 -0
- package/src/components/MaterialUI/Inputs/SelectProps.js +2 -0
- package/src/components/MaterialUI/Inputs/SelectProps.test.js +2 -0
- package/src/components/MaterialUI/Navigation/DropDownMenu.js +2 -2
- package/src/components/MaterialUI/Navigation/DropDownMenu.test.js +5 -6
- package/src/components/Navigation/Navigation.test.js +0 -5
- package/src/components/Navigation/useNavigationState.test.js +79 -222
- package/src/components/Provision.js +36 -42
- package/src/components/Provision.test.js +10 -26
- package/src/components/Routing/SegmentPage.js +68 -52
- package/src/components/Routing/SegmentPage.test.js +4 -12
- package/src/components/Scope/ScopeNode.js +61 -54
- package/src/components/Scope/ScopeNode.test.js +61 -154
- package/src/components/ScopeExtendedConfigurationLoader.test.js +1 -4
- package/src/components/Sidepanel.js +38 -32
- package/src/components/Sidepanel.test.js +49 -27
- package/src/components/Spritesheet.js +23 -21
- package/src/components/Spritesheet.test.js +10 -10
- package/src/components/Text.js +0 -49
- package/src/components/Treeview/Branch.js +63 -45
- package/src/components/Treeview/Branch.test.js +21 -24
- package/src/components/Treeview/Label.js +66 -52
- package/src/components/Treeview/Label.test.js +42 -60
- package/src/components/Treeview/Leaf.js +41 -22
- package/src/components/Treeview/Leaf.test.js +15 -10
- package/src/components/Treeview/Node.js +16 -9
- package/src/components/Treeview/Node.test.js +269 -200
- package/src/components/Treeview/Treeview.test.js +248 -248
- package/src/components/Treeview/index.js +6 -0
- package/src/components/Treeview/settings.js +7 -6
- package/src/utils/index.js +0 -4
- package/src/utils/testUtils.js +0 -10
- package/src/utils/testUtils.test.js +0 -68
- package/dist/components/Button.js +0 -70
- package/dist/components/Checkbox.js +0 -103
- package/dist/components/IconButton.js +0 -80
- package/dist/components/Input.js +0 -101
- package/dist/components/Modal/Background.js +0 -55
- package/dist/components/Modal/Dialog.js +0 -75
- package/dist/components/Modal/Wrapper.js +0 -69
- package/dist/components/Modal/index.js +0 -86
- package/dist/components/MultiSelector.js +0 -187
- package/dist/components/Navigation/Bar.js +0 -293
- package/dist/components/Navigation/Tab.js +0 -182
- package/dist/components/Placeholder.js +0 -114
- package/dist/components/Scope/Selector.js +0 -123
- package/dist/components/Selector.js +0 -185
- package/dist/components/Switch.js +0 -128
- package/dist/components/Toolbar.js +0 -227
- package/dist/components/Tooltip.js +0 -66
- package/dist/getTheme.js +0 -153
- package/dist/getThemeOverrides.js +0 -93
- package/dist/hocs/withAuthentication.js +0 -72
- package/dist/utils/styledPropFuncs.js +0 -88
- package/src/components/Button.js +0 -90
- package/src/components/Button.test.js +0 -49
- package/src/components/Checkbox.js +0 -63
- package/src/components/Checkbox.test.js +0 -122
- package/src/components/Icon.js +0 -18
- package/src/components/IconButton.js +0 -30
- package/src/components/IconButton.test.js +0 -61
- package/src/components/Input.js +0 -35
- package/src/components/Input.test.js +0 -34
- package/src/components/Modal/Background.js +0 -10
- package/src/components/Modal/Dialog.js +0 -27
- package/src/components/Modal/Dialog.test.js +0 -20
- package/src/components/Modal/Modal.test.js +0 -52
- package/src/components/Modal/Wrapper.js +0 -32
- package/src/components/Modal/Wrapper.test.js +0 -55
- package/src/components/Modal/index.js +0 -22
- package/src/components/MultiSelector.js +0 -104
- package/src/components/MultiSelector.test.js +0 -348
- package/src/components/Navigation/Bar.js +0 -212
- package/src/components/Navigation/Bar.test.js +0 -552
- package/src/components/Navigation/Tab.js +0 -156
- package/src/components/Navigation/Tab.test.js +0 -404
- package/src/components/Placeholder.js +0 -61
- package/src/components/Placeholder.test.js +0 -106
- package/src/components/Scope/Selector.js +0 -70
- package/src/components/Scope/Selector.test.js +0 -138
- package/src/components/Selector.js +0 -191
- package/src/components/Selector.test.js +0 -157
- package/src/components/Switch.js +0 -112
- package/src/components/Switch.test.js +0 -130
- package/src/components/Text.test.js +0 -132
- package/src/components/Toolbar.js +0 -178
- package/src/components/Toolbar.test.js +0 -478
- package/src/components/Tooltip.js +0 -51
- package/src/components/Tooltip.test.js +0 -21
- package/src/getTheme.js +0 -98
- package/src/getTheme.test.js +0 -92
- package/src/getThemeOverrides.js +0 -27
- package/src/hocs/withAuthentication.js +0 -18
- package/src/hocs/withAuthentication.test.js +0 -120
- package/src/utils/styledPropFuncs.js +0 -20
- package/src/utils/styledPropFuncs.test.js +0 -166
package/src/getTheme.test.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import getTheme from "./getTheme";
|
|
2
|
-
|
|
3
|
-
jest.mock("typeface-open-sans", () => ({}));
|
|
4
|
-
jest.mock("typeface-roboto-condensed", () => ({}));
|
|
5
|
-
|
|
6
|
-
describe("getTheme", () => {
|
|
7
|
-
it("gives a theme object containing colors, icon names", () =>
|
|
8
|
-
expect(getTheme, "called with", [], "to satisfy", {
|
|
9
|
-
colors: { error: "#ce4844" },
|
|
10
|
-
treeSettings: {},
|
|
11
|
-
icons: {},
|
|
12
|
-
fonts: {
|
|
13
|
-
base: "Open Sans, sans-serif",
|
|
14
|
-
header: "Roboto Condensed, sans-serif",
|
|
15
|
-
},
|
|
16
|
-
}));
|
|
17
|
-
|
|
18
|
-
it("has default app colors", () =>
|
|
19
|
-
expect(getTheme, "called with", [], "to satisfy", {
|
|
20
|
-
colors: {
|
|
21
|
-
application: {
|
|
22
|
-
base: "#cccccc",
|
|
23
|
-
primary: "#cccccc",
|
|
24
|
-
highlight: "#f7f7f7",
|
|
25
|
-
select: "#efefef",
|
|
26
|
-
dark: "#a3a3a3",
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
}));
|
|
30
|
-
|
|
31
|
-
it("creates app colors from base", () =>
|
|
32
|
-
expect(getTheme, "called with", [{ colors: { application: { base: "#cc33cc" } } }], "to satisfy", {
|
|
33
|
-
colors: {
|
|
34
|
-
application: {
|
|
35
|
-
base: "#cc33cc",
|
|
36
|
-
primary: "#cc33cc",
|
|
37
|
-
highlight: "#f7e2f7",
|
|
38
|
-
select: "#efc1ef",
|
|
39
|
-
dark: "#a328a3",
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
}));
|
|
43
|
-
|
|
44
|
-
it("accepts preset app colors", () =>
|
|
45
|
-
expect(
|
|
46
|
-
getTheme,
|
|
47
|
-
"called with",
|
|
48
|
-
[
|
|
49
|
-
{
|
|
50
|
-
colors: {
|
|
51
|
-
application: {
|
|
52
|
-
base: "#cc33cc",
|
|
53
|
-
primary: "#ff00ff",
|
|
54
|
-
highlight: "#6666d8",
|
|
55
|
-
select: "#efc1c1",
|
|
56
|
-
dark: "#a32828",
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
],
|
|
61
|
-
"to satisfy",
|
|
62
|
-
{
|
|
63
|
-
colors: {
|
|
64
|
-
application: {
|
|
65
|
-
base: "#cc33cc",
|
|
66
|
-
primary: "#ff00ff",
|
|
67
|
-
highlight: "#6666d8",
|
|
68
|
-
select: "#efc1c1",
|
|
69
|
-
dark: "#a32828",
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
));
|
|
74
|
-
|
|
75
|
-
it("handles overrides, including deep merges", () =>
|
|
76
|
-
expect(
|
|
77
|
-
getTheme,
|
|
78
|
-
"called with",
|
|
79
|
-
[{ colors: { error: "#FF00FF" }, fonts: { base: "serif", extra: "cursive" } }],
|
|
80
|
-
"to satisfy",
|
|
81
|
-
{
|
|
82
|
-
colors: { error: "#FF00FF" },
|
|
83
|
-
treeSettings: {},
|
|
84
|
-
icons: {},
|
|
85
|
-
fonts: {
|
|
86
|
-
base: "serif",
|
|
87
|
-
header: "Roboto Condensed, sans-serif",
|
|
88
|
-
extra: "cursive",
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
));
|
|
92
|
-
});
|
package/src/getThemeOverrides.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/* istanbul ignore file */
|
|
2
|
-
// Override values to use Orckestra icon sheet and colors
|
|
3
|
-
// See also orc-shared/src/getTheme.js#setApplicationColors()
|
|
4
|
-
const colors = {
|
|
5
|
-
orckestraBlue: "#00b2e2",
|
|
6
|
-
pim: { base: "#0a98cf", highlight: "#8ad5f2" },
|
|
7
|
-
oms: {
|
|
8
|
-
base: "#1f5b7f",
|
|
9
|
-
primary: "#b4cfe3",
|
|
10
|
-
highlight: "#b4cfe3",
|
|
11
|
-
select: "#b4cfe3",
|
|
12
|
-
},
|
|
13
|
-
marketing: { base: "#fd6b35", highlight: "#fd6b35" },
|
|
14
|
-
analytics: { base: "#ffa205", dark: "#cf8409", highlight: "#f1eae0" },
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const getThemeOverrides = appName => {
|
|
18
|
-
const application = colors[appName] || {
|
|
19
|
-
base: "#ff00ff", // Deliberately godawful default value
|
|
20
|
-
highlight: "#efefef",
|
|
21
|
-
};
|
|
22
|
-
return {
|
|
23
|
-
colors: { ...colors, application },
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export default getThemeOverrides;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { compose, branch, renderComponent, mapProps, withProps } from "recompose";
|
|
2
|
-
import { useAuthenticationData, Loader, Error } from "../components/Authenticate";
|
|
3
|
-
|
|
4
|
-
console.warn("Higher order component withAuthentication has been deprecated in favor of component Authenticate");
|
|
5
|
-
|
|
6
|
-
const isAuthenticated = withProps(useAuthenticationData);
|
|
7
|
-
|
|
8
|
-
const withAuthentication = compose(
|
|
9
|
-
isAuthenticated,
|
|
10
|
-
branch(({ loading }) => loading, renderComponent(Loader)),
|
|
11
|
-
branch(
|
|
12
|
-
({ authedUser }) => !authedUser,
|
|
13
|
-
renderComponent(Error),
|
|
14
|
-
mapProps(({ authedUser, loading, requestError, needLogin, ...props }) => props),
|
|
15
|
-
),
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
export default withAuthentication;
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import Immutable from "immutable";
|
|
3
|
-
import { Provider } from "react-redux";
|
|
4
|
-
import { ThemeProvider } from "styled-components";
|
|
5
|
-
import withAuthentication from "./withAuthentication";
|
|
6
|
-
import { Wrapper, Loader } from "../components/Authenticate";
|
|
7
|
-
import { ERROR, LOGOUT } from "../reducers/request";
|
|
8
|
-
import { GET_AUTHENTICATION_PROFILE } from "../actions/authentication";
|
|
9
|
-
|
|
10
|
-
const TestComp = () => {
|
|
11
|
-
return <div className="test"></div>;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
describe("withAuthentication", () => {
|
|
15
|
-
let state, store, AuthedComp;
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
state = Immutable.fromJS({
|
|
18
|
-
requests: {},
|
|
19
|
-
authentication: {
|
|
20
|
-
name: "foo@bar.com",
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
store = state => ({
|
|
24
|
-
subscribe: () => {},
|
|
25
|
-
getState: () => state,
|
|
26
|
-
dispatch: () => {},
|
|
27
|
-
});
|
|
28
|
-
AuthedComp = withAuthentication(TestComp);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("shows the wrapped component if authenticated", () =>
|
|
32
|
-
expect(
|
|
33
|
-
<Provider store={store(state)}>
|
|
34
|
-
<AuthedComp />
|
|
35
|
-
</Provider>,
|
|
36
|
-
"when mounted",
|
|
37
|
-
"to exhaustively satisfy",
|
|
38
|
-
<TestComp />,
|
|
39
|
-
));
|
|
40
|
-
|
|
41
|
-
it("shows a load indicator component if authentication is ongoing", () => {
|
|
42
|
-
state = state.setIn(["requests", "actives", GET_AUTHENTICATION_PROFILE], true);
|
|
43
|
-
return expect(
|
|
44
|
-
<Provider store={store(state)}>
|
|
45
|
-
<ThemeProvider theme={{}}>
|
|
46
|
-
<AuthedComp />
|
|
47
|
-
</ThemeProvider>
|
|
48
|
-
</Provider>,
|
|
49
|
-
"when mounted",
|
|
50
|
-
"to exhaustively satisfy",
|
|
51
|
-
<ThemeProvider theme={{}}>
|
|
52
|
-
<Loader />
|
|
53
|
-
</ThemeProvider>,
|
|
54
|
-
);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("shows an error screen if not logged in", () => {
|
|
58
|
-
state = state.deleteIn(["authentication", "name"]).setIn(["requests", LOGOUT], true);
|
|
59
|
-
return expect(
|
|
60
|
-
<Provider store={store(state)}>
|
|
61
|
-
<AuthedComp />
|
|
62
|
-
</Provider>,
|
|
63
|
-
"when mounted",
|
|
64
|
-
"to exhaustively satisfy",
|
|
65
|
-
<Wrapper>
|
|
66
|
-
<h1>Not logged in</h1>
|
|
67
|
-
</Wrapper>,
|
|
68
|
-
);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it("shows an error screen if an error occured", () => {
|
|
72
|
-
state = state.deleteIn(["authentication", "name"]).setIn(
|
|
73
|
-
["requests", ERROR],
|
|
74
|
-
Immutable.fromJS({
|
|
75
|
-
type: "TEST_ACTION",
|
|
76
|
-
payload: { status: 404, message: "404 - NotFound" },
|
|
77
|
-
}),
|
|
78
|
-
);
|
|
79
|
-
return expect(
|
|
80
|
-
<Provider store={store(state)}>
|
|
81
|
-
<AuthedComp />
|
|
82
|
-
</Provider>,
|
|
83
|
-
"when mounted",
|
|
84
|
-
"to exhaustively satisfy",
|
|
85
|
-
<Wrapper>
|
|
86
|
-
<h1>404 - NotFound</h1>
|
|
87
|
-
{"Last failing action: "}
|
|
88
|
-
<pre>
|
|
89
|
-
{"{\n" +
|
|
90
|
-
' "type": "TEST_ACTION",\n' +
|
|
91
|
-
' "payload": {\n' +
|
|
92
|
-
' "status": 404,\n' +
|
|
93
|
-
' "message": "404 - NotFound"\n' +
|
|
94
|
-
" }\n" +
|
|
95
|
-
"}"}
|
|
96
|
-
</pre>
|
|
97
|
-
</Wrapper>,
|
|
98
|
-
);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it("shows an error screen if an error without payload occured", () => {
|
|
102
|
-
state = state.deleteIn(["authentication", "name"]).setIn(
|
|
103
|
-
["requests", ERROR],
|
|
104
|
-
Immutable.fromJS({
|
|
105
|
-
type: "TEST_ACTION",
|
|
106
|
-
}),
|
|
107
|
-
);
|
|
108
|
-
return expect(
|
|
109
|
-
<Provider store={store(state)}>
|
|
110
|
-
<AuthedComp />
|
|
111
|
-
</Provider>,
|
|
112
|
-
"when mounted",
|
|
113
|
-
"to exhaustively satisfy",
|
|
114
|
-
<Wrapper>
|
|
115
|
-
<h1>An error occurred</h1>
|
|
116
|
-
Last failing action: <pre>{'{\n "type": "TEST_ACTION"\n}'}</pre>
|
|
117
|
-
</Wrapper>,
|
|
118
|
-
);
|
|
119
|
-
});
|
|
120
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import safeGet from "./safeGet";
|
|
2
|
-
|
|
3
|
-
const feedPropFunc = props => value => typeof value === "function" ? value(props) : value;
|
|
4
|
-
|
|
5
|
-
/* Safely gets a (potentially nested) theme property, can run a function on the resulting value */
|
|
6
|
-
export const getThemeProp =
|
|
7
|
-
(path, defaultValue, func = x => x) =>
|
|
8
|
-
props =>
|
|
9
|
-
func(safeGet(props, "theme", ...path.map(feedPropFunc(props))) || feedPropFunc(props)(defaultValue));
|
|
10
|
-
|
|
11
|
-
/* Use in styled components to check if a prop has a truthy value and
|
|
12
|
-
return values based on that. */
|
|
13
|
-
export const ifFlag =
|
|
14
|
-
(name, thenVal, elseVal = "") =>
|
|
15
|
-
props =>
|
|
16
|
-
props[name] ? feedPropFunc(props)(thenVal) : feedPropFunc(props)(elseVal);
|
|
17
|
-
|
|
18
|
-
/* Creates a prop function that checks a field against a list of cases,
|
|
19
|
-
and gives back a found case, or a default */
|
|
20
|
-
export const switchEnum = (enumField, cases) => props => cases[props[enumField]] || cases["default"];
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { getThemeProp, ifFlag, switchEnum } from "./styledPropFuncs";
|
|
2
|
-
|
|
3
|
-
describe("getThemeProp", () => {
|
|
4
|
-
let props;
|
|
5
|
-
beforeEach(() => {
|
|
6
|
-
props = {
|
|
7
|
-
theme: { hot: { potato: "ooh so tasty" } },
|
|
8
|
-
temp: "hot",
|
|
9
|
-
weird: "flavortown",
|
|
10
|
-
};
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it("returns a function that gets a value from the theme prop", () =>
|
|
14
|
-
expect(
|
|
15
|
-
getThemeProp,
|
|
16
|
-
"when called with",
|
|
17
|
-
[["hot", "potato"], "a mess"],
|
|
18
|
-
"when called with",
|
|
19
|
-
[props],
|
|
20
|
-
"to equal",
|
|
21
|
-
"ooh so tasty",
|
|
22
|
-
));
|
|
23
|
-
|
|
24
|
-
it("gets the default if theme prop not found", () =>
|
|
25
|
-
expect(
|
|
26
|
-
getThemeProp,
|
|
27
|
-
"when called with",
|
|
28
|
-
[["hot", "tomato"], "a mess"],
|
|
29
|
-
"when called with",
|
|
30
|
-
[props],
|
|
31
|
-
"to equal",
|
|
32
|
-
"a mess",
|
|
33
|
-
));
|
|
34
|
-
|
|
35
|
-
it("can use prop functions in the path", () =>
|
|
36
|
-
expect(
|
|
37
|
-
getThemeProp,
|
|
38
|
-
"when called with",
|
|
39
|
-
[[props => props.temp, "potato"], "a mess"],
|
|
40
|
-
"when called with",
|
|
41
|
-
[props],
|
|
42
|
-
"to equal",
|
|
43
|
-
"ooh so tasty",
|
|
44
|
-
));
|
|
45
|
-
|
|
46
|
-
it("can use prop functions in the default", () =>
|
|
47
|
-
expect(
|
|
48
|
-
getThemeProp,
|
|
49
|
-
"when called with",
|
|
50
|
-
[["hot", "tomato"], props => props.weird],
|
|
51
|
-
"when called with",
|
|
52
|
-
[props],
|
|
53
|
-
"to equal",
|
|
54
|
-
"flavortown",
|
|
55
|
-
));
|
|
56
|
-
|
|
57
|
-
describe("with function parameter", () => {
|
|
58
|
-
let func;
|
|
59
|
-
beforeEach(() => {
|
|
60
|
-
func = x => x.toUpperCase();
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("calls the passed function on the value from the theme prop", () =>
|
|
64
|
-
expect(
|
|
65
|
-
getThemeProp,
|
|
66
|
-
"when called with",
|
|
67
|
-
[["hot", "potato"], "a mess", func],
|
|
68
|
-
"when called with",
|
|
69
|
-
[props],
|
|
70
|
-
"to equal",
|
|
71
|
-
"OOH SO TASTY",
|
|
72
|
-
));
|
|
73
|
-
|
|
74
|
-
it("calls the passed function on the default if theme prop not found", () =>
|
|
75
|
-
expect(
|
|
76
|
-
getThemeProp,
|
|
77
|
-
"when called with",
|
|
78
|
-
[["hot", "tomato"], "a mess", func],
|
|
79
|
-
"when called with",
|
|
80
|
-
[props],
|
|
81
|
-
"to equal",
|
|
82
|
-
"A MESS",
|
|
83
|
-
));
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
describe("ifFlag", () => {
|
|
88
|
-
let props;
|
|
89
|
-
beforeEach(() => {
|
|
90
|
-
props = { yesFlag: true, noFlag: false, value: "this is it" };
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it("makes a prop function that returns second parameter if first parameter true", () =>
|
|
94
|
-
expect(
|
|
95
|
-
ifFlag,
|
|
96
|
-
"when called with",
|
|
97
|
-
["yesFlag", "no fooling", "not this"],
|
|
98
|
-
"when called with",
|
|
99
|
-
[props],
|
|
100
|
-
"to equal",
|
|
101
|
-
"no fooling",
|
|
102
|
-
));
|
|
103
|
-
|
|
104
|
-
it("makes a prop function that returns third parameter if first parameter false", () =>
|
|
105
|
-
expect(
|
|
106
|
-
ifFlag,
|
|
107
|
-
"when called with",
|
|
108
|
-
["noFlag", "no fooling", "not this"],
|
|
109
|
-
"when called with",
|
|
110
|
-
[props],
|
|
111
|
-
"to equal",
|
|
112
|
-
"not this",
|
|
113
|
-
));
|
|
114
|
-
|
|
115
|
-
it("returns empty string if no third parameter", () =>
|
|
116
|
-
expect(ifFlag, "when called with", ["noFlag", "no fooling"], "when called with", [props], "to equal", ""));
|
|
117
|
-
|
|
118
|
-
it("handles prop funcs as second parameter", () =>
|
|
119
|
-
expect(
|
|
120
|
-
ifFlag,
|
|
121
|
-
"when called with",
|
|
122
|
-
["yesFlag", props => props.value, "not this"],
|
|
123
|
-
"when called with",
|
|
124
|
-
[props],
|
|
125
|
-
"to equal",
|
|
126
|
-
"this is it",
|
|
127
|
-
));
|
|
128
|
-
|
|
129
|
-
it("handles prop funcs as third parameter", () =>
|
|
130
|
-
expect(
|
|
131
|
-
ifFlag,
|
|
132
|
-
"when called with",
|
|
133
|
-
["noFlag", "no fooling", props => props.value],
|
|
134
|
-
"when called with",
|
|
135
|
-
[props],
|
|
136
|
-
"to equal",
|
|
137
|
-
"this is it",
|
|
138
|
-
));
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
describe("switchEnum", () => {
|
|
142
|
-
let cases;
|
|
143
|
-
beforeEach(() => {
|
|
144
|
-
cases = { one: "One 111", two: "Two 222" };
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it("yields a property function which checks a field against a list of cases", () =>
|
|
148
|
-
expect(switchEnum, "when called with", ["enum", cases]).then(func =>
|
|
149
|
-
expect(func, "when called with", [{ enum: "one" }], "to equal", "One 111")
|
|
150
|
-
.and("when called with", [{ enum: "two" }], "to equal", "Two 222")
|
|
151
|
-
.and("when called with", [{ enum: "three" }], "to be undefined"),
|
|
152
|
-
));
|
|
153
|
-
|
|
154
|
-
it("yields a default if one is set", () => {
|
|
155
|
-
cases.default = "A default";
|
|
156
|
-
return expect(
|
|
157
|
-
switchEnum,
|
|
158
|
-
"when called with",
|
|
159
|
-
["enum", cases],
|
|
160
|
-
"when called with",
|
|
161
|
-
[{ enum: "three" }],
|
|
162
|
-
"to equal",
|
|
163
|
-
"A default",
|
|
164
|
-
);
|
|
165
|
-
});
|
|
166
|
-
});
|