@jsonforms/angular-material 3.1.0-alpha.0 → 3.1.0-alpha.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 (74) hide show
  1. package/lib/cjs/controls/autocomplete.renderer.d.ts +2 -2
  2. package/lib/cjs/other/master-detail/master.js +3 -0
  3. package/lib/cjs/other/master-detail/master.js.map +1 -1
  4. package/lib/cjs/other/master-detail/master.metadata.json +1 -1
  5. package/lib/esm/controls/autocomplete.renderer.d.ts +2 -2
  6. package/lib/esm/other/master-detail/master.js +4 -1
  7. package/lib/esm/other/master-detail/master.js.map +1 -1
  8. package/lib/esm/other/master-detail/master.metadata.json +1 -1
  9. package/package.json +23 -8
  10. package/src/controls/autocomplete.renderer.ts +2 -2
  11. package/src/layouts/layout.renderer.ts +2 -2
  12. package/src/other/master-detail/master.ts +5 -0
  13. package/docs/assets/css/main.css +0 -1
  14. package/docs/assets/images/icons.png +0 -0
  15. package/docs/assets/images/icons@2x.png +0 -0
  16. package/docs/assets/images/widgets.png +0 -0
  17. package/docs/assets/images/widgets@2x.png +0 -0
  18. package/docs/assets/js/main.js +0 -51
  19. package/docs/assets/js/search.json +0 -1
  20. package/docs/classes/arraylayoutrenderer.html +0 -1256
  21. package/docs/classes/autocompletecontrolrenderer.html +0 -887
  22. package/docs/classes/booleancontrolrenderer.html +0 -771
  23. package/docs/classes/categorizationtablayoutrenderer.html +0 -384
  24. package/docs/classes/datecontrolrenderer.html +0 -739
  25. package/docs/classes/grouplayoutrenderer.html +0 -396
  26. package/docs/classes/horizontallayoutrenderer.html +0 -396
  27. package/docs/classes/jsonformsangularmaterialmodule.html +0 -133
  28. package/docs/classes/jsonformsdetailcomponent.html +0 -227
  29. package/docs/classes/labelrenderer.html +0 -363
  30. package/docs/classes/layoutchildrenrenderpropspipe.html +0 -189
  31. package/docs/classes/layoutrenderer.html +0 -436
  32. package/docs/classes/masterlistcomponent.html +0 -1054
  33. package/docs/classes/numbercontrolrenderer.html +0 -893
  34. package/docs/classes/objectcontrolrenderer.html +0 -761
  35. package/docs/classes/rangecontrolrenderer.html +0 -792
  36. package/docs/classes/tablerenderer.html +0 -1222
  37. package/docs/classes/textarearenderer.html +0 -739
  38. package/docs/classes/textcontrolrenderer.html +0 -760
  39. package/docs/classes/togglecontrolrenderer.html +0 -771
  40. package/docs/classes/verticallayoutrenderer.html +0 -396
  41. package/docs/globals.html +0 -610
  42. package/docs/index.html +0 -378
  43. package/docs/interfaces/columndescription.html +0 -192
  44. package/docs/interfaces/ownpropsofautocomplete.html +0 -327
  45. package/example/app/app.component.ts +0 -122
  46. package/example/app/app.module.ts +0 -42
  47. package/example/index.html +0 -25
  48. package/example/main.ts +0 -37
  49. package/test/autocomplete-control.spec.ts +0 -322
  50. package/test/boolean-control.spec.ts +0 -76
  51. package/test/categorization-tab-layout.spec.ts +0 -330
  52. package/test/date-control.spec.ts +0 -280
  53. package/test/group-layout.spec.ts +0 -105
  54. package/test/horizontal-layout.spec.ts +0 -96
  55. package/test/label-renderer.spec.ts +0 -78
  56. package/test/master-detail.spec.ts +0 -408
  57. package/test/number-control.spec.ts +0 -208
  58. package/test/object-control.spec.ts +0 -247
  59. package/test/range-control.spec.ts +0 -104
  60. package/test/table-control.spec.ts +0 -369
  61. package/test/text-area.spec.ts +0 -108
  62. package/test/text-control.spec.ts +0 -89
  63. package/test/toggle-control.spec.ts +0 -77
  64. package/test/tsconfig.test.json +0 -18
  65. package/test/util.ts +0 -28
  66. package/test/vertical-layout.spec.ts +0 -115
  67. package/test-config/karma-test-shim.js +0 -21
  68. package/test-config/karma.conf.js +0 -58
  69. package/test-config/protractor.conf.js +0 -28
  70. package/test-config/webpack.test.js +0 -65
  71. package/tsconfig.cjs.json +0 -9
  72. package/tsconfig.json +0 -16
  73. package/webpack/webpack.build.js +0 -13
  74. package/webpack/webpack.dev.js +0 -37
@@ -1,105 +0,0 @@
1
- /*
2
- The MIT License
3
-
4
- Copyright (c) 2017-2019 EclipseSource Munich
5
- https://github.com/eclipsesource/jsonforms
6
-
7
- Permission is hereby granted, free of charge, to any person obtaining a copy
8
- of this software and associated documentation files (the "Software"), to deal
9
- in the Software without restriction, including without limitation the rights
10
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- copies of the Software, and to permit persons to whom the Software is
12
- furnished to do so, subject to the following conditions:
13
-
14
- The above copyright notice and this permission notice shall be included in
15
- all copies or substantial portions of the Software.
16
-
17
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
- THE SOFTWARE.
24
- */
25
- import { ComponentFixture } from '@angular/core/testing';
26
- import { GroupLayout, UISchemaElement } from '@jsonforms/core';
27
- import { MatCard, MatCardTitle } from '@angular/material/card';
28
- import { By } from '@angular/platform-browser';
29
- import { DebugElement } from '@angular/core';
30
- import {
31
- beforeEachLayoutTest,
32
- setupMockStore
33
- } from '@jsonforms/angular-test';
34
- import { FlexLayoutModule } from '@angular/flex-layout';
35
- import { LayoutChildrenRenderPropsPipe } from '../src/layouts/layout.renderer';
36
- import {
37
- GroupLayoutRenderer,
38
- groupLayoutTester
39
- } from '../src/layouts/group-layout.renderer';
40
-
41
- describe('Group layout tester', () => {
42
- it('should succeed', () => {
43
- expect(groupLayoutTester({ type: 'Group' }, undefined, undefined)).toBe(1);
44
- });
45
- });
46
- describe('Group layout', () => {
47
- let fixture: ComponentFixture<any>;
48
-
49
- beforeEach(() => {
50
- fixture = beforeEachLayoutTest(GroupLayoutRenderer, {
51
- declarations: [LayoutChildrenRenderPropsPipe, MatCard, MatCardTitle],
52
- imports: [FlexLayoutModule]
53
- });
54
- });
55
-
56
- it('render with undefined elements', () => {
57
- const uischema: UISchemaElement = {
58
- type: 'Group'
59
- };
60
- setupMockStore(fixture, { data: {}, schema: {}, uischema });
61
- fixture.componentInstance.ngOnInit();
62
- fixture.detectChanges();
63
- const card: DebugElement[] = fixture.debugElement.queryAll(
64
- By.directive(MatCard)
65
- );
66
- // title
67
- expect(card[0].nativeElement.children.length).toBe(1);
68
- });
69
-
70
- it('render with null elements', () => {
71
- const uischema: GroupLayout = {
72
- type: 'Group',
73
- elements: null
74
- };
75
- setupMockStore(fixture, { data: {}, schema: {}, uischema });
76
- fixture.componentInstance.ngOnInit();
77
- fixture.detectChanges();
78
- const card: DebugElement[] = fixture.debugElement.queryAll(
79
- By.directive(MatCard)
80
- );
81
- // title
82
- expect(card[0].nativeElement.children.length).toBe(1);
83
- });
84
-
85
- it('render with children', () => {
86
- const uischema: GroupLayout = {
87
- type: 'Group',
88
- label: 'foo',
89
- elements: [{ type: 'Control' }, { type: 'Control' }]
90
- };
91
- setupMockStore(fixture, { data: {}, schema: {}, uischema });
92
- fixture.componentInstance.ngOnInit();
93
- fixture.detectChanges();
94
- const card: DebugElement[] = fixture.debugElement.queryAll(
95
- By.directive(MatCard)
96
- );
97
- const title: DebugElement = fixture.debugElement.query(
98
- By.directive(MatCardTitle)
99
- );
100
-
101
- expect(title.nativeElement.textContent).toBe('foo');
102
- // title + 2 controls
103
- expect(card[0].nativeElement.children.length).toBe(3);
104
- });
105
- });
@@ -1,96 +0,0 @@
1
- /*
2
- The MIT License
3
-
4
- Copyright (c) 2017-2019 EclipseSource Munich
5
- https://github.com/eclipsesource/jsonforms
6
-
7
- Permission is hereby granted, free of charge, to any person obtaining a copy
8
- of this software and associated documentation files (the "Software"), to deal
9
- in the Software without restriction, including without limitation the rights
10
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- copies of the Software, and to permit persons to whom the Software is
12
- furnished to do so, subject to the following conditions:
13
-
14
- The above copyright notice and this permission notice shall be included in
15
- all copies or substantial portions of the Software.
16
-
17
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
- THE SOFTWARE.
24
- */
25
- import { ComponentFixture } from '@angular/core/testing';
26
- import { HorizontalLayout, UISchemaElement } from '@jsonforms/core';
27
- import { beforeEachLayoutTest, setupMockStore } from '@jsonforms/angular-test';
28
- import { FlexLayoutModule } from '@angular/flex-layout';
29
- import {
30
- HorizontalLayoutRenderer,
31
- horizontalLayoutTester
32
- } from '../src/layouts/horizontal-layout.renderer';
33
- import { LayoutChildrenRenderPropsPipe } from '../src/layouts/layout.renderer';
34
-
35
- describe('Horizontal layout tester', () => {
36
- it('should succeed', () => {
37
- expect(
38
- horizontalLayoutTester({ type: 'HorizontalLayout' }, undefined, undefined)
39
- ).toBe(1);
40
- });
41
- });
42
- describe('Horizontal layout', () => {
43
- let fixture: ComponentFixture<any>;
44
-
45
- beforeEach(() => {
46
- fixture = beforeEachLayoutTest(HorizontalLayoutRenderer, {
47
- declarations: [LayoutChildrenRenderPropsPipe],
48
- imports: [FlexLayoutModule]
49
- });
50
- });
51
-
52
- it('render with undefined elements', () => {
53
- const uischema: UISchemaElement = {
54
- type: 'HorizontalLayout'
55
- };
56
- setupMockStore(fixture, {
57
- data: {},
58
- schema: {},
59
- uischema
60
- });
61
- fixture.componentInstance.ngOnInit();
62
- fixture.detectChanges();
63
- expect(fixture.nativeElement.children[0].children.length).toBe(0);
64
- });
65
-
66
- it('render with null elements', () => {
67
- const uischema: HorizontalLayout = {
68
- type: 'HorizontalLayout',
69
- elements: null
70
- };
71
- setupMockStore(fixture, {
72
- data: {},
73
- schema: {},
74
- uischema
75
- });
76
- fixture.componentInstance.ngOnInit();
77
- fixture.detectChanges();
78
- expect(fixture.nativeElement.children[0].children.length).toBe(0);
79
- });
80
-
81
- it('render with children', () => {
82
- const uischema: HorizontalLayout = {
83
- type: 'HorizontalLayout',
84
- elements: [{ type: 'Control' }, { type: 'Control' }]
85
- };
86
- setupMockStore(fixture, {
87
- data: {},
88
- schema: {},
89
- uischema
90
- });
91
- fixture.componentInstance.ngOnInit();
92
- fixture.detectChanges();
93
- expect(fixture.nativeElement.children[0].children.length).toBe(2);
94
- expect(fixture.nativeElement.children[0].hidden).toBe(false);
95
- });
96
- });
@@ -1,78 +0,0 @@
1
- /*
2
- The MIT License
3
-
4
- Copyright (c) 2017-2019 EclipseSource Munich
5
- https://github.com/eclipsesource/jsonforms
6
-
7
- Permission is hereby granted, free of charge, to any person obtaining a copy
8
- of this software and associated documentation files (the "Software"), to deal
9
- in the Software without restriction, including without limitation the rights
10
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- copies of the Software, and to permit persons to whom the Software is
12
- furnished to do so, subject to the following conditions:
13
-
14
- The above copyright notice and this permission notice shall be included in
15
- all copies or substantial portions of the Software.
16
-
17
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
- THE SOFTWARE.
24
- */
25
- import { ComponentFixture, TestBed } from '@angular/core/testing';
26
- import { By } from '@angular/platform-browser';
27
- import { JsonSchema, LabelElement } from '@jsonforms/core';
28
-
29
- import { LabelRenderer, LabelRendererTester } from '../src/other';
30
- import { setupMockStore } from '@jsonforms/angular-test';
31
- import { JsonFormsAngularService } from '@jsonforms/angular';
32
-
33
- const data = {};
34
- const schema: JsonSchema = {
35
- type: 'object',
36
- properties: {
37
- foo: {
38
- type: 'string'
39
- }
40
- }
41
- };
42
- const uischema: LabelElement = {
43
- type: 'Label',
44
- text: 'FooBar'
45
- };
46
-
47
- describe('Material label field tester', () => {
48
- it('should succeed', () => {
49
- expect(LabelRendererTester(uischema, schema, undefined)).toBe(4);
50
- });
51
- });
52
- const providers = [JsonFormsAngularService];
53
- const componentUT: any = LabelRenderer;
54
-
55
- describe('Label Renderer Base Tests', () => {
56
- let fixture: ComponentFixture<LabelRenderer>;
57
- let component: LabelRenderer;
58
- let labelElement: HTMLLabelElement;
59
- beforeEach(() => {
60
- TestBed.configureTestingModule({
61
- declarations: [componentUT],
62
- providers: providers
63
- }).compileComponents();
64
- });
65
- beforeEach(() => {
66
- fixture = TestBed.createComponent(componentUT);
67
- component = fixture.componentInstance;
68
-
69
- labelElement = fixture.debugElement.query(By.css('label')).nativeElement;
70
- });
71
-
72
- it('should render', () => {
73
- setupMockStore(fixture, { uischema, schema, data });
74
- fixture.detectChanges();
75
- component.ngOnInit();
76
- expect(labelElement.innerText.trim()).toBe('FooBar');
77
- });
78
- });
@@ -1,408 +0,0 @@
1
- /*
2
- The MIT License
3
-
4
- Copyright (c) 2017-2019 EclipseSource Munich
5
- https://github.com/eclipsesource/jsonforms
6
-
7
- Permission is hereby granted, free of charge, to any person obtaining a copy
8
- of this software and associated documentation files (the "Software"), to deal
9
- in the Software without restriction, including without limitation the rights
10
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- copies of the Software, and to permit persons to whom the Software is
12
- furnished to do so, subject to the following conditions:
13
-
14
- The above copyright notice and this permission notice shall be included in
15
- all copies or substantial portions of the Software.
16
-
17
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
- THE SOFTWARE.
24
- */
25
- import { async, ComponentFixture, TestBed } from '@angular/core/testing';
26
- import { By } from '@angular/platform-browser';
27
- import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
28
- import { MatButtonModule } from '@angular/material/button';
29
- import { MatIconModule } from '@angular/material/icon';
30
- import { MatListItem, MatListModule } from '@angular/material/list';
31
- import { MatSidenavModule } from '@angular/material/sidenav';
32
- import { NoopAnimationsModule } from '@angular/platform-browser/animations';
33
- import {
34
- JsonFormsAngularService,
35
- JsonFormsOutlet,
36
- UnknownRenderer
37
- } from '@jsonforms/angular';
38
- import { FlexLayoutModule } from '@angular/flex-layout';
39
- import { DebugElement } from '@angular/core';
40
- import { MasterListComponent } from '../src/other/master-detail/master';
41
- import { JsonFormsDetailComponent } from '../src/other/master-detail/detail';
42
- import { getJsonFormsService, setupMockStore } from '@jsonforms/angular-test';
43
- import { Actions } from '@jsonforms/core';
44
-
45
- describe('Master detail', () => {
46
- let fixture: ComponentFixture<MasterListComponent>;
47
- let component: any;
48
-
49
- const data = {
50
- orders: [
51
- {
52
- customer: {
53
- name: 'ACME'
54
- },
55
- title: 'Carrots'
56
- }
57
- ]
58
- };
59
- const schema = {
60
- definitions: {
61
- order: {
62
- type: 'object',
63
- properties: {
64
- customer: {
65
- type: 'object',
66
- properties: {
67
- name: { type: 'string' }
68
- }
69
- },
70
- title: {
71
- type: 'string'
72
- }
73
- }
74
- }
75
- },
76
- type: 'object',
77
- properties: {
78
- orders: {
79
- type: 'array',
80
- items: {
81
- $ref: '#/definitions/order'
82
- }
83
- }
84
- }
85
- };
86
- const uischema = {
87
- type: 'ListWithDetail',
88
- scope: '#/properties/orders',
89
- options: {
90
- labelRef: '#/items/properties/customer/properties/name',
91
- detail: {
92
- type: 'VerticalLayout',
93
- elements: [
94
- {
95
- type: 'Control',
96
- scope: '#/properties/customer/properties/name'
97
- }
98
- ]
99
- }
100
- }
101
- };
102
-
103
- beforeEach(() => {
104
- TestBed.configureTestingModule({
105
- declarations: [
106
- JsonFormsOutlet,
107
- MasterListComponent,
108
- UnknownRenderer,
109
- JsonFormsDetailComponent
110
- ],
111
- imports: [
112
- MatListModule,
113
- MatSidenavModule,
114
- MatIconModule,
115
- MatButtonModule,
116
- FlexLayoutModule,
117
- NoopAnimationsModule
118
- ],
119
- providers: [JsonFormsAngularService]
120
- })
121
- .overrideModule(BrowserDynamicTestingModule, {
122
- set: {
123
- entryComponents: [UnknownRenderer]
124
- }
125
- })
126
- .compileComponents();
127
-
128
- fixture = TestBed.createComponent(MasterListComponent);
129
- component = fixture.componentInstance;
130
- });
131
-
132
- it('should render', async(() => {
133
- setupMockStore(fixture, { uischema, schema, data });
134
- getJsonFormsService(component).updateCore(Actions.init(data, schema));
135
- component.ngOnInit();
136
-
137
- fixture.detectChanges();
138
- fixture.whenStable().then(() => {
139
- fixture.detectChanges();
140
- expect(component.masterItems.length).toBe(1);
141
- expect(
142
- fixture.debugElement.queryAll(By.directive(MatListItem)).length
143
- ).toBe(1);
144
- // the component is wrapped in a div
145
- expect(fixture.nativeElement.children[0].style.display).not.toBe('none');
146
- });
147
- }));
148
-
149
- it('add a master item', async(() => {
150
- setupMockStore(fixture, { uischema, schema, data });
151
- getJsonFormsService(component).updateCore(Actions.init(data, schema));
152
- component.ngOnInit();
153
- fixture.detectChanges();
154
-
155
- const spy = spyOn(component, 'addItem').and.returnValue(() => {
156
- /* noop */
157
- });
158
- fixture.whenStable().then(() => {
159
- const buttons: DebugElement[] = fixture.debugElement.queryAll(
160
- By.css('button')
161
- );
162
- buttons[1].nativeElement.click();
163
- fixture.detectChanges();
164
- fixture.whenRenderingDone().then(() => {
165
- fixture.detectChanges();
166
- expect(spy).toHaveBeenCalled();
167
- });
168
- });
169
- }));
170
-
171
- it('remove an item', async(() => {
172
- setupMockStore(fixture, { uischema, schema, data });
173
- getJsonFormsService(component).updateCore(Actions.init(data, schema));
174
- component.ngOnInit();
175
- fixture.detectChanges();
176
-
177
- const spy = spyOn(component, 'removeItems').and.returnValue(() => {
178
- /* noop */
179
- });
180
- fixture.whenStable().then(() => {
181
- const buttons: DebugElement[] = fixture.debugElement.queryAll(
182
- By.css('button')
183
- );
184
- buttons[0].nativeElement.click();
185
- fixture.whenStable().then(() => {
186
- fixture.detectChanges();
187
- expect(spy).toHaveBeenCalled();
188
- });
189
- });
190
- }));
191
-
192
- it('remove an item with index < selected index', () => {
193
- const moreData = {
194
- orders: [
195
- {
196
- customer: { name: 'Carrot Chipmunk' },
197
- title: 'Carrots'
198
- },
199
- {
200
- customer: { name: 'Banana Joe' },
201
- title: 'Bananas'
202
- },
203
- {
204
- customer: { name: 'Fry' },
205
- title: 'Slurm'
206
- }
207
- ]
208
- };
209
-
210
- setupMockStore(fixture, {
211
- uischema,
212
- schema,
213
- data: moreData
214
- });
215
- getJsonFormsService(component).updateCore(Actions.init(moreData, schema));
216
- component.ngOnInit();
217
- fixture.detectChanges();
218
-
219
- // select last element
220
- const listItems: DebugElement[] = fixture.debugElement.queryAll(
221
- By.directive(MatListItem)
222
- );
223
- listItems[2].nativeElement.click();
224
- fixture.detectChanges();
225
- expect(component.selectedItemIdx).toBe(2);
226
-
227
- // delete 1st item
228
- spyOn(component, 'removeItems').and.callFake(() => () => {
229
- getJsonFormsService(component).updateCore(Actions.update('orders', () => moreData.orders.slice(1)));
230
- fixture.detectChanges();
231
- });
232
- const buttons: DebugElement[] = fixture.debugElement.queryAll(
233
- By.css('button')
234
- );
235
- buttons[0].nativeElement.click();
236
-
237
- expect(component.selectedItemIdx).toBe(1);
238
- expect(component.selectedItem.data.title).toBe('Slurm');
239
- });
240
-
241
- it('remove an item with index > selected index', () => {
242
- const moreData = {
243
- orders: [
244
- {
245
- customer: { name: 'Carrot Chipmunk' },
246
- title: 'Carrots'
247
- },
248
- {
249
- customer: { name: 'Banana Joe' },
250
- title: 'Bananas'
251
- },
252
- {
253
- customer: { name: 'Fry' },
254
- title: 'Slurm'
255
- }
256
- ]
257
- };
258
- setupMockStore(fixture, {
259
- uischema,
260
- schema,
261
- data: moreData
262
- });
263
- getJsonFormsService(component).updateCore(Actions.init(moreData, schema));
264
- component.ngOnInit();
265
- fixture.detectChanges();
266
-
267
- // delete 2nd item
268
- spyOn(component, 'removeItems').and.callFake(() => () => {
269
- const copy = moreData.orders.slice();
270
- copy.splice(1, 1);
271
- getJsonFormsService(component).updateCore(Actions.update('orders', () => copy));
272
- fixture.detectChanges();
273
- });
274
- const buttons: DebugElement[] = fixture.debugElement.queryAll(
275
- By.css('button')
276
- );
277
- buttons[1].nativeElement.click();
278
-
279
- expect(component.selectedItemIdx).toBe(0);
280
- expect(component.selectedItem.data.title).toBe('Carrots');
281
- });
282
-
283
- it('remove an item with index == selected index', () => {
284
- const moreData = {
285
- orders: [
286
- {
287
- customer: { name: 'Carrot Chipmunk' },
288
- title: 'Carrots'
289
- },
290
- {
291
- customer: { name: 'Banana Joe' },
292
- title: 'Bananas'
293
- },
294
- {
295
- customer: { name: 'Fry' },
296
- title: 'Slurm'
297
- }
298
- ]
299
- };
300
- setupMockStore(fixture, {
301
- uischema,
302
- schema,
303
- data: moreData
304
- });
305
- getJsonFormsService(component).updateCore(Actions.init(moreData, schema));
306
- component.ngOnInit();
307
- fixture.detectChanges();
308
-
309
- // delete 1st item
310
- spyOn(component, 'removeItems').and.callFake(() => () => {
311
- getJsonFormsService(component).updateCore(Actions.update('orders', () => moreData.orders.slice(1)));
312
- fixture.detectChanges();
313
- });
314
- const buttons: DebugElement[] = fixture.debugElement.queryAll(
315
- By.css('button')
316
- );
317
- buttons[0].nativeElement.click();
318
-
319
- expect(component.selectedItemIdx).toBe(0);
320
- expect(component.selectedItem.data.title).toBe('Bananas');
321
- });
322
-
323
- it('remove last item', () => {
324
- const moreData = {
325
- orders: [
326
- {
327
- customer: { name: 'Carrot Chipmunk' },
328
- title: 'Carrots'
329
- }
330
- ]
331
- };
332
- setupMockStore(fixture, {
333
- uischema,
334
- schema,
335
- data: moreData
336
- });
337
- getJsonFormsService(component).updateCore(Actions.init(moreData, schema));
338
- component.ngOnInit();
339
- fixture.detectChanges();
340
-
341
- // delete item
342
- spyOn(component, 'removeItems').and.callFake(() => () => {
343
- getJsonFormsService(component).updateCore(Actions.update('orders', () => []));
344
- fixture.detectChanges();
345
- });
346
- const buttons: DebugElement[] = fixture.debugElement.queryAll(
347
- By.css('button')
348
- );
349
- buttons[0].nativeElement.click();
350
-
351
- expect(component.selectedItemIdx).toBe(-1);
352
- expect(component.selectedItem).toBe(undefined);
353
- });
354
-
355
- it('setting detail on click', async(() => {
356
- setupMockStore(fixture, { uischema, schema, data });
357
- getJsonFormsService(component).updateCore(Actions.init(data, schema));
358
- component.ngOnInit();
359
-
360
- fixture.detectChanges();
361
- fixture.whenStable().then(() => {
362
- spyOn(component, 'onSelect');
363
- const select = fixture.debugElement.query(By.directive(MatListItem))
364
- .nativeElement;
365
- select.click();
366
- fixture.detectChanges();
367
- fixture.whenStable().then(() => {
368
- fixture.detectChanges();
369
- expect(
370
- fixture.debugElement.queryAll(By.directive(JsonFormsDetailComponent))
371
- .length
372
- ).toBe(1);
373
- expect(component.onSelect).toHaveBeenCalledWith(
374
- {
375
- label: 'ACME',
376
- data: {
377
- customer: { name: 'ACME' },
378
- title: 'Carrots'
379
- },
380
- path: 'orders.0',
381
- schema: schema.definitions.order,
382
- uischema: {
383
- type: 'VerticalLayout',
384
- elements: [
385
- {
386
- type: 'Control',
387
- scope: '#/properties/customer/properties/name'
388
- }
389
- ]
390
- }
391
- },
392
- 0
393
- );
394
- });
395
- });
396
- }));
397
-
398
- it('can be hidden', async(() => {
399
- setupMockStore(fixture, { uischema, schema, data });
400
- getJsonFormsService(component).updateCore(Actions.init(data, schema));
401
- component.visible = false;
402
- component.ngOnInit();
403
- fixture.detectChanges();
404
- fixture.whenRenderingDone().then(() => {
405
- expect(fixture.nativeElement.children[0].style.display).toBe('none');
406
- });
407
- }));
408
- });