@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,488 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
5
|
+
var _canvas = require("@instructure/ui-themes/lib/themes/canvas");
|
|
6
|
+
var _canvasHighContrast = require("@instructure/ui-themes/lib/themes/canvasHighContrast");
|
|
7
|
+
var _uiTestUtils = require("@instructure/ui-test-utils");
|
|
8
|
+
var _themeRegistry = require("@instructure/theme-registry");
|
|
9
|
+
var _useTheme = require("../useTheme");
|
|
10
|
+
var _InstUISettingsProvider = require("../InstUISettingsProvider");
|
|
11
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
12
|
+
/*
|
|
13
|
+
* The MIT License (MIT)
|
|
14
|
+
*
|
|
15
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
16
|
+
*
|
|
17
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
18
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
19
|
+
* in the Software without restriction, including without limitation the rights
|
|
20
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
21
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
22
|
+
* furnished to do so, subject to the following conditions:
|
|
23
|
+
*
|
|
24
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
25
|
+
* copies or substantial portions of the Software.
|
|
26
|
+
*
|
|
27
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
28
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
29
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
30
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
31
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
32
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
|
+
* SOFTWARE.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
const defaultRegistry = _themeRegistry.ThemeRegistry.getRegistry();
|
|
37
|
+
const ExampleComponent = props => {
|
|
38
|
+
const theme = (0, _useTheme.useTheme)();
|
|
39
|
+
props.callback(theme);
|
|
40
|
+
return null;
|
|
41
|
+
};
|
|
42
|
+
describe('useTheme hook', () => {
|
|
43
|
+
beforeEach(() => {
|
|
44
|
+
_themeRegistry.ThemeRegistry.clearRegistry();
|
|
45
|
+
});
|
|
46
|
+
afterEach(() => {
|
|
47
|
+
//this is needed to not mess up the global Theme Registry
|
|
48
|
+
_themeRegistry.ThemeRegistry.setRegistry(defaultRegistry);
|
|
49
|
+
});
|
|
50
|
+
describe('with using InstUISettingsProvider', () => {
|
|
51
|
+
it('should use default canvas theme when no "theme" is provided', async () => {
|
|
52
|
+
const callback = (0, _uiTestUtils.spy)();
|
|
53
|
+
await (0, _uiTestUtils.mount)((0, _jsxRuntime.jsx)(_InstUISettingsProvider.InstUISettingsProvider, {
|
|
54
|
+
children: (0, _jsxRuntime.jsx)(ExampleComponent, {
|
|
55
|
+
callback: callback
|
|
56
|
+
})
|
|
57
|
+
}));
|
|
58
|
+
(0, _uiTestUtils.expect)(callback).to.have.been.calledWith(_canvas.canvas);
|
|
59
|
+
});
|
|
60
|
+
it('should use global theme when no "theme" is provided', async () => {
|
|
61
|
+
const callback = (0, _uiTestUtils.spy)();
|
|
62
|
+
const theme = _themeRegistry.ThemeRegistry.registerTheme(_canvasHighContrast.canvasHighContrast);
|
|
63
|
+
theme.use();
|
|
64
|
+
await (0, _uiTestUtils.mount)((0, _jsxRuntime.jsx)(_InstUISettingsProvider.InstUISettingsProvider, {
|
|
65
|
+
children: (0, _jsxRuntime.jsx)(ExampleComponent, {
|
|
66
|
+
callback: callback
|
|
67
|
+
})
|
|
68
|
+
}));
|
|
69
|
+
(0, _uiTestUtils.expect)(callback).to.have.been.calledWith(theme);
|
|
70
|
+
});
|
|
71
|
+
it('should default to canvas theme when no global theme is available and no theme is provided', async () => {
|
|
72
|
+
const callback = (0, _uiTestUtils.spy)();
|
|
73
|
+
await (0, _uiTestUtils.mount)((0, _jsxRuntime.jsx)(_InstUISettingsProvider.InstUISettingsProvider, {
|
|
74
|
+
children: (0, _jsxRuntime.jsx)(ExampleComponent, {
|
|
75
|
+
callback: callback
|
|
76
|
+
})
|
|
77
|
+
}));
|
|
78
|
+
(0, _uiTestUtils.expect)(callback).to.have.been.calledWith(_canvas.canvas);
|
|
79
|
+
});
|
|
80
|
+
it('should use provided theme when theme is provided', async () => {
|
|
81
|
+
const callback = (0, _uiTestUtils.spy)();
|
|
82
|
+
const theme = _themeRegistry.ThemeRegistry.registerTheme(_canvas.canvas);
|
|
83
|
+
theme.use();
|
|
84
|
+
await (0, _uiTestUtils.mount)((0, _jsxRuntime.jsx)(_InstUISettingsProvider.InstUISettingsProvider, {
|
|
85
|
+
theme: _canvasHighContrast.canvasHighContrast,
|
|
86
|
+
children: (0, _jsxRuntime.jsx)(ExampleComponent, {
|
|
87
|
+
callback: callback
|
|
88
|
+
})
|
|
89
|
+
}));
|
|
90
|
+
(0, _uiTestUtils.expect)(callback).to.have.been.calledWith(_canvasHighContrast.canvasHighContrast);
|
|
91
|
+
});
|
|
92
|
+
it('should override the default theme when no other theme is available', async () => {
|
|
93
|
+
const callback = (0, _uiTestUtils.spy)();
|
|
94
|
+
await (0, _uiTestUtils.mount)((0, _jsxRuntime.jsx)(_InstUISettingsProvider.InstUISettingsProvider, {
|
|
95
|
+
theme: {
|
|
96
|
+
colors: {
|
|
97
|
+
primitives: {
|
|
98
|
+
white: 'red'
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
children: (0, _jsxRuntime.jsx)(ExampleComponent, {
|
|
103
|
+
callback: callback
|
|
104
|
+
})
|
|
105
|
+
}));
|
|
106
|
+
(0, _uiTestUtils.expect)(callback).to.have.been.calledWithMatch({
|
|
107
|
+
..._canvas.canvas,
|
|
108
|
+
colors: {
|
|
109
|
+
primitives: {
|
|
110
|
+
white: 'red'
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
it('should override the global theme if that is the only theme available', async () => {
|
|
116
|
+
const callback = (0, _uiTestUtils.spy)();
|
|
117
|
+
const theme = _themeRegistry.ThemeRegistry.registerTheme(_canvasHighContrast.canvasHighContrast);
|
|
118
|
+
theme.use();
|
|
119
|
+
await (0, _uiTestUtils.mount)((0, _jsxRuntime.jsx)(_InstUISettingsProvider.InstUISettingsProvider, {
|
|
120
|
+
theme: {
|
|
121
|
+
colors: {
|
|
122
|
+
primitives: {
|
|
123
|
+
white: 'red'
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
children: (0, _jsxRuntime.jsx)(ExampleComponent, {
|
|
128
|
+
callback: callback
|
|
129
|
+
})
|
|
130
|
+
}));
|
|
131
|
+
(0, _uiTestUtils.expect)(callback).to.have.been.calledWithMatch({
|
|
132
|
+
...theme,
|
|
133
|
+
colors: {
|
|
134
|
+
primitives: {
|
|
135
|
+
white: 'red'
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
it('should override the global theme with the "themeOverrides" option if that is the only theme available', async () => {
|
|
141
|
+
const callback = (0, _uiTestUtils.spy)();
|
|
142
|
+
const theme = _themeRegistry.ThemeRegistry.registerTheme(_canvasHighContrast.canvasHighContrast);
|
|
143
|
+
theme.use();
|
|
144
|
+
await (0, _uiTestUtils.mount)((0, _jsxRuntime.jsx)(_InstUISettingsProvider.InstUISettingsProvider, {
|
|
145
|
+
theme: {
|
|
146
|
+
themeOverrides: {
|
|
147
|
+
colors: {
|
|
148
|
+
primitives: {
|
|
149
|
+
white: 'red'
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
children: (0, _jsxRuntime.jsx)(ExampleComponent, {
|
|
155
|
+
callback: callback
|
|
156
|
+
})
|
|
157
|
+
}));
|
|
158
|
+
(0, _uiTestUtils.expect)(callback).to.have.been.calledWithMatch({
|
|
159
|
+
...theme,
|
|
160
|
+
colors: {
|
|
161
|
+
primitives: {
|
|
162
|
+
white: 'red'
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
it('should override the theme from context when provided', async () => {
|
|
168
|
+
const callback = (0, _uiTestUtils.spy)();
|
|
169
|
+
const theme = _themeRegistry.ThemeRegistry.registerTheme(_canvasHighContrast.canvasHighContrast);
|
|
170
|
+
theme.use();
|
|
171
|
+
await (0, _uiTestUtils.mount)((0, _jsxRuntime.jsx)(_InstUISettingsProvider.InstUISettingsProvider, {
|
|
172
|
+
theme: _canvasHighContrast.canvasHighContrast,
|
|
173
|
+
children: (0, _jsxRuntime.jsx)(_InstUISettingsProvider.InstUISettingsProvider, {
|
|
174
|
+
theme: {
|
|
175
|
+
themeOverrides: {
|
|
176
|
+
colors: {
|
|
177
|
+
primitives: {
|
|
178
|
+
white: 'red'
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
children: (0, _jsxRuntime.jsx)(ExampleComponent, {
|
|
184
|
+
callback: callback
|
|
185
|
+
})
|
|
186
|
+
})
|
|
187
|
+
}));
|
|
188
|
+
(0, _uiTestUtils.expect)(callback).to.have.been.calledWithMatch({
|
|
189
|
+
..._canvasHighContrast.canvasHighContrast,
|
|
190
|
+
colors: {
|
|
191
|
+
primitives: {
|
|
192
|
+
white: 'red'
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
it('should use local themes correctly', async () => {
|
|
198
|
+
const callback = (0, _uiTestUtils.spy)();
|
|
199
|
+
const theme = _themeRegistry.ThemeRegistry.registerTheme(_canvas.canvas);
|
|
200
|
+
theme.use();
|
|
201
|
+
await (0, _uiTestUtils.mount)((0, _jsxRuntime.jsx)(_InstUISettingsProvider.InstUISettingsProvider, {
|
|
202
|
+
theme: canvasThemeLocal,
|
|
203
|
+
children: (0, _jsxRuntime.jsx)(_InstUISettingsProvider.InstUISettingsProvider, {
|
|
204
|
+
theme: {
|
|
205
|
+
themeOverrides: {
|
|
206
|
+
colors: {
|
|
207
|
+
primitives: {
|
|
208
|
+
white: 'red'
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
children: (0, _jsxRuntime.jsx)(ExampleComponent, {
|
|
214
|
+
callback: callback
|
|
215
|
+
})
|
|
216
|
+
})
|
|
217
|
+
}));
|
|
218
|
+
(0, _uiTestUtils.expect)(callback).to.have.been.calledWithMatch({
|
|
219
|
+
...canvasThemeLocal,
|
|
220
|
+
colors: {
|
|
221
|
+
primitives: {
|
|
222
|
+
white: 'red'
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
describe('without using InstUISettingsProvider', () => {
|
|
229
|
+
it('should use theme from global ThemeRegistry', async () => {
|
|
230
|
+
const callback = (0, _uiTestUtils.spy)();
|
|
231
|
+
const theme = _themeRegistry.ThemeRegistry.registerTheme(_canvasHighContrast.canvasHighContrast);
|
|
232
|
+
theme.use();
|
|
233
|
+
await (0, _uiTestUtils.mount)((0, _jsxRuntime.jsx)(ExampleComponent, {
|
|
234
|
+
callback: callback
|
|
235
|
+
}));
|
|
236
|
+
(0, _uiTestUtils.expect)(callback).to.have.been.calledWith(theme);
|
|
237
|
+
});
|
|
238
|
+
it('should use default "canvas" theme when no theme is used from ThemeRegistry', async () => {
|
|
239
|
+
const callback = (0, _uiTestUtils.spy)();
|
|
240
|
+
await (0, _uiTestUtils.mount)((0, _jsxRuntime.jsx)(ExampleComponent, {
|
|
241
|
+
callback: callback
|
|
242
|
+
}));
|
|
243
|
+
(0, _uiTestUtils.expect)(callback).to.have.been.calledWith(_canvas.canvas);
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
describe('with InstUISettingsProvider and global theme', () => {
|
|
247
|
+
it('overrides should work correctly', async () => {
|
|
248
|
+
const _Array$fill$map = Array(6).fill(0).map(() => (0, _uiTestUtils.spy)()),
|
|
249
|
+
_Array$fill$map2 = (0, _slicedToArray2.default)(_Array$fill$map, 6),
|
|
250
|
+
cb1 = _Array$fill$map2[0],
|
|
251
|
+
cb2 = _Array$fill$map2[1],
|
|
252
|
+
cb3 = _Array$fill$map2[2],
|
|
253
|
+
cb4 = _Array$fill$map2[3],
|
|
254
|
+
cb5 = _Array$fill$map2[4],
|
|
255
|
+
cb6 = _Array$fill$map2[5];
|
|
256
|
+
const theme = _themeRegistry.ThemeRegistry.registerTheme(_canvasHighContrast.canvasHighContrast);
|
|
257
|
+
theme.use({
|
|
258
|
+
overrides: {
|
|
259
|
+
colors: {
|
|
260
|
+
primitives: {
|
|
261
|
+
red12: 'red',
|
|
262
|
+
green12: 'yellow',
|
|
263
|
+
blue12: 'magenta'
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
await (0, _uiTestUtils.mount)((0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
269
|
+
children: [(0, _jsxRuntime.jsx)(ExampleComponent, {
|
|
270
|
+
callback: cb1
|
|
271
|
+
}), (0, _jsxRuntime.jsxs)(_InstUISettingsProvider.InstUISettingsProvider, {
|
|
272
|
+
theme: _canvasHighContrast.canvasHighContrast,
|
|
273
|
+
children: [(0, _jsxRuntime.jsx)(ExampleComponent, {
|
|
274
|
+
callback: cb2
|
|
275
|
+
}), (0, _jsxRuntime.jsxs)(_InstUISettingsProvider.InstUISettingsProvider, {
|
|
276
|
+
theme: _canvas.canvas,
|
|
277
|
+
children: [(0, _jsxRuntime.jsx)(ExampleComponent, {
|
|
278
|
+
callback: cb3
|
|
279
|
+
}), (0, _jsxRuntime.jsx)(_InstUISettingsProvider.InstUISettingsProvider, {
|
|
280
|
+
theme: {
|
|
281
|
+
colors: {
|
|
282
|
+
primitives: {
|
|
283
|
+
red12: 'orange'
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
themeOverrides: {
|
|
287
|
+
colors: {
|
|
288
|
+
primitives: {
|
|
289
|
+
green12: 'olive'
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
children: (0, _jsxRuntime.jsx)(ExampleComponent, {
|
|
295
|
+
callback: cb4
|
|
296
|
+
})
|
|
297
|
+
})]
|
|
298
|
+
})]
|
|
299
|
+
}), (0, _jsxRuntime.jsxs)(_InstUISettingsProvider.InstUISettingsProvider, {
|
|
300
|
+
children: [(0, _jsxRuntime.jsx)(ExampleComponent, {
|
|
301
|
+
callback: cb5
|
|
302
|
+
}), (0, _jsxRuntime.jsx)(_InstUISettingsProvider.InstUISettingsProvider, {
|
|
303
|
+
theme: {
|
|
304
|
+
colors: {
|
|
305
|
+
primitives: {
|
|
306
|
+
red12: 'brown'
|
|
307
|
+
}
|
|
308
|
+
},
|
|
309
|
+
themeOverrides: {
|
|
310
|
+
colors: {
|
|
311
|
+
primitives: {
|
|
312
|
+
green12: 'pink'
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
children: (0, _jsxRuntime.jsx)(ExampleComponent, {
|
|
318
|
+
callback: cb6
|
|
319
|
+
})
|
|
320
|
+
})]
|
|
321
|
+
})]
|
|
322
|
+
}));
|
|
323
|
+
(0, _uiTestUtils.expect)(cb1).to.have.been.calledWithMatch({
|
|
324
|
+
...theme,
|
|
325
|
+
colors: {
|
|
326
|
+
primitives: {
|
|
327
|
+
red12: 'red',
|
|
328
|
+
green12: 'yellow',
|
|
329
|
+
blue12: 'magenta'
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
(0, _uiTestUtils.expect)(cb2).to.have.been.calledWith(_canvasHighContrast.canvasHighContrast);
|
|
334
|
+
(0, _uiTestUtils.expect)(cb3).to.have.been.calledWith(_canvas.canvas);
|
|
335
|
+
(0, _uiTestUtils.expect)(cb4).to.have.been.calledWithMatch({
|
|
336
|
+
..._canvas.canvas,
|
|
337
|
+
colors: {
|
|
338
|
+
primitives: {
|
|
339
|
+
red12: 'orange',
|
|
340
|
+
green12: 'olive'
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
(0, _uiTestUtils.expect)(cb5).to.have.been.calledWithMatch({
|
|
345
|
+
...theme,
|
|
346
|
+
colors: {
|
|
347
|
+
primitives: {
|
|
348
|
+
red12: 'red',
|
|
349
|
+
green12: 'yellow',
|
|
350
|
+
blue12: 'magenta'
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
(0, _uiTestUtils.expect)(cb6).to.have.been.calledWithMatch({
|
|
355
|
+
...theme,
|
|
356
|
+
colors: {
|
|
357
|
+
primitives: {
|
|
358
|
+
red12: 'brown',
|
|
359
|
+
green12: 'pink',
|
|
360
|
+
blue12: 'magenta'
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
});
|
|
365
|
+
it('local themes should work correctly', async () => {
|
|
366
|
+
const _Array$fill$map3 = Array(6).fill(0).map(() => (0, _uiTestUtils.spy)()),
|
|
367
|
+
_Array$fill$map4 = (0, _slicedToArray2.default)(_Array$fill$map3, 4),
|
|
368
|
+
cb1 = _Array$fill$map4[0],
|
|
369
|
+
cb2 = _Array$fill$map4[1],
|
|
370
|
+
cb3 = _Array$fill$map4[2],
|
|
371
|
+
cb4 = _Array$fill$map4[3];
|
|
372
|
+
const theme = _themeRegistry.ThemeRegistry.registerTheme(_canvasHighContrast.canvasHighContrast);
|
|
373
|
+
theme.use({
|
|
374
|
+
overrides: {
|
|
375
|
+
colors: {
|
|
376
|
+
primitives: {
|
|
377
|
+
red12: 'red',
|
|
378
|
+
green12: 'yellow',
|
|
379
|
+
blue12: 'magenta'
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
await (0, _uiTestUtils.mount)((0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
385
|
+
children: [(0, _jsxRuntime.jsx)(ExampleComponent, {
|
|
386
|
+
callback: cb1
|
|
387
|
+
}), (0, _jsxRuntime.jsxs)(_InstUISettingsProvider.InstUISettingsProvider, {
|
|
388
|
+
theme: _canvas.canvas,
|
|
389
|
+
children: [(0, _jsxRuntime.jsx)(ExampleComponent, {
|
|
390
|
+
callback: cb2
|
|
391
|
+
}), (0, _jsxRuntime.jsxs)(_InstUISettingsProvider.InstUISettingsProvider, {
|
|
392
|
+
theme: canvasThemeLocal,
|
|
393
|
+
children: [(0, _jsxRuntime.jsx)(ExampleComponent, {
|
|
394
|
+
callback: cb3
|
|
395
|
+
}), (0, _jsxRuntime.jsx)(_InstUISettingsProvider.InstUISettingsProvider, {
|
|
396
|
+
theme: {
|
|
397
|
+
colors: {
|
|
398
|
+
primitives: {
|
|
399
|
+
red12: 'orange'
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
themeOverrides: {
|
|
403
|
+
colors: {
|
|
404
|
+
primitives: {
|
|
405
|
+
green12: 'olive'
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
},
|
|
410
|
+
children: (0, _jsxRuntime.jsx)(ExampleComponent, {
|
|
411
|
+
callback: cb4
|
|
412
|
+
})
|
|
413
|
+
})]
|
|
414
|
+
})]
|
|
415
|
+
})]
|
|
416
|
+
}));
|
|
417
|
+
(0, _uiTestUtils.expect)(cb1).to.have.been.calledWithMatch({
|
|
418
|
+
...theme,
|
|
419
|
+
colors: {
|
|
420
|
+
primitives: {
|
|
421
|
+
red12: 'red',
|
|
422
|
+
green12: 'yellow',
|
|
423
|
+
blue12: 'magenta'
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
(0, _uiTestUtils.expect)(cb2).to.have.been.calledWith(_canvas.canvas);
|
|
428
|
+
(0, _uiTestUtils.expect)(cb3).to.have.been.calledWith(canvasThemeLocal);
|
|
429
|
+
(0, _uiTestUtils.expect)(cb4).to.have.been.calledWithMatch({
|
|
430
|
+
...canvasThemeLocal,
|
|
431
|
+
colors: {
|
|
432
|
+
primitives: {
|
|
433
|
+
red12: 'orange',
|
|
434
|
+
green12: 'olive'
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
});
|
|
439
|
+
});
|
|
440
|
+
it('should work correctly when multiple React trees is used', async () => {
|
|
441
|
+
const callback1 = (0, _uiTestUtils.spy)();
|
|
442
|
+
const callback2 = (0, _uiTestUtils.spy)();
|
|
443
|
+
const theme = _themeRegistry.ThemeRegistry.registerTheme(_canvasHighContrast.canvasHighContrast);
|
|
444
|
+
theme.use();
|
|
445
|
+
|
|
446
|
+
//first react tree
|
|
447
|
+
await (0, _uiTestUtils.mount)((0, _jsxRuntime.jsx)(ExampleComponent, {
|
|
448
|
+
callback: callback1
|
|
449
|
+
}));
|
|
450
|
+
|
|
451
|
+
//second react tree
|
|
452
|
+
await (0, _uiTestUtils.mount)((0, _jsxRuntime.jsx)(ExampleComponent, {
|
|
453
|
+
callback: callback2
|
|
454
|
+
}));
|
|
455
|
+
(0, _uiTestUtils.expect)(callback1).to.have.been.calledWith(theme);
|
|
456
|
+
(0, _uiTestUtils.expect)(callback2).to.have.been.calledWith(theme);
|
|
457
|
+
});
|
|
458
|
+
it('should work correctly when multiple React trees is used together with InstUISettingsProvider', async () => {
|
|
459
|
+
const callback1 = (0, _uiTestUtils.spy)();
|
|
460
|
+
const callback2 = (0, _uiTestUtils.spy)();
|
|
461
|
+
const callback3 = (0, _uiTestUtils.spy)();
|
|
462
|
+
const theme = _themeRegistry.ThemeRegistry.registerTheme(_canvasHighContrast.canvasHighContrast);
|
|
463
|
+
theme.use();
|
|
464
|
+
|
|
465
|
+
//first react tree
|
|
466
|
+
await (0, _uiTestUtils.mount)((0, _jsxRuntime.jsx)(ExampleComponent, {
|
|
467
|
+
callback: callback1
|
|
468
|
+
}));
|
|
469
|
+
|
|
470
|
+
//second react tree
|
|
471
|
+
await (0, _uiTestUtils.mount)((0, _jsxRuntime.jsx)(_InstUISettingsProvider.InstUISettingsProvider, {
|
|
472
|
+
children: (0, _jsxRuntime.jsx)(ExampleComponent, {
|
|
473
|
+
callback: callback2
|
|
474
|
+
})
|
|
475
|
+
}));
|
|
476
|
+
|
|
477
|
+
//third react tree
|
|
478
|
+
await (0, _uiTestUtils.mount)((0, _jsxRuntime.jsx)(_InstUISettingsProvider.InstUISettingsProvider, {
|
|
479
|
+
theme: _canvasHighContrast.canvasHighContrast,
|
|
480
|
+
children: (0, _jsxRuntime.jsx)(ExampleComponent, {
|
|
481
|
+
callback: callback3
|
|
482
|
+
})
|
|
483
|
+
}));
|
|
484
|
+
(0, _uiTestUtils.expect)(callback1).to.have.been.calledWith(theme);
|
|
485
|
+
(0, _uiTestUtils.expect)(callback2).to.have.been.calledWith(theme);
|
|
486
|
+
(0, _uiTestUtils.expect)(callback3).to.have.been.calledWith(_canvasHighContrast.canvasHighContrast);
|
|
487
|
+
});
|
|
488
|
+
});
|