@elastic/eui-theme-common 10.1.0 → 10.2.0

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.
@@ -59,3 +59,38 @@ describe('EuiVisColorStore', () => {
59
59
  });
60
60
  });
61
61
  });
62
+ describe('getInstance() initialization contract', () => {
63
+ // Each test gets a fresh module registry so the singleton starts
64
+ // uninitialized, as it would for a consumer that imports this package
65
+ // standalone (e.g. without @elastic/eui).
66
+ it('throws when accessed before being initialized with default colors', () => {
67
+ jest.isolateModules(() => {
68
+ const { EuiVisColorStore: FreshStore } = jest.requireActual('./vis_color_store');
69
+ expect(() => FreshStore.getInstance()).toThrow('EuiVisColorStore was accessed before it was initialized');
70
+ });
71
+ });
72
+ it('returns the existing instance when called without arguments after initialization', () => {
73
+ jest.isolateModules(() => {
74
+ const { EuiVisColorStore: FreshStore } = jest.requireActual('./vis_color_store');
75
+ const initialized = FreshStore.getInstance(visColors);
76
+ expect(FreshStore.getInstance()).toBe(initialized);
77
+ expect(FreshStore.getInstance().visColors).toEqual(visColors);
78
+ });
79
+ });
80
+ it('provides palette defaults once a theme package has initialized the store', () => {
81
+ jest.isolateModules(() => {
82
+ const { EuiVisColorStore: FreshStore } = jest.requireActual('./vis_color_store');
83
+ const { euiPaletteColorBlind } = jest.requireActual('./eui_palettes');
84
+ // simulates what a theme package (e.g. @elastic/eui-theme-borealis)
85
+ // does on import
86
+ FreshStore.getInstance(visColors);
87
+ expect(euiPaletteColorBlind()[0]).toBe(visColors.euiColorVis0);
88
+ });
89
+ });
90
+ it('palette functions throw a descriptive error when no theme initialized the store', () => {
91
+ jest.isolateModules(() => {
92
+ const { euiPaletteColorBlind } = jest.requireActual('./eui_palettes');
93
+ expect(() => euiPaletteColorBlind()).toThrow('EuiVisColorStore was accessed before it was initialized');
94
+ });
95
+ });
96
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elastic/eui-theme-common",
3
- "version": "10.1.0",
3
+ "version": "10.2.0",
4
4
  "description": "EUI theme common",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "scripts": {
@@ -26,7 +26,7 @@
26
26
  "dependencies": {
27
27
  "@types/lodash": "^4.14.202",
28
28
  "chroma-js": "^2.4.2",
29
- "lodash": "^4.17.21"
29
+ "lodash": "^4.18.1"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@babel/cli": "^7.21.5",