@instructure/emotion 10.19.2-snapshot-2 → 10.19.2-snapshot-4
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/CHANGELOG.md +1 -1
- package/es/InstUISettingsProvider/__old-tests__/InstUISettingProvider.test.js +84 -0
- package/es/__old-tests__/getComponentThemeOverride.test.js +128 -0
- package/es/__old-tests__/useStyle.test.js +226 -0
- package/es/__old-tests__/useTheme.test.js +484 -0
- package/es/__old-tests__/withStyle.test.js +327 -0
- package/es/styleUtils/__old-tests__/getShorthandPropValue.test.js +85 -0
- package/es/{InstUISettingsProvider/__new-tests__/InstUISettingsProvider.test.js → styleUtils/__old-tests__/makeThemeVars.test.js} +19 -16
- package/es/styleUtils/__old-tests__/mirrorShorthand.test.js +66 -0
- package/lib/InstUISettingsProvider/__old-tests__/InstUISettingProvider.test.js +86 -0
- package/lib/__old-tests__/getComponentThemeOverride.test.js +131 -0
- package/lib/__old-tests__/useStyle.test.js +228 -0
- package/lib/__old-tests__/useTheme.test.js +488 -0
- package/lib/__old-tests__/withStyle.test.js +329 -0
- package/lib/styleUtils/__old-tests__/getShorthandPropValue.test.js +87 -0
- package/lib/{InstUISettingsProvider/__new-tests__/InstUISettingsProvider.test.js → styleUtils/__old-tests__/makeThemeVars.test.js} +19 -16
- package/lib/styleUtils/__old-tests__/mirrorShorthand.test.js +68 -0
- package/package.json +11 -11
- package/src/InstUISettingsProvider/__old-tests__/InstUISettingProvider.test.tsx +82 -0
- package/src/__old-tests__/getComponentThemeOverride.test.ts +182 -0
- package/src/__old-tests__/useStyle.test.tsx +272 -0
- package/src/__old-tests__/useTheme.test.tsx +510 -0
- package/src/__old-tests__/withStyle.test.tsx +389 -0
- package/src/styleUtils/__old-tests__/getShorthandPropValue.test.ts +96 -0
- package/src/{InstUISettingsProvider/__new-tests__/InstUISettingsProvider.test.tsx → styleUtils/__old-tests__/makeThemeVars.test.ts} +19 -14
- package/src/styleUtils/__old-tests__/mirrorShorthand.test.ts +77 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/InstUISettingsProvider/__old-tests__/InstUISettingProvider.test.d.ts +2 -0
- package/types/InstUISettingsProvider/__old-tests__/InstUISettingProvider.test.d.ts.map +1 -0
- package/types/__old-tests__/getComponentThemeOverride.test.d.ts +2 -0
- package/types/__old-tests__/getComponentThemeOverride.test.d.ts.map +1 -0
- package/types/__old-tests__/useStyle.test.d.ts +2 -0
- package/types/__old-tests__/useStyle.test.d.ts.map +1 -0
- package/types/__old-tests__/useTheme.test.d.ts +2 -0
- package/types/__old-tests__/useTheme.test.d.ts.map +1 -0
- package/types/__old-tests__/withStyle.test.d.ts +2 -0
- package/types/__old-tests__/withStyle.test.d.ts.map +1 -0
- package/types/styleUtils/__old-tests__/getShorthandPropValue.test.d.ts +2 -0
- package/types/styleUtils/__old-tests__/getShorthandPropValue.test.d.ts.map +1 -0
- package/types/styleUtils/__old-tests__/makeThemeVars.test.d.ts +2 -0
- package/types/styleUtils/__old-tests__/makeThemeVars.test.d.ts.map +1 -0
- package/types/styleUtils/__old-tests__/mirrorShorthand.test.d.ts +2 -0
- package/types/styleUtils/__old-tests__/mirrorShorthand.test.d.ts.map +1 -0
- package/types/InstUISettingsProvider/__new-tests__/InstUISettingsProvider.test.d.ts +0 -2
- package/types/InstUISettingsProvider/__new-tests__/InstUISettingsProvider.test.d.ts.map +0 -1
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _uiTestUtils = require("@instructure/ui-test-utils");
|
|
5
|
+
var _uiThemes = _interopRequireDefault(require("@instructure/ui-themes"));
|
|
6
|
+
var _getComponentThemeOverride = require("../getComponentThemeOverride");
|
|
7
|
+
/*
|
|
8
|
+
* The MIT License (MIT)
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
11
|
+
*
|
|
12
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
* in the Software without restriction, including without limitation the rights
|
|
15
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
* furnished to do so, subject to the following conditions:
|
|
18
|
+
*
|
|
19
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
* copies or substantial portions of the Software.
|
|
21
|
+
*
|
|
22
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
* SOFTWARE.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
const componentName = 'ExampleComponent';
|
|
32
|
+
const componentId = 'Example.Component';
|
|
33
|
+
describe('@getComponentThemeOverride', async () => {
|
|
34
|
+
describe('should return empty object', async () => {
|
|
35
|
+
it('if there is no theme set', async () => {
|
|
36
|
+
const override = (0, _getComponentThemeOverride.getComponentThemeOverride)({}, componentName, componentId, {});
|
|
37
|
+
(0, _uiTestUtils.expect)(override).to.deep.equal({});
|
|
38
|
+
});
|
|
39
|
+
it('if there is no override set', async () => {
|
|
40
|
+
const override = (0, _getComponentThemeOverride.getComponentThemeOverride)(_uiThemes.default, componentName, componentId, {});
|
|
41
|
+
(0, _uiTestUtils.expect)(override).to.deep.equal({});
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
describe('should return the correct override', async () => {
|
|
45
|
+
it('if there is `themeOverride` set on the props', async () => {
|
|
46
|
+
const componentOverride = {
|
|
47
|
+
componentColor: 'rgb(150, 0, 0)'
|
|
48
|
+
};
|
|
49
|
+
const override = (0, _getComponentThemeOverride.getComponentThemeOverride)(_uiThemes.default, componentName, componentId, {
|
|
50
|
+
themeOverride: componentOverride
|
|
51
|
+
});
|
|
52
|
+
(0, _uiTestUtils.expect)(override).to.deep.equal(componentOverride);
|
|
53
|
+
});
|
|
54
|
+
it('if the `themeOverride` prop is a function', async () => {
|
|
55
|
+
const theme = {
|
|
56
|
+
backgroundGreen: 'rgb(0, 150, 0)',
|
|
57
|
+
backgroundBlue: 'rgb(0, 0, 150)',
|
|
58
|
+
backgroundDark: 'rgb(0, 0, 0)'
|
|
59
|
+
};
|
|
60
|
+
const override = (0, _getComponentThemeOverride.getComponentThemeOverride)(_uiThemes.default, componentName, componentId, {
|
|
61
|
+
themeOverride: (componentTheme, currentTheme) => ({
|
|
62
|
+
backgroundBlue: componentTheme.backgroundGreen,
|
|
63
|
+
backgroundDark: currentTheme.colors.contrasts.white1010
|
|
64
|
+
})
|
|
65
|
+
}, theme);
|
|
66
|
+
(0, _uiTestUtils.expect)(override).to.deep.equal({
|
|
67
|
+
backgroundBlue: 'rgb(0, 150, 0)',
|
|
68
|
+
backgroundDark: '#FFFFFF'
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
it('if `themeOverride` and `componentOverrides` are both set', async () => {
|
|
72
|
+
const override = (0, _getComponentThemeOverride.getComponentThemeOverride)({
|
|
73
|
+
..._uiThemes.default,
|
|
74
|
+
componentOverrides: {
|
|
75
|
+
[componentName]: {
|
|
76
|
+
componentColor: 'rgb(0, 0, 150)'
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}, componentName, componentId, {
|
|
80
|
+
themeOverride: {
|
|
81
|
+
componentColor: 'rgb(0, 150, 0)'
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
(0, _uiTestUtils.expect)(override).to.deep.equal({
|
|
85
|
+
componentColor: 'rgb(0, 150, 0)'
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
describe('if there is `componentOverrides` set on the theme', async () => {
|
|
89
|
+
it('with the displayName', async () => {
|
|
90
|
+
const componentOverride = {
|
|
91
|
+
componentColor: 'rgb(0, 0, 150)'
|
|
92
|
+
};
|
|
93
|
+
const override = (0, _getComponentThemeOverride.getComponentThemeOverride)({
|
|
94
|
+
..._uiThemes.default,
|
|
95
|
+
componentOverrides: {
|
|
96
|
+
[componentName]: componentOverride
|
|
97
|
+
}
|
|
98
|
+
}, componentName, componentId, {});
|
|
99
|
+
(0, _uiTestUtils.expect)(override).to.deep.equal(componentOverride);
|
|
100
|
+
});
|
|
101
|
+
it('with the componentId', async () => {
|
|
102
|
+
const componentOverride = {
|
|
103
|
+
componentColor: 'rgb(0, 150, 150)'
|
|
104
|
+
};
|
|
105
|
+
const override = (0, _getComponentThemeOverride.getComponentThemeOverride)({
|
|
106
|
+
..._uiThemes.default,
|
|
107
|
+
componentOverrides: {
|
|
108
|
+
[componentId]: componentOverride
|
|
109
|
+
}
|
|
110
|
+
}, componentName, componentId, {});
|
|
111
|
+
(0, _uiTestUtils.expect)(override).to.deep.equal(componentOverride);
|
|
112
|
+
});
|
|
113
|
+
it('with both the displayName and componentId (displayName takes precedence)', async () => {
|
|
114
|
+
const override = (0, _getComponentThemeOverride.getComponentThemeOverride)({
|
|
115
|
+
..._uiThemes.default,
|
|
116
|
+
componentOverrides: {
|
|
117
|
+
[componentName]: {
|
|
118
|
+
componentColor: 'rgb(150, 150, 150)'
|
|
119
|
+
},
|
|
120
|
+
[componentId]: {
|
|
121
|
+
componentColor: 'rgb(150, 150, 0)'
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}, componentName, componentId, {});
|
|
125
|
+
(0, _uiTestUtils.expect)(override).to.deep.equal({
|
|
126
|
+
componentColor: 'rgb(150, 150, 150)'
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
});
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
5
|
+
var _react = require("react");
|
|
6
|
+
var _uiTestUtils = require("@instructure/ui-test-utils");
|
|
7
|
+
var _index = require("../index");
|
|
8
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
9
|
+
var _p;
|
|
10
|
+
/*
|
|
11
|
+
* The MIT License (MIT)
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
14
|
+
*
|
|
15
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
17
|
+
* in the Software without restriction, including without limitation the rights
|
|
18
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
20
|
+
* furnished to do so, subject to the following conditions:
|
|
21
|
+
*
|
|
22
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
23
|
+
* copies or substantial portions of the Software.
|
|
24
|
+
*
|
|
25
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
+
* SOFTWARE.
|
|
32
|
+
*/
|
|
33
|
+
describe('useStyle', async () => {
|
|
34
|
+
var _InstUISettingsProvid, _InstUISettingsProvid2, _InstUISettingsProvid3, _InstUISettingsProvid4, _InstUISettingsProvid5;
|
|
35
|
+
const grey1111 = 'rgb(0, 128, 0)';
|
|
36
|
+
const green4570 = 'rgb(10, 10, 10)';
|
|
37
|
+
const blue4570 = 'rgb(255, 255, 0)';
|
|
38
|
+
const exampleTheme = {
|
|
39
|
+
key: 'exampleTheme',
|
|
40
|
+
colors: {
|
|
41
|
+
contrasts: {
|
|
42
|
+
grey1111,
|
|
43
|
+
green4570,
|
|
44
|
+
blue4570
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const generateComponentTheme = function (theme) {
|
|
49
|
+
const colors = theme.colors;
|
|
50
|
+
return {
|
|
51
|
+
textColor: colors.contrasts.grey1111,
|
|
52
|
+
textColorInverse: colors.contrasts.green4570,
|
|
53
|
+
backgroundColor: colors.contrasts.blue4570
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
const generateStyle = function (componentTheme, params) {
|
|
57
|
+
const inverse = params.inverse,
|
|
58
|
+
clearBackground = params.clearBackground;
|
|
59
|
+
return {
|
|
60
|
+
exampleComponent: {
|
|
61
|
+
label: 'exampleComponent',
|
|
62
|
+
color: componentTheme.textColor,
|
|
63
|
+
background: componentTheme.backgroundColor,
|
|
64
|
+
insetInlineStart: '8px',
|
|
65
|
+
...(inverse && {
|
|
66
|
+
color: componentTheme.textColorInverse
|
|
67
|
+
}),
|
|
68
|
+
...(clearBackground && {
|
|
69
|
+
background: 'transparent'
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
const ThemedComponent = ({
|
|
75
|
+
inverse = false,
|
|
76
|
+
themeOverride
|
|
77
|
+
}) => {
|
|
78
|
+
const _useState = (0, _react.useState)(false),
|
|
79
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
80
|
+
clearBackground = _useState2[0],
|
|
81
|
+
setClearBackground = _useState2[1];
|
|
82
|
+
const styles = (0, _index.useStyle)({
|
|
83
|
+
generateStyle,
|
|
84
|
+
generateComponentTheme,
|
|
85
|
+
componentId: 'ThemedComponent',
|
|
86
|
+
params: {
|
|
87
|
+
inverse,
|
|
88
|
+
clearBackground,
|
|
89
|
+
themeOverride
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
const handleClick = () => {
|
|
93
|
+
setClearBackground(true);
|
|
94
|
+
};
|
|
95
|
+
return (0, _jsxRuntime.jsxs)("div", {
|
|
96
|
+
css: styles.exampleComponent,
|
|
97
|
+
children: [_p || (_p = (0, _jsxRuntime.jsx)("p", {
|
|
98
|
+
children: "Hello World"
|
|
99
|
+
})), (0, _jsxRuntime.jsx)("button", {
|
|
100
|
+
onClick: handleClick,
|
|
101
|
+
children: "Button"
|
|
102
|
+
})]
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
describe('with theme provided by InstUISettingsProvider', async () => {
|
|
106
|
+
it('should add css class suffixed with label', async () => {
|
|
107
|
+
const subject = await (0, _uiTestUtils.mount)(_InstUISettingsProvid || (_InstUISettingsProvid = (0, _jsxRuntime.jsx)(_index.InstUISettingsProvider, {
|
|
108
|
+
theme: exampleTheme,
|
|
109
|
+
children: (0, _jsxRuntime.jsx)(ThemedComponent, {})
|
|
110
|
+
})));
|
|
111
|
+
const emotionClassRegex = new RegExp(/^css-.+-exampleComponent$/);
|
|
112
|
+
(0, _uiTestUtils.expect)(subject.getDOMNode().classList[0]).to.match(emotionClassRegex);
|
|
113
|
+
});
|
|
114
|
+
it('should apply correct css props', async () => {
|
|
115
|
+
const subject = await (0, _uiTestUtils.mount)(_InstUISettingsProvid2 || (_InstUISettingsProvid2 = (0, _jsxRuntime.jsx)(_index.InstUISettingsProvider, {
|
|
116
|
+
theme: exampleTheme,
|
|
117
|
+
children: (0, _jsxRuntime.jsx)(ThemedComponent, {})
|
|
118
|
+
})));
|
|
119
|
+
const component = subject.getDOMNode();
|
|
120
|
+
const computedStyle = getComputedStyle(component);
|
|
121
|
+
(0, _uiTestUtils.expect)(computedStyle.color).to.equal('rgb(0, 128, 0)');
|
|
122
|
+
(0, _uiTestUtils.expect)(computedStyle.backgroundColor).to.equal('rgb(255, 255, 0)');
|
|
123
|
+
});
|
|
124
|
+
describe('should allow configuration through the themeOverride prop', async () => {
|
|
125
|
+
it('when it is an object', async () => {
|
|
126
|
+
const subject = await (0, _uiTestUtils.mount)((0, _jsxRuntime.jsx)(_index.InstUISettingsProvider, {
|
|
127
|
+
theme: exampleTheme,
|
|
128
|
+
children: (0, _jsxRuntime.jsx)(ThemedComponent, {
|
|
129
|
+
themeOverride: {
|
|
130
|
+
textColor: 'rgb(128, 0, 128)'
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
}));
|
|
134
|
+
const component = subject.getDOMNode();
|
|
135
|
+
const computedStyle = getComputedStyle(component);
|
|
136
|
+
(0, _uiTestUtils.expect)(computedStyle.color).to.equal('rgb(128, 0, 128)');
|
|
137
|
+
(0, _uiTestUtils.expect)(computedStyle.backgroundColor).to.equal('rgb(255, 255, 0)');
|
|
138
|
+
});
|
|
139
|
+
it('when it is a function', async () => {
|
|
140
|
+
const subject = await (0, _uiTestUtils.mount)((0, _jsxRuntime.jsx)(_index.InstUISettingsProvider, {
|
|
141
|
+
theme: exampleTheme,
|
|
142
|
+
children: (0, _jsxRuntime.jsx)(ThemedComponent, {
|
|
143
|
+
themeOverride: componentTheme => ({
|
|
144
|
+
textColor: componentTheme.backgroundColor
|
|
145
|
+
})
|
|
146
|
+
})
|
|
147
|
+
}));
|
|
148
|
+
const component = subject.getDOMNode();
|
|
149
|
+
const computedStyle = getComputedStyle(component);
|
|
150
|
+
(0, _uiTestUtils.expect)(computedStyle.color).to.equal('rgb(255, 255, 0)');
|
|
151
|
+
(0, _uiTestUtils.expect)(computedStyle.backgroundColor).to.equal('rgb(255, 255, 0)');
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
it('should ignore empty themeOverride props', async () => {
|
|
155
|
+
const subject = await (0, _uiTestUtils.mount)((0, _jsxRuntime.jsx)(_index.InstUISettingsProvider, {
|
|
156
|
+
theme: exampleTheme,
|
|
157
|
+
children: (0, _jsxRuntime.jsx)(ThemedComponent, {
|
|
158
|
+
themeOverride: {}
|
|
159
|
+
})
|
|
160
|
+
}));
|
|
161
|
+
const component = subject.getDOMNode();
|
|
162
|
+
const computedStyle = getComputedStyle(component);
|
|
163
|
+
(0, _uiTestUtils.expect)(computedStyle.color).to.equal('rgb(0, 128, 0)');
|
|
164
|
+
(0, _uiTestUtils.expect)(computedStyle.backgroundColor).to.equal('rgb(255, 255, 0)');
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
describe('should update css props', async () => {
|
|
168
|
+
it('when props are updated', async () => {
|
|
169
|
+
// `setProps` can be called on the outer component,
|
|
170
|
+
// so have to add the theme ad themeOverride here, and suppress the error
|
|
171
|
+
(0, _uiTestUtils.stub)(console, 'warn'); // suppress "no theme provided error"
|
|
172
|
+
|
|
173
|
+
const subject = await (0, _uiTestUtils.mount)((0, _jsxRuntime.jsx)(ThemedComponent, {
|
|
174
|
+
inverse: false,
|
|
175
|
+
themeOverride: {
|
|
176
|
+
textColor: grey1111,
|
|
177
|
+
textColorInverse: blue4570,
|
|
178
|
+
backgroundColor: green4570
|
|
179
|
+
}
|
|
180
|
+
}));
|
|
181
|
+
const component = subject.getDOMNode();
|
|
182
|
+
(0, _uiTestUtils.expect)(getComputedStyle(component).color).to.equal(grey1111);
|
|
183
|
+
await subject.setProps({
|
|
184
|
+
inverse: true
|
|
185
|
+
});
|
|
186
|
+
(0, _uiTestUtils.expect)(getComputedStyle(component).color).to.equal(blue4570);
|
|
187
|
+
});
|
|
188
|
+
it('when state is updated', async () => {
|
|
189
|
+
const subject = await (0, _uiTestUtils.mount)(_InstUISettingsProvid3 || (_InstUISettingsProvid3 = (0, _jsxRuntime.jsx)(_index.InstUISettingsProvider, {
|
|
190
|
+
theme: exampleTheme,
|
|
191
|
+
children: (0, _jsxRuntime.jsx)(ThemedComponent, {})
|
|
192
|
+
})));
|
|
193
|
+
const main = (0, _uiTestUtils.within)(subject.getDOMNode());
|
|
194
|
+
const clearBackgroundButton = await main.find('button');
|
|
195
|
+
const component = main.getDOMNode();
|
|
196
|
+
(0, _uiTestUtils.expect)(getComputedStyle(component).backgroundColor).to.equal('rgb(255, 255, 0)');
|
|
197
|
+
await clearBackgroundButton.click();
|
|
198
|
+
(0, _uiTestUtils.expect)(getComputedStyle(component).backgroundColor).to.equal('rgba(0, 0, 0, 0)');
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
describe('should apply bi-directional polyfill on styles object', async () => {
|
|
202
|
+
it('in default "ltr" mode', async () => {
|
|
203
|
+
const subject = await (0, _uiTestUtils.mount)(_InstUISettingsProvid4 || (_InstUISettingsProvid4 = (0, _jsxRuntime.jsx)(_index.InstUISettingsProvider, {
|
|
204
|
+
theme: exampleTheme,
|
|
205
|
+
children: (0, _jsxRuntime.jsx)(ThemedComponent, {})
|
|
206
|
+
})));
|
|
207
|
+
const component = subject.getDOMNode();
|
|
208
|
+
const computedStyle = getComputedStyle(component);
|
|
209
|
+
|
|
210
|
+
// `inset-inline-start` should be transformed to 'left' in 'ltr' mode
|
|
211
|
+
(0, _uiTestUtils.expect)(computedStyle.left).to.equal('8px');
|
|
212
|
+
(0, _uiTestUtils.expect)(computedStyle.right).to.equal('auto');
|
|
213
|
+
});
|
|
214
|
+
it('in "rtl" mode', async () => {
|
|
215
|
+
const subject = await (0, _uiTestUtils.mount)(_InstUISettingsProvid5 || (_InstUISettingsProvid5 = (0, _jsxRuntime.jsx)(_index.InstUISettingsProvider, {
|
|
216
|
+
theme: exampleTheme,
|
|
217
|
+
dir: "rtl",
|
|
218
|
+
children: (0, _jsxRuntime.jsx)(ThemedComponent, {})
|
|
219
|
+
})));
|
|
220
|
+
const component = subject.getDOMNode().firstElementChild;
|
|
221
|
+
const computedStyle = getComputedStyle(component);
|
|
222
|
+
|
|
223
|
+
// `inset-inline-start` should be transformed to 'right' in 'rtl' mode
|
|
224
|
+
(0, _uiTestUtils.expect)(computedStyle.left).to.equal('auto');
|
|
225
|
+
(0, _uiTestUtils.expect)(computedStyle.right).to.equal('8px');
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
});
|