@cratis/scene.primereact 4.1.1 → 4.2.1

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.
Files changed (87) hide show
  1. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  2. package/package.json +18 -17
  3. package/dist/esm/for_columnDefinitions/when_deriving_columns.d.ts +0 -2
  4. package/dist/esm/for_columnDefinitions/when_deriving_columns.d.ts.map +0 -1
  5. package/dist/esm/for_columnDefinitions/when_deriving_columns.js +0 -64
  6. package/dist/esm/for_columnDefinitions/when_deriving_columns.js.map +0 -1
  7. package/dist/esm/for_menuItems/when_converting_entries.d.ts +0 -2
  8. package/dist/esm/for_menuItems/when_converting_entries.d.ts.map +0 -1
  9. package/dist/esm/for_menuItems/when_converting_entries.js +0 -31
  10. package/dist/esm/for_menuItems/when_converting_entries.js.map +0 -1
  11. package/dist/esm/for_primeReactPackage/when_inspecting_the_manifest.d.ts +0 -2
  12. package/dist/esm/for_primeReactPackage/when_inspecting_the_manifest.d.ts.map +0 -1
  13. package/dist/esm/for_primeReactPackage/when_inspecting_the_manifest.js +0 -31
  14. package/dist/esm/for_primeReactPackage/when_inspecting_the_manifest.js.map +0 -1
  15. package/dist/esm/for_primeReactPackage/when_inspecting_the_registry.d.ts +0 -2
  16. package/dist/esm/for_primeReactPackage/when_inspecting_the_registry.d.ts.map +0 -1
  17. package/dist/esm/for_primeReactPackage/when_inspecting_the_registry.js +0 -25
  18. package/dist/esm/for_primeReactPackage/when_inspecting_the_registry.js.map +0 -1
  19. package/dist/esm/for_primeReactPackage/when_rendering_every_declared_component.d.ts +0 -2
  20. package/dist/esm/for_primeReactPackage/when_rendering_every_declared_component.d.ts.map +0 -1
  21. package/dist/esm/for_primeReactPackage/when_rendering_every_declared_component.js +0 -65
  22. package/dist/esm/for_primeReactPackage/when_rendering_every_declared_component.js.map +0 -1
  23. package/dist/esm/for_primeReactPackage/when_resolving_a_name_core_also_declares.d.ts +0 -2
  24. package/dist/esm/for_primeReactPackage/when_resolving_a_name_core_also_declares.d.ts.map +0 -1
  25. package/dist/esm/for_primeReactPackage/when_resolving_a_name_core_also_declares.js +0 -34
  26. package/dist/esm/for_primeReactPackage/when_resolving_a_name_core_also_declares.js.map +0 -1
  27. package/dist/esm/for_primeReactPackage/when_validating_the_bundle.d.ts +0 -2
  28. package/dist/esm/for_primeReactPackage/when_validating_the_bundle.d.ts.map +0 -1
  29. package/dist/esm/for_primeReactPackage/when_validating_the_bundle.js +0 -12
  30. package/dist/esm/for_primeReactPackage/when_validating_the_bundle.js.map +0 -1
  31. package/dist/esm/for_primeReactThemePreset/when_resolving_a_preset.d.ts +0 -2
  32. package/dist/esm/for_primeReactThemePreset/when_resolving_a_preset.d.ts.map +0 -1
  33. package/dist/esm/for_primeReactThemePreset/when_resolving_a_preset.js +0 -30
  34. package/dist/esm/for_primeReactThemePreset/when_resolving_a_preset.js.map +0 -1
  35. package/dist/esm/for_primeReactThemes/when_checking_attribution.d.ts +0 -2
  36. package/dist/esm/for_primeReactThemes/when_checking_attribution.d.ts.map +0 -1
  37. package/dist/esm/for_primeReactThemes/when_checking_attribution.js +0 -27
  38. package/dist/esm/for_primeReactThemes/when_checking_attribution.js.map +0 -1
  39. package/dist/esm/for_primeReactThemes/when_checking_compatibility.d.ts +0 -2
  40. package/dist/esm/for_primeReactThemes/when_checking_compatibility.d.ts.map +0 -1
  41. package/dist/esm/for_primeReactThemes/when_checking_compatibility.js +0 -18
  42. package/dist/esm/for_primeReactThemes/when_checking_compatibility.js.map +0 -1
  43. package/dist/esm/for_primeReactThemes/when_checking_the_token_vocabulary.d.ts +0 -2
  44. package/dist/esm/for_primeReactThemes/when_checking_the_token_vocabulary.d.ts.map +0 -1
  45. package/dist/esm/for_primeReactThemes/when_checking_the_token_vocabulary.js +0 -48
  46. package/dist/esm/for_primeReactThemes/when_checking_the_token_vocabulary.js.map +0 -1
  47. package/dist/esm/for_properties/when_reading_a_boolean_property.d.ts +0 -2
  48. package/dist/esm/for_properties/when_reading_a_boolean_property.d.ts.map +0 -1
  49. package/dist/esm/for_properties/when_reading_a_boolean_property.js +0 -26
  50. package/dist/esm/for_properties/when_reading_a_boolean_property.js.map +0 -1
  51. package/dist/esm/for_properties/when_reading_a_number_property.d.ts +0 -2
  52. package/dist/esm/for_properties/when_reading_a_number_property.d.ts.map +0 -1
  53. package/dist/esm/for_properties/when_reading_a_number_property.js +0 -29
  54. package/dist/esm/for_properties/when_reading_a_number_property.js.map +0 -1
  55. package/dist/esm/for_properties/when_reading_a_string_property.d.ts +0 -2
  56. package/dist/esm/for_properties/when_reading_a_string_property.d.ts.map +0 -1
  57. package/dist/esm/for_properties/when_reading_a_string_property.js +0 -23
  58. package/dist/esm/for_properties/when_reading_a_string_property.js.map +0 -1
  59. package/dist/esm/for_properties/when_reading_an_array_property.d.ts +0 -2
  60. package/dist/esm/for_properties/when_reading_an_array_property.d.ts.map +0 -1
  61. package/dist/esm/for_properties/when_reading_an_array_property.js +0 -32
  62. package/dist/esm/for_properties/when_reading_an_array_property.js.map +0 -1
  63. package/dist/esm/for_properties/when_reading_options.d.ts +0 -2
  64. package/dist/esm/for_properties/when_reading_options.d.ts.map +0 -1
  65. package/dist/esm/for_properties/when_reading_options.js +0 -37
  66. package/dist/esm/for_properties/when_reading_options.js.map +0 -1
  67. package/dist/esm/for_treeNodes/when_converting_entries.d.ts +0 -2
  68. package/dist/esm/for_treeNodes/when_converting_entries.d.ts.map +0 -1
  69. package/dist/esm/for_treeNodes/when_converting_entries.js +0 -33
  70. package/dist/esm/for_treeNodes/when_converting_entries.js.map +0 -1
  71. package/for_columnDefinitions/when_deriving_columns.ts +0 -80
  72. package/for_menuItems/when_converting_entries.ts +0 -40
  73. package/for_primeReactPackage/when_inspecting_the_manifest.ts +0 -41
  74. package/for_primeReactPackage/when_inspecting_the_registry.ts +0 -33
  75. package/for_primeReactPackage/when_rendering_every_declared_component.tsx +0 -111
  76. package/for_primeReactPackage/when_resolving_a_name_core_also_declares.ts +0 -45
  77. package/for_primeReactPackage/when_validating_the_bundle.ts +0 -17
  78. package/for_primeReactThemePreset/when_resolving_a_preset.ts +0 -49
  79. package/for_primeReactThemes/when_checking_attribution.ts +0 -46
  80. package/for_primeReactThemes/when_checking_compatibility.ts +0 -26
  81. package/for_primeReactThemes/when_checking_the_token_vocabulary.ts +0 -70
  82. package/for_properties/when_reading_a_boolean_property.ts +0 -35
  83. package/for_properties/when_reading_a_number_property.ts +0 -39
  84. package/for_properties/when_reading_a_string_property.ts +0 -31
  85. package/for_properties/when_reading_an_array_property.ts +0 -41
  86. package/for_properties/when_reading_options.ts +0 -50
  87. package/for_treeNodes/when_converting_entries.ts +0 -43
@@ -1,17 +0,0 @@
1
- // Copyright (c) Cratis. All rights reserved.
2
- // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
-
4
- import { validatePackageBundle } from '@cratis/scene.react';
5
- import { primeReactPackage } from '../primeReactPackage';
6
-
7
- describe('when validating the bundle', () => {
8
- let problems: string[];
9
-
10
- beforeEach(() => {
11
- problems = validatePackageBundle(primeReactPackage);
12
- });
13
-
14
- it('should report no problems', () => {
15
- problems.should.deep.equal([]);
16
- });
17
- });
@@ -1,49 +0,0 @@
1
- // Copyright (c) Cratis. All rights reserved.
2
- // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
-
4
- import { primeReactThemeNames, primeReactThemePreset } from '../theme';
5
-
6
- describe('when resolving a preset', () => {
7
- describe('and the theme is one this package ships', () => {
8
- it('should resolve a preset for every theme in the catalog', () => {
9
- primeReactThemeNames.filter((name) => primeReactThemePreset(name) === undefined).should.deep.equal([]);
10
- });
11
-
12
- it('should bind the theme accent onto the preset primary scale', () => {
13
- const preset = primeReactThemePreset('lara-light-blue')!;
14
- (preset.semantic!.primary as Record<string, string>)['500'].should.equal('#3b82f6');
15
- });
16
-
17
- it('should bind a different accent for a differently tinted theme of the same family', () => {
18
- const preset = primeReactThemePreset('lara-light-teal')!;
19
- (preset.semantic!.primary as Record<string, string>)['500'].should.equal('#14b8a6');
20
- });
21
-
22
- /**
23
- * `definePreset` deep-merges into a *new* object, but the base presets are module singletons.
24
- * A merge that mutated its base would leave whichever theme resolved first tinting every later
25
- * one - a bug that only appears once two themes of a family are used in the same session, which
26
- * is exactly what a theme picker does.
27
- */
28
- it('should not tint one theme with another theme of the same family', () => {
29
- primeReactThemePreset('lara-light-purple');
30
- const blue = primeReactThemePreset('lara-light-blue')!;
31
- (blue.semantic!.primary as Record<string, string>)['500'].should.equal('#3b82f6');
32
- });
33
-
34
- /**
35
- * `PrimeReactProvider` treats a new preset identity as a theme change and re-emits every `--p-*`
36
- * custom property, so handing it a freshly built object each render would repaint the page on
37
- * every render.
38
- */
39
- it('should return the same preset instance for the same theme, so a re-render is not a theme change', () => {
40
- primeReactThemePreset('aura-dark-indigo')!.should.equal(primeReactThemePreset('aura-dark-indigo')!);
41
- });
42
- });
43
-
44
- describe('and the theme is unknown', () => {
45
- it('should resolve nothing rather than a default that would silently theme a screen wrongly', () => {
46
- (primeReactThemePreset('lara-light-chartreuse') === undefined).should.be.true;
47
- });
48
- });
49
- });
@@ -1,46 +0,0 @@
1
- // Copyright (c) Cratis. All rights reserved.
2
- // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
-
4
- import { primeReactThemeLicense, primeReactThemeLicenseUrl, primeReactThemes } from '../theme';
5
-
6
- describe('when checking attribution', () => {
7
- it('should credit an author on every theme', () => {
8
- primeReactThemes.filter((theme) => theme.author === undefined || theme.author === '').should.deep.equal([]);
9
- });
10
-
11
- it('should link to the author on every theme', () => {
12
- primeReactThemes.filter((theme) => theme.authorUrl === undefined || theme.authorUrl === '').should.deep.equal([]);
13
- });
14
-
15
- it('should state a license on every theme', () => {
16
- primeReactThemes.filter((theme) => theme.license === undefined || theme.license === '').should.deep.equal([]);
17
- });
18
-
19
- it('should credit PrimeTek, whose presets every one of them is built on', () => {
20
- primeReactThemes.filter((theme) => theme.author !== 'PrimeTek').should.deep.equal([]);
21
- });
22
-
23
- /**
24
- * The assertion this spec exists for. Until PrimeReact 11 these themes really were MIT, and the
25
- * previous version of this file pinned exactly that. Relicensing is invisible to a compiler and to
26
- * every other spec in this package, so without a spec that names the current license out loud, the
27
- * catalog would have gone on advertising MIT indefinitely.
28
- */
29
- it('should state the commercial license PrimeReact 11 actually ships under, not the MIT of v10', () => {
30
- primeReactThemeLicense.should.equal('PrimeUI Community / Commercial');
31
- primeReactThemes.filter((theme) => theme.license !== primeReactThemeLicense).should.deep.equal([]);
32
- });
33
-
34
- /**
35
- * A license name on its own does not tell a reader whether they qualify for the free Community tier
36
- * or owe a commercial fee. The link is the part that answers that, so it is pinned too.
37
- */
38
- it('should link to the terms on every theme, not just name them', () => {
39
- primeReactThemeLicenseUrl.should.equal('https://primeui.dev/licenses/community');
40
- primeReactThemes.filter((theme) => theme.licenseUrl !== primeReactThemeLicenseUrl).should.deep.equal([]);
41
- });
42
-
43
- it('should describe every theme for a picker', () => {
44
- primeReactThemes.filter((theme) => theme.description === undefined || theme.description === '').should.deep.equal([]);
45
- });
46
- });
@@ -1,26 +0,0 @@
1
- // Copyright (c) Cratis. All rights reserved.
2
- // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
-
4
- import { incompatiblePackages } from '@cratis/scene.engine';
5
- import { UiProfile } from '@cratis/scene.model';
6
- import { primeReactThemes } from '../theme';
7
-
8
- describe('when checking compatibility', () => {
9
- const profile: UiProfile = { name: 'web', targetPlatform: 'web', packages: ['core', 'PrimeReact', 'Tailwind'] };
10
-
11
- it('should declare every theme compatible with PrimeReact', () => {
12
- primeReactThemes.filter((theme) => !theme.compatibleWith.includes('PrimeReact')).should.deep.equal([]);
13
- });
14
-
15
- it('should declare every theme compatible with Tailwind', () => {
16
- primeReactThemes.filter((theme) => !theme.compatibleWith.includes('Tailwind')).should.deep.equal([]);
17
- });
18
-
19
- it('should declare every theme compatible with core, which gets no implicit exemption', () => {
20
- primeReactThemes.filter((theme) => !theme.compatibleWith.includes('core')).should.deep.equal([]);
21
- });
22
-
23
- it('should report no incompatibility for a profile listing all three', () => {
24
- primeReactThemes.flatMap((theme) => incompatiblePackages(theme, profile)).should.deep.equal([]);
25
- });
26
- });
@@ -1,70 +0,0 @@
1
- // Copyright (c) Cratis. All rights reserved.
2
- // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
-
4
- import { primeReactThemes } from '../theme';
5
-
6
- describe('when checking the token vocabulary', () => {
7
- const vocabulary = [
8
- 'primary.color',
9
- 'primary.contrastColor',
10
- 'surface.background',
11
- 'surface.card',
12
- 'surface.border',
13
- 'surface.hover',
14
- 'surface.overlay',
15
- 'text.color',
16
- 'text.mutedColor',
17
- 'highlight.background',
18
- 'highlight.color',
19
- 'content.borderRadius',
20
- 'focus.ring',
21
- ];
22
-
23
- it('should give every theme the whole vocabulary', () => {
24
- const incomplete = primeReactThemes
25
- .filter((theme) => vocabulary.some((token) => theme.tokens?.[token] === undefined))
26
- .map((theme) => theme.name);
27
- incomplete.should.deep.equal([]);
28
- });
29
-
30
- it('should give every theme nothing but the vocabulary, so packages can agree on it', () => {
31
- const extra = primeReactThemes.flatMap((theme) => Object.keys(theme.tokens ?? {}).filter((token) => !vocabulary.includes(token)));
32
- extra.should.deep.equal([]);
33
- });
34
-
35
- it('should say whether every theme is dark', () => {
36
- primeReactThemes.filter((theme) => theme.isDark === undefined).should.deep.equal([]);
37
- });
38
-
39
- it('should ship both light and dark themes', () => {
40
- primeReactThemes.some((theme) => theme.isDark === true).should.be.true;
41
- primeReactThemes.some((theme) => theme.isDark === false).should.be.true;
42
- });
43
-
44
- /**
45
- * The token values are generated by resolving each preset's `{path}` references and `light-dark()`
46
- * pairs, so the risk is not a typo but a resolver that silently gave up - leaving a raw `{emerald.500}`
47
- * or an unpicked `light-dark(...)` in the catalog, which reaches CSS as a value the browser drops.
48
- */
49
- it('should have resolved every token to a literal value rather than leaving a preset reference behind', () => {
50
- const unresolved = primeReactThemes.flatMap((theme) =>
51
- Object.entries(theme.tokens ?? {})
52
- .filter(([, value]) => value.includes('{') || value.includes('light-dark('))
53
- .map(([token]) => `${theme.name}: ${token}`)
54
- );
55
- unresolved.should.deep.equal([]);
56
- });
57
-
58
- it('should mirror the accent the preset binds for a light theme', () => {
59
- primeReactThemes.find((theme) => theme.name === 'lara-light-blue')!.tokens!['primary.color'].should.equal('#3b82f6');
60
- });
61
-
62
- /**
63
- * A dark theme takes the lighter step of the accent ramp, not the same value as its light sibling.
64
- * Getting this wrong is the classic `light-dark()` resolution bug and produces a dark theme that is
65
- * legible everywhere except its own accent.
66
- */
67
- it('should take the accent from the lighter end of the ramp for a dark theme', () => {
68
- primeReactThemes.find((theme) => theme.name === 'lara-dark-blue')!.tokens!['primary.color'].should.equal('#60a5fa');
69
- });
70
- });
@@ -1,35 +0,0 @@
1
- // Copyright (c) Cratis. All rights reserved.
2
- // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
-
4
- import { SceneElement } from '@cratis/scene.model';
5
- import { booleanProperty } from '../properties';
6
-
7
- describe('when reading a boolean property', () => {
8
- const element: SceneElement = { id: 'element', properties: { disabled: true, visible: false, filter: 'yes' } };
9
-
10
- describe('and the property is present and a boolean', () => {
11
- it('should return true when it is true', () => {
12
- booleanProperty(element, 'disabled', false).should.be.true;
13
- });
14
-
15
- it('should return false when it is false rather than falling back', () => {
16
- booleanProperty(element, 'visible', true).should.be.false;
17
- });
18
- });
19
-
20
- describe('and the property is missing', () => {
21
- it('should return undefined when no fallback was given', () => {
22
- (booleanProperty(element, 'rounded') === undefined).should.be.true;
23
- });
24
-
25
- it('should return the fallback when one was given', () => {
26
- booleanProperty(element, 'rounded', true).should.be.true;
27
- });
28
- });
29
-
30
- describe('and the property is present but not a boolean', () => {
31
- it('should treat a truthy string like a missing property', () => {
32
- booleanProperty(element, 'filter', false).should.be.false;
33
- });
34
- });
35
- });
@@ -1,39 +0,0 @@
1
- // Copyright (c) Cratis. All rights reserved.
2
- // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
-
4
- import { SceneElement } from '@cratis/scene.model';
5
- import { numberProperty } from '../properties';
6
-
7
- describe('when reading a number property', () => {
8
- const element: SceneElement = { id: 'element', properties: { rows: 5, zero: 0, size: '12', broken: Number.NaN } };
9
-
10
- describe('and the property is present and a number', () => {
11
- it('should return it', () => {
12
- numberProperty(element, 'rows', 1).should.equal(5);
13
- });
14
-
15
- it('should return zero rather than falling back', () => {
16
- numberProperty(element, 'zero', 10).should.equal(0);
17
- });
18
- });
19
-
20
- describe('and the property is missing', () => {
21
- it('should return undefined when no fallback was given', () => {
22
- (numberProperty(element, 'columns') === undefined).should.be.true;
23
- });
24
-
25
- it('should return the fallback when one was given', () => {
26
- numberProperty(element, 'columns', 2).should.equal(2);
27
- });
28
- });
29
-
30
- describe('and the property is present but not a usable number', () => {
31
- it('should treat a numeric string like a missing property', () => {
32
- numberProperty(element, 'size', 16).should.equal(16);
33
- });
34
-
35
- it('should treat NaN like a missing property, because it is never a usable size', () => {
36
- numberProperty(element, 'broken', 16).should.equal(16);
37
- });
38
- });
39
- });
@@ -1,31 +0,0 @@
1
- // Copyright (c) Cratis. All rights reserved.
2
- // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
-
4
- import { SceneElement } from '@cratis/scene.model';
5
- import { stringProperty } from '../properties';
6
-
7
- describe('when reading a string property', () => {
8
- const element: SceneElement = { id: 'element', properties: { label: 'Save', count: 3 } };
9
-
10
- describe('and the property is present and a string', () => {
11
- it('should return it', () => {
12
- stringProperty(element, 'label')!.should.equal('Save');
13
- });
14
- });
15
-
16
- describe('and the property is missing', () => {
17
- it('should return undefined when no fallback was given', () => {
18
- (stringProperty(element, 'placeholder') === undefined).should.be.true;
19
- });
20
-
21
- it('should return the fallback when one was given', () => {
22
- stringProperty(element, 'placeholder', 'Type here').should.equal('Type here');
23
- });
24
- });
25
-
26
- describe('and the property is present but not a string', () => {
27
- it('should treat it exactly like a missing one', () => {
28
- stringProperty(element, 'count', 'none').should.equal('none');
29
- });
30
- });
31
- });
@@ -1,41 +0,0 @@
1
- // Copyright (c) Cratis. All rights reserved.
2
- // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
-
4
- import { SceneElement } from '@cratis/scene.model';
5
- import { arrayProperty, recordArrayProperty, stringArrayProperty } from '../properties';
6
-
7
- describe('when reading an array property', () => {
8
- const element: SceneElement = {
9
- id: 'element',
10
- properties: {
11
- mixed: ['a', 2, { name: 'c' }, ['d'], undefined],
12
- notAnArray: 'a',
13
- },
14
- };
15
-
16
- describe('and the property is present and an array', () => {
17
- it('should return every entry untouched', () => {
18
- arrayProperty(element, 'mixed').should.have.lengthOf(5);
19
- });
20
-
21
- it('should keep only the strings when strings were asked for', () => {
22
- stringArrayProperty(element, 'mixed').should.deep.equal(['a']);
23
- });
24
-
25
- it('should keep only the objects when objects were asked for, excluding arrays', () => {
26
- recordArrayProperty(element, 'mixed').should.deep.equal([{ name: 'c' }]);
27
- });
28
- });
29
-
30
- describe('and the property is missing', () => {
31
- it('should return an empty array rather than undefined, because every caller maps over it', () => {
32
- arrayProperty(element, 'absent').should.deep.equal([]);
33
- });
34
- });
35
-
36
- describe('and the property is present but not an array', () => {
37
- it('should treat it exactly like a missing one', () => {
38
- arrayProperty(element, 'notAnArray').should.deep.equal([]);
39
- });
40
- });
41
- });
@@ -1,50 +0,0 @@
1
- // Copyright (c) Cratis. All rights reserved.
2
- // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
-
4
- import { SceneElement } from '@cratis/scene.model';
5
- import { optionsProperty } from '../properties';
6
-
7
- describe('when reading options', () => {
8
- describe('and the options are written as bare strings', () => {
9
- const element: SceneElement = { id: 'element', properties: { options: ['Draft', 'Published'] } };
10
-
11
- it('should use each string as both label and value', () => {
12
- optionsProperty(element, 'options').should.deep.equal([
13
- { label: 'Draft', value: 'Draft' },
14
- { label: 'Published', value: 'Published' },
15
- ]);
16
- });
17
- });
18
-
19
- describe('and the options are written as records', () => {
20
- const element: SceneElement = { id: 'element', properties: { options: [{ label: 'Draft', value: 'draft' }] } };
21
-
22
- it('should keep the label and value apart', () => {
23
- optionsProperty(element, 'options').should.deep.equal([{ label: 'Draft', value: 'draft' }]);
24
- });
25
- });
26
-
27
- describe('and a record carries only a label', () => {
28
- const element: SceneElement = { id: 'element', properties: { options: [{ label: 'Draft' }] } };
29
-
30
- it('should use the label as the value, which is what the shorthand means', () => {
31
- optionsProperty(element, 'options').should.deep.equal([{ label: 'Draft', value: 'Draft' }]);
32
- });
33
- });
34
-
35
- describe('and an entry carries no usable label', () => {
36
- const element: SceneElement = { id: 'element', properties: { options: [{ value: 'draft' }, 7, { label: 'Draft' }] } };
37
-
38
- it('should skip it rather than render a blank choice', () => {
39
- optionsProperty(element, 'options').should.deep.equal([{ label: 'Draft', value: 'Draft' }]);
40
- });
41
- });
42
-
43
- describe('and the property is missing', () => {
44
- const element: SceneElement = { id: 'element', properties: {} };
45
-
46
- it('should return no options', () => {
47
- optionsProperty(element, 'options').should.deep.equal([]);
48
- });
49
- });
50
- });
@@ -1,43 +0,0 @@
1
- // Copyright (c) Cratis. All rights reserved.
2
- // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
-
4
- import { toTreeNodes } from '../treeNodes';
5
-
6
- describe('when converting entries', () => {
7
- describe('and no entry supplies a key', () => {
8
- const nodes = toTreeNodes([{ label: 'Documents', children: [{ label: 'Work' }, { label: 'Work' }] }]);
9
-
10
- it('should derive a key from the path', () => {
11
- nodes[0].key!.should.equal('0');
12
- });
13
-
14
- it('should keep two identically labeled siblings apart, so expansion and selection track the right row', () => {
15
- nodes[0].children![0].key!.should.equal('0-0');
16
- nodes[0].children![1].key!.should.equal('0-1');
17
- });
18
- });
19
-
20
- describe('and an entry supplies its own key', () => {
21
- const nodes = toTreeNodes([{ key: 'docs', label: 'Documents', children: [{ label: 'Work' }] }]);
22
-
23
- it('should keep it', () => {
24
- nodes[0].key!.should.equal('docs');
25
- });
26
-
27
- it('should build child keys from it', () => {
28
- nodes[0].children![0].key!.should.equal('docs-0');
29
- });
30
- });
31
-
32
- describe('and an entry is a bare string', () => {
33
- it('should use it as the label', () => {
34
- toTreeNodes(['Documents'])[0].label!.should.equal('Documents');
35
- });
36
- });
37
-
38
- describe('and an entry is neither a string nor a record', () => {
39
- it('should drop it', () => {
40
- toTreeNodes([7, ['nested'], 'Documents']).should.have.lengthOf(1);
41
- });
42
- });
43
- });