@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.
- package/lib/cjs/controls/autocomplete.renderer.d.ts +2 -2
- package/lib/cjs/other/master-detail/master.js +3 -0
- package/lib/cjs/other/master-detail/master.js.map +1 -1
- package/lib/cjs/other/master-detail/master.metadata.json +1 -1
- package/lib/esm/controls/autocomplete.renderer.d.ts +2 -2
- package/lib/esm/other/master-detail/master.js +4 -1
- package/lib/esm/other/master-detail/master.js.map +1 -1
- package/lib/esm/other/master-detail/master.metadata.json +1 -1
- package/package.json +23 -8
- package/src/controls/autocomplete.renderer.ts +2 -2
- package/src/layouts/layout.renderer.ts +2 -2
- package/src/other/master-detail/master.ts +5 -0
- package/docs/assets/css/main.css +0 -1
- package/docs/assets/images/icons.png +0 -0
- package/docs/assets/images/icons@2x.png +0 -0
- package/docs/assets/images/widgets.png +0 -0
- package/docs/assets/images/widgets@2x.png +0 -0
- package/docs/assets/js/main.js +0 -51
- package/docs/assets/js/search.json +0 -1
- package/docs/classes/arraylayoutrenderer.html +0 -1256
- package/docs/classes/autocompletecontrolrenderer.html +0 -887
- package/docs/classes/booleancontrolrenderer.html +0 -771
- package/docs/classes/categorizationtablayoutrenderer.html +0 -384
- package/docs/classes/datecontrolrenderer.html +0 -739
- package/docs/classes/grouplayoutrenderer.html +0 -396
- package/docs/classes/horizontallayoutrenderer.html +0 -396
- package/docs/classes/jsonformsangularmaterialmodule.html +0 -133
- package/docs/classes/jsonformsdetailcomponent.html +0 -227
- package/docs/classes/labelrenderer.html +0 -363
- package/docs/classes/layoutchildrenrenderpropspipe.html +0 -189
- package/docs/classes/layoutrenderer.html +0 -436
- package/docs/classes/masterlistcomponent.html +0 -1054
- package/docs/classes/numbercontrolrenderer.html +0 -893
- package/docs/classes/objectcontrolrenderer.html +0 -761
- package/docs/classes/rangecontrolrenderer.html +0 -792
- package/docs/classes/tablerenderer.html +0 -1222
- package/docs/classes/textarearenderer.html +0 -739
- package/docs/classes/textcontrolrenderer.html +0 -760
- package/docs/classes/togglecontrolrenderer.html +0 -771
- package/docs/classes/verticallayoutrenderer.html +0 -396
- package/docs/globals.html +0 -610
- package/docs/index.html +0 -378
- package/docs/interfaces/columndescription.html +0 -192
- package/docs/interfaces/ownpropsofautocomplete.html +0 -327
- package/example/app/app.component.ts +0 -122
- package/example/app/app.module.ts +0 -42
- package/example/index.html +0 -25
- package/example/main.ts +0 -37
- package/test/autocomplete-control.spec.ts +0 -322
- package/test/boolean-control.spec.ts +0 -76
- package/test/categorization-tab-layout.spec.ts +0 -330
- package/test/date-control.spec.ts +0 -280
- package/test/group-layout.spec.ts +0 -105
- package/test/horizontal-layout.spec.ts +0 -96
- package/test/label-renderer.spec.ts +0 -78
- package/test/master-detail.spec.ts +0 -408
- package/test/number-control.spec.ts +0 -208
- package/test/object-control.spec.ts +0 -247
- package/test/range-control.spec.ts +0 -104
- package/test/table-control.spec.ts +0 -369
- package/test/text-area.spec.ts +0 -108
- package/test/text-control.spec.ts +0 -89
- package/test/toggle-control.spec.ts +0 -77
- package/test/tsconfig.test.json +0 -18
- package/test/util.ts +0 -28
- package/test/vertical-layout.spec.ts +0 -115
- package/test-config/karma-test-shim.js +0 -21
- package/test-config/karma.conf.js +0 -58
- package/test-config/protractor.conf.js +0 -28
- package/test-config/webpack.test.js +0 -65
- package/tsconfig.cjs.json +0 -9
- package/tsconfig.json +0 -16
- package/webpack/webpack.build.js +0 -13
- package/webpack/webpack.dev.js +0 -37
|
@@ -1,330 +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 { DebugElement } from '@angular/core';
|
|
26
|
-
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
27
|
-
import {
|
|
28
|
-
MatTab,
|
|
29
|
-
MatTabBody,
|
|
30
|
-
MatTabGroup,
|
|
31
|
-
MatTabsModule
|
|
32
|
-
} from '@angular/material/tabs';
|
|
33
|
-
import { By } from '@angular/platform-browser';
|
|
34
|
-
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
|
35
|
-
import {
|
|
36
|
-
JsonFormsAngularService,
|
|
37
|
-
JsonFormsModule,
|
|
38
|
-
JsonFormsOutlet
|
|
39
|
-
} from '@jsonforms/angular';
|
|
40
|
-
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
|
|
41
|
-
import { CategorizationTabLayoutRenderer, TextControlRenderer, TextControlRendererTester } from '../src';
|
|
42
|
-
import { FlexLayoutModule } from '@angular/flex-layout';
|
|
43
|
-
import { setupMockStore, getJsonFormsService } from '@jsonforms/angular-test';
|
|
44
|
-
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
45
|
-
import { MatInputModule } from '@angular/material/input';
|
|
46
|
-
import { ReactiveFormsModule } from '@angular/forms';
|
|
47
|
-
import { CommonModule } from '@angular/common';
|
|
48
|
-
|
|
49
|
-
const renderers = [
|
|
50
|
-
{ tester: TextControlRendererTester, renderer: TextControlRenderer },
|
|
51
|
-
];
|
|
52
|
-
|
|
53
|
-
describe('Categorization tab layout', () => {
|
|
54
|
-
let fixture: ComponentFixture<any>;
|
|
55
|
-
let component: any;
|
|
56
|
-
|
|
57
|
-
const data = { foo: 'true' };
|
|
58
|
-
const schema = {
|
|
59
|
-
type: 'object',
|
|
60
|
-
properties: {
|
|
61
|
-
foo: {
|
|
62
|
-
type: 'string'
|
|
63
|
-
},
|
|
64
|
-
bar: {
|
|
65
|
-
type: 'string'
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
beforeEach(() => {
|
|
71
|
-
TestBed.configureTestingModule({
|
|
72
|
-
declarations: [
|
|
73
|
-
CategorizationTabLayoutRenderer,
|
|
74
|
-
TextControlRenderer
|
|
75
|
-
],
|
|
76
|
-
imports: [CommonModule, MatTabsModule, FlexLayoutModule, NoopAnimationsModule, JsonFormsModule,MatFormFieldModule,MatInputModule,ReactiveFormsModule,],
|
|
77
|
-
providers: [JsonFormsAngularService]
|
|
78
|
-
})
|
|
79
|
-
.overrideModule(BrowserDynamicTestingModule, {
|
|
80
|
-
set: {
|
|
81
|
-
entryComponents: [TextControlRenderer]
|
|
82
|
-
}
|
|
83
|
-
})
|
|
84
|
-
.compileComponents();
|
|
85
|
-
|
|
86
|
-
fixture = TestBed.createComponent(CategorizationTabLayoutRenderer);
|
|
87
|
-
component = fixture.componentInstance;
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('render categories initially', async(() => {
|
|
91
|
-
const uischema = {
|
|
92
|
-
type: 'Categorization',
|
|
93
|
-
elements: [
|
|
94
|
-
{
|
|
95
|
-
type: 'Category',
|
|
96
|
-
label: 'foo',
|
|
97
|
-
elements: [
|
|
98
|
-
{
|
|
99
|
-
type: 'Control',
|
|
100
|
-
scope: '#/properties/foo'
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
type: 'Control',
|
|
104
|
-
scope: '#/properties/bar'
|
|
105
|
-
}
|
|
106
|
-
]
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
type: 'Category',
|
|
110
|
-
label: 'bar',
|
|
111
|
-
elements: [
|
|
112
|
-
{
|
|
113
|
-
type: 'Control',
|
|
114
|
-
scope: '#/properties/bar'
|
|
115
|
-
}
|
|
116
|
-
]
|
|
117
|
-
}
|
|
118
|
-
]
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
setupMockStore(fixture, { uischema, schema, data });
|
|
122
|
-
|
|
123
|
-
fixture.detectChanges();
|
|
124
|
-
fixture.whenRenderingDone().then(() => {
|
|
125
|
-
fixture.detectChanges();
|
|
126
|
-
const tabGroupDE: DebugElement[] = fixture.debugElement.queryAll(
|
|
127
|
-
By.directive(MatTabGroup)
|
|
128
|
-
);
|
|
129
|
-
expect(tabGroupDE.length).toBe(1);
|
|
130
|
-
const tabGroup: MatTabGroup = tabGroupDE[0].componentInstance;
|
|
131
|
-
expect(tabGroup._tabs.length).toBe(2);
|
|
132
|
-
const tab1: MatTab = tabGroup._tabs.first;
|
|
133
|
-
const tab2: MatTab = tabGroup._tabs.last;
|
|
134
|
-
expect(tab1.isActive).toBeTruthy();
|
|
135
|
-
expect(tab2.isActive).toBeFalsy();
|
|
136
|
-
expect(tab1.textLabel).toBe('foo');
|
|
137
|
-
expect(tab2.textLabel).toBe('bar');
|
|
138
|
-
expect(tab1.isActive).toBeTruthy();
|
|
139
|
-
expect(tab2.isActive).toBeFalsy();
|
|
140
|
-
expect(tab1.content.isAttached).toBeTruthy();
|
|
141
|
-
expect(tab2.content.isAttached).toBeFalsy();
|
|
142
|
-
|
|
143
|
-
const contents: DebugElement[] = fixture.debugElement.queryAll(
|
|
144
|
-
By.directive(MatTabBody)
|
|
145
|
-
);
|
|
146
|
-
const activeTabOutlets = contents[0].queryAll(
|
|
147
|
-
By.directive(JsonFormsOutlet)
|
|
148
|
-
);
|
|
149
|
-
expect(activeTabOutlets.length).toBe(2);
|
|
150
|
-
|
|
151
|
-
expect(fixture.nativeElement.children[0].style.display).not.toBe('none');
|
|
152
|
-
});
|
|
153
|
-
}));
|
|
154
|
-
|
|
155
|
-
it('pass path and schema to children', async(() => {
|
|
156
|
-
const uischema = {
|
|
157
|
-
type: 'Categorization',
|
|
158
|
-
elements: [
|
|
159
|
-
{
|
|
160
|
-
type: 'Category',
|
|
161
|
-
label: 'foo',
|
|
162
|
-
elements: [
|
|
163
|
-
{
|
|
164
|
-
type: 'Control',
|
|
165
|
-
scope: '#/properties/foo'
|
|
166
|
-
},
|
|
167
|
-
]
|
|
168
|
-
}
|
|
169
|
-
]
|
|
170
|
-
};
|
|
171
|
-
setupMockStore(fixture, { uischema, schema, data });
|
|
172
|
-
component.path = 'aa';
|
|
173
|
-
const subSchema = {type: 'string'};
|
|
174
|
-
component.schema = subSchema;
|
|
175
|
-
getJsonFormsService(component).init({
|
|
176
|
-
|
|
177
|
-
renderers: renderers,
|
|
178
|
-
core: {
|
|
179
|
-
data: {},
|
|
180
|
-
schema: schema,
|
|
181
|
-
uischema: undefined
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
fixture.detectChanges();
|
|
187
|
-
fixture.whenRenderingDone().then(() => {
|
|
188
|
-
const contents: DebugElement[] = fixture.debugElement.queryAll(
|
|
189
|
-
By.directive(MatTabBody)
|
|
190
|
-
);
|
|
191
|
-
const activeTabOutlets = contents[0].queryAll(
|
|
192
|
-
By.directive(TextControlRenderer)
|
|
193
|
-
);
|
|
194
|
-
expect(activeTabOutlets[0].componentInstance.path).toBe('aa');
|
|
195
|
-
expect(activeTabOutlets[0].componentInstance.schema).toBe(subSchema);
|
|
196
|
-
});
|
|
197
|
-
}));
|
|
198
|
-
|
|
199
|
-
it('add category', async(() => {
|
|
200
|
-
const uischema = {
|
|
201
|
-
type: 'Categorization',
|
|
202
|
-
elements: [
|
|
203
|
-
{
|
|
204
|
-
type: 'Category',
|
|
205
|
-
label: 'foo',
|
|
206
|
-
elements: [
|
|
207
|
-
{
|
|
208
|
-
type: 'Control',
|
|
209
|
-
scope: '#/properties/foo'
|
|
210
|
-
},
|
|
211
|
-
{
|
|
212
|
-
type: 'Control',
|
|
213
|
-
scope: '#/properties/bar'
|
|
214
|
-
}
|
|
215
|
-
]
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
type: 'Category',
|
|
219
|
-
label: 'bar',
|
|
220
|
-
elements: [
|
|
221
|
-
{
|
|
222
|
-
type: 'Control',
|
|
223
|
-
scope: '#/properties/bar'
|
|
224
|
-
}
|
|
225
|
-
]
|
|
226
|
-
}
|
|
227
|
-
]
|
|
228
|
-
};
|
|
229
|
-
setupMockStore(fixture, { uischema, schema, data });
|
|
230
|
-
fixture.detectChanges();
|
|
231
|
-
fixture.whenRenderingDone().then(() => {
|
|
232
|
-
fixture.detectChanges();
|
|
233
|
-
const tabGroupDE: DebugElement[] = fixture.debugElement.queryAll(
|
|
234
|
-
By.directive(MatTabGroup)
|
|
235
|
-
);
|
|
236
|
-
const tabGroup: MatTabGroup = tabGroupDE[0].componentInstance;
|
|
237
|
-
expect(tabGroup._tabs.length).toBe(2);
|
|
238
|
-
|
|
239
|
-
const newUischema = {
|
|
240
|
-
type: 'Categorization',
|
|
241
|
-
elements: [
|
|
242
|
-
{
|
|
243
|
-
type: 'Category',
|
|
244
|
-
label: 'foo',
|
|
245
|
-
elements: [
|
|
246
|
-
{
|
|
247
|
-
type: 'Control',
|
|
248
|
-
scope: '#/properties/foo'
|
|
249
|
-
}
|
|
250
|
-
]
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
type: 'Category',
|
|
254
|
-
label: 'bar',
|
|
255
|
-
elements: [
|
|
256
|
-
{
|
|
257
|
-
type: 'Control',
|
|
258
|
-
scope: '#/properties/bar'
|
|
259
|
-
}
|
|
260
|
-
]
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
type: 'Category',
|
|
264
|
-
label: 'quux',
|
|
265
|
-
elements: [
|
|
266
|
-
{
|
|
267
|
-
type: 'Control',
|
|
268
|
-
scope: '#/properties/bar'
|
|
269
|
-
}
|
|
270
|
-
]
|
|
271
|
-
}
|
|
272
|
-
]
|
|
273
|
-
};
|
|
274
|
-
component.uischema = newUischema;
|
|
275
|
-
fixture.detectChanges();
|
|
276
|
-
getJsonFormsService(component).setUiSchema(newUischema);
|
|
277
|
-
|
|
278
|
-
fixture.whenRenderingDone().then(() => {
|
|
279
|
-
fixture.detectChanges();
|
|
280
|
-
const tabGroupDE2: DebugElement[] = fixture.debugElement.queryAll(
|
|
281
|
-
By.directive(MatTabGroup)
|
|
282
|
-
);
|
|
283
|
-
const tabGroup2: MatTabGroup = tabGroupDE2[0].componentInstance;
|
|
284
|
-
expect(tabGroup2._tabs.length).toBe(3);
|
|
285
|
-
const lastTab: MatTab = tabGroup2._tabs.last;
|
|
286
|
-
expect(lastTab.isActive).toBeFalsy();
|
|
287
|
-
expect(lastTab.textLabel).toBe('quux');
|
|
288
|
-
});
|
|
289
|
-
});
|
|
290
|
-
}));
|
|
291
|
-
|
|
292
|
-
// TODO: broken due to https://github.com/angular/flex-layout/issues/848
|
|
293
|
-
xit('can be hidden', async(() => {
|
|
294
|
-
const uischema = {
|
|
295
|
-
type: 'Categorization',
|
|
296
|
-
elements: [
|
|
297
|
-
{
|
|
298
|
-
type: 'Category',
|
|
299
|
-
label: 'foo',
|
|
300
|
-
elements: [
|
|
301
|
-
{
|
|
302
|
-
type: 'Control',
|
|
303
|
-
scope: '#/properties/foo'
|
|
304
|
-
},
|
|
305
|
-
{
|
|
306
|
-
type: 'Control',
|
|
307
|
-
scope: '#/properties/bar'
|
|
308
|
-
}
|
|
309
|
-
]
|
|
310
|
-
},
|
|
311
|
-
{
|
|
312
|
-
type: 'Category',
|
|
313
|
-
label: 'bar',
|
|
314
|
-
elements: [
|
|
315
|
-
{
|
|
316
|
-
type: 'Control',
|
|
317
|
-
scope: '#/properties/bar'
|
|
318
|
-
}
|
|
319
|
-
]
|
|
320
|
-
}
|
|
321
|
-
]
|
|
322
|
-
};
|
|
323
|
-
setupMockStore(fixture, { uischema, schema, data });
|
|
324
|
-
component.visible = false;
|
|
325
|
-
fixture.detectChanges();
|
|
326
|
-
fixture.whenRenderingDone().then(() => {
|
|
327
|
-
expect(fixture.nativeElement.children[0].style.display).toBe('none');
|
|
328
|
-
});
|
|
329
|
-
}));
|
|
330
|
-
});
|
|
@@ -1,280 +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 { DebugElement } from '@angular/core';
|
|
26
|
-
import {
|
|
27
|
-
ComponentFixture,
|
|
28
|
-
fakeAsync,
|
|
29
|
-
flush,
|
|
30
|
-
TestBed
|
|
31
|
-
} from '@angular/core/testing';
|
|
32
|
-
import { ReactiveFormsModule } from '@angular/forms';
|
|
33
|
-
import { MatNativeDateModule } from '@angular/material/core'
|
|
34
|
-
import { MatDatepicker, MatDatepickerModule } from '@angular/material/datepicker';
|
|
35
|
-
import { MatError, MatFormFieldModule } from '@angular/material/form-field';
|
|
36
|
-
import { MatInputModule } from '@angular/material/input';
|
|
37
|
-
import { By } from '@angular/platform-browser';
|
|
38
|
-
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
|
39
|
-
import { ErrorTestExpectation, getJsonFormsService, setupMockStore } from '@jsonforms/angular-test';
|
|
40
|
-
import { Actions, ControlElement, JsonSchema } from '@jsonforms/core';
|
|
41
|
-
import { DateControlRenderer, DateControlRendererTester } from '../src';
|
|
42
|
-
import { FlexLayoutModule } from '@angular/flex-layout';
|
|
43
|
-
import { JsonFormsAngularService } from '@jsonforms/angular';
|
|
44
|
-
import { createTesterContext } from './util';
|
|
45
|
-
|
|
46
|
-
const data = { foo: '2018-01-01' };
|
|
47
|
-
const schema: JsonSchema = {
|
|
48
|
-
type: 'object',
|
|
49
|
-
properties: {
|
|
50
|
-
foo: {
|
|
51
|
-
type: 'string',
|
|
52
|
-
format: 'date'
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
const uischema: ControlElement = {
|
|
57
|
-
type: 'Control',
|
|
58
|
-
scope: '#/properties/foo'
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
describe('Material boolean field tester', () => {
|
|
62
|
-
it('should succeed', () => {
|
|
63
|
-
expect(DateControlRendererTester(uischema, schema, createTesterContext(schema))).toBe(2);
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
const imports = [
|
|
67
|
-
MatDatepickerModule,
|
|
68
|
-
MatInputModule,
|
|
69
|
-
MatNativeDateModule,
|
|
70
|
-
MatFormFieldModule,
|
|
71
|
-
NoopAnimationsModule,
|
|
72
|
-
ReactiveFormsModule,
|
|
73
|
-
FlexLayoutModule
|
|
74
|
-
];
|
|
75
|
-
const providers = [JsonFormsAngularService];
|
|
76
|
-
const componentUT: any = DateControlRenderer;
|
|
77
|
-
const errorTest: ErrorTestExpectation = {
|
|
78
|
-
errorInstance: MatError,
|
|
79
|
-
numberOfElements: 1,
|
|
80
|
-
indexOfElement: 0
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
describe('Date control Base Tests', () => {
|
|
84
|
-
let fixture: ComponentFixture<DateControlRenderer>;
|
|
85
|
-
let component: DateControlRenderer;
|
|
86
|
-
let inputElement: HTMLInputElement;
|
|
87
|
-
beforeEach(() => {
|
|
88
|
-
TestBed.configureTestingModule({
|
|
89
|
-
declarations: [componentUT],
|
|
90
|
-
imports: imports,
|
|
91
|
-
providers: providers
|
|
92
|
-
}).compileComponents();
|
|
93
|
-
|
|
94
|
-
});
|
|
95
|
-
beforeEach(() => {
|
|
96
|
-
fixture = TestBed.createComponent(componentUT);
|
|
97
|
-
component = fixture.componentInstance;
|
|
98
|
-
|
|
99
|
-
inputElement = fixture.debugElement.query(By.css('input')).nativeElement;
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('should render', () => {
|
|
103
|
-
setupMockStore(fixture, { uischema, schema, data });
|
|
104
|
-
getJsonFormsService(component).updateCore(Actions.init(data, schema, uischema));
|
|
105
|
-
component.ngOnInit();
|
|
106
|
-
fixture.detectChanges();
|
|
107
|
-
expect(component.data).toBe('2018-01-01');
|
|
108
|
-
// auto? shown with US layout
|
|
109
|
-
expect(inputElement.value).toBe('1/1/2018');
|
|
110
|
-
expect(inputElement.disabled).toBe(false);
|
|
111
|
-
// the component is wrapped in a div
|
|
112
|
-
expect(fixture.nativeElement.children[0].style.display).not.toBe('none');
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it('should support updating the state', () => {
|
|
116
|
-
setupMockStore(fixture, { uischema, schema, data });
|
|
117
|
-
getJsonFormsService(component).updateCore(Actions.init(data, schema, uischema));
|
|
118
|
-
component.ngOnInit();
|
|
119
|
-
fixture.detectChanges();
|
|
120
|
-
|
|
121
|
-
getJsonFormsService(component).updateCore(Actions.update('foo', () => '2018-03-03'));
|
|
122
|
-
fixture.detectChanges();
|
|
123
|
-
expect(component.data).toBe('2018-03-03');
|
|
124
|
-
expect(inputElement.value).toBe('3/3/2018');
|
|
125
|
-
});
|
|
126
|
-
it('should update with undefined value', () => {
|
|
127
|
-
setupMockStore(fixture, { uischema, schema, data });
|
|
128
|
-
getJsonFormsService(component).updateCore(Actions.init(data, schema, uischema));
|
|
129
|
-
component.ngOnInit();
|
|
130
|
-
fixture.detectChanges();
|
|
131
|
-
|
|
132
|
-
getJsonFormsService(component).updateCore(Actions.update('foo', () => undefined));
|
|
133
|
-
fixture.detectChanges();
|
|
134
|
-
expect(component.data).toBe(undefined);
|
|
135
|
-
expect(inputElement.value).toBe('');
|
|
136
|
-
});
|
|
137
|
-
it('should update with null value', () => {
|
|
138
|
-
setupMockStore(fixture, { uischema, schema, data });
|
|
139
|
-
getJsonFormsService(component).updateCore(Actions.init(data, schema, uischema));
|
|
140
|
-
component.ngOnInit();
|
|
141
|
-
fixture.detectChanges();
|
|
142
|
-
|
|
143
|
-
getJsonFormsService(component).updateCore(Actions.update('foo', () => null));
|
|
144
|
-
fixture.detectChanges();
|
|
145
|
-
expect(component.data).toBe(null);
|
|
146
|
-
expect(inputElement.value).toBe('');
|
|
147
|
-
});
|
|
148
|
-
it('should not update with wrong ref', () => {
|
|
149
|
-
setupMockStore(fixture, { uischema, schema, data });
|
|
150
|
-
getJsonFormsService(component).updateCore(Actions.init(data, schema, uischema));
|
|
151
|
-
component.ngOnInit();
|
|
152
|
-
fixture.detectChanges();
|
|
153
|
-
|
|
154
|
-
getJsonFormsService(component).updateCore(Actions.update('foo', () => '2018-01-01'));
|
|
155
|
-
getJsonFormsService(component).updateCore(Actions.update('bar', () => '2018-03-03'));
|
|
156
|
-
fixture.detectChanges();
|
|
157
|
-
expect(component.data).toBe('2018-01-01');
|
|
158
|
-
expect(inputElement.value).toBe('1/1/2018');
|
|
159
|
-
});
|
|
160
|
-
// store needed as we evaluate the calculated enabled value to disable/enable the control
|
|
161
|
-
it('can be disabled', () => {
|
|
162
|
-
setupMockStore(fixture, { uischema, schema, data });
|
|
163
|
-
component.disabled = true;
|
|
164
|
-
getJsonFormsService(component).updateCore(Actions.init(data, schema, uischema));
|
|
165
|
-
|
|
166
|
-
component.ngOnInit();
|
|
167
|
-
fixture.detectChanges();
|
|
168
|
-
expect(inputElement.disabled).toBe(true);
|
|
169
|
-
});
|
|
170
|
-
// store needed as we evaluate the calculated enabled value to disable/enable the control
|
|
171
|
-
it('can be hidden', () => {
|
|
172
|
-
setupMockStore(fixture, { uischema, schema, data });
|
|
173
|
-
component.visible = false;
|
|
174
|
-
getJsonFormsService(component).updateCore(Actions.init(data, schema, uischema));
|
|
175
|
-
|
|
176
|
-
component.ngOnInit();
|
|
177
|
-
fixture.detectChanges();
|
|
178
|
-
// the component is wrapped in a div
|
|
179
|
-
expect(fixture.nativeElement.children[0].style.display).toBe('none');
|
|
180
|
-
});
|
|
181
|
-
it('id should be present in output', () => {
|
|
182
|
-
component.uischema = uischema;
|
|
183
|
-
component.id = 'myId';
|
|
184
|
-
getJsonFormsService(component).init(
|
|
185
|
-
{core: {data: data, schema: schema, uischema: uischema}}
|
|
186
|
-
);
|
|
187
|
-
|
|
188
|
-
component.ngOnInit();
|
|
189
|
-
fixture.detectChanges();
|
|
190
|
-
expect(inputElement.id).toBe('myId');
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
describe('Date control Input Event Tests', () => {
|
|
194
|
-
let fixture: ComponentFixture<DateControlRenderer>;
|
|
195
|
-
let component: DateControlRenderer;
|
|
196
|
-
let inputElement: HTMLInputElement;
|
|
197
|
-
beforeEach(() => {
|
|
198
|
-
TestBed.configureTestingModule({
|
|
199
|
-
declarations: [componentUT],
|
|
200
|
-
imports: imports,
|
|
201
|
-
providers: providers
|
|
202
|
-
}).compileComponents();
|
|
203
|
-
});
|
|
204
|
-
beforeEach(() => {
|
|
205
|
-
fixture = TestBed.createComponent(componentUT);
|
|
206
|
-
component = fixture.componentInstance;
|
|
207
|
-
|
|
208
|
-
inputElement = fixture.debugElement.query(By.css('input')).nativeElement;
|
|
209
|
-
});
|
|
210
|
-
it('should update via input event', fakeAsync(() => {
|
|
211
|
-
setupMockStore(fixture, { uischema, schema, data });
|
|
212
|
-
getJsonFormsService(component).updateCore(Actions.init(data, schema, uischema));
|
|
213
|
-
component.ngOnInit();
|
|
214
|
-
fixture.detectChanges();
|
|
215
|
-
|
|
216
|
-
const spy = spyOn(component, 'onChange');
|
|
217
|
-
|
|
218
|
-
fixture.debugElement
|
|
219
|
-
.query(By.directive(MatDatepicker))
|
|
220
|
-
.componentInstance.open();
|
|
221
|
-
fixture.detectChanges();
|
|
222
|
-
flush();
|
|
223
|
-
|
|
224
|
-
const cells = document.querySelectorAll('.mat-calendar-body-cell');
|
|
225
|
-
const firstCell: HTMLElement = cells[1] as HTMLElement;
|
|
226
|
-
firstCell.click();
|
|
227
|
-
fixture.detectChanges();
|
|
228
|
-
flush();
|
|
229
|
-
|
|
230
|
-
inputElement.dispatchEvent(new Event('change'));
|
|
231
|
-
// trigger change detection
|
|
232
|
-
fixture.detectChanges();
|
|
233
|
-
expect(spy).toHaveBeenCalled();
|
|
234
|
-
expect(inputElement.value).toBe('1/2/2018');
|
|
235
|
-
}));
|
|
236
|
-
});
|
|
237
|
-
describe('Date control Error Tests', () => {
|
|
238
|
-
let fixture: ComponentFixture<DateControlRenderer>;
|
|
239
|
-
let component: DateControlRenderer;
|
|
240
|
-
beforeEach(() => {
|
|
241
|
-
TestBed.configureTestingModule({
|
|
242
|
-
declarations: [componentUT],
|
|
243
|
-
imports: imports,
|
|
244
|
-
providers: providers
|
|
245
|
-
}).compileComponents();
|
|
246
|
-
|
|
247
|
-
});
|
|
248
|
-
beforeEach(() => {
|
|
249
|
-
fixture = TestBed.createComponent(componentUT);
|
|
250
|
-
component = fixture.componentInstance;
|
|
251
|
-
});
|
|
252
|
-
it('should display errors', () => {
|
|
253
|
-
setupMockStore(fixture, {
|
|
254
|
-
uischema,
|
|
255
|
-
schema,
|
|
256
|
-
data
|
|
257
|
-
});
|
|
258
|
-
const formsService = getJsonFormsService(component);
|
|
259
|
-
formsService.updateCore(Actions.updateErrors([
|
|
260
|
-
{
|
|
261
|
-
instancePath: '/foo',
|
|
262
|
-
message: 'Hi, this is me, test error!',
|
|
263
|
-
params: {},
|
|
264
|
-
keyword: '',
|
|
265
|
-
schemaPath: ''
|
|
266
|
-
}
|
|
267
|
-
]));
|
|
268
|
-
formsService.refresh();
|
|
269
|
-
|
|
270
|
-
component.ngOnInit();
|
|
271
|
-
fixture.detectChanges();
|
|
272
|
-
const debugErrors: DebugElement[] = fixture.debugElement.queryAll(
|
|
273
|
-
By.directive(errorTest.errorInstance)
|
|
274
|
-
);
|
|
275
|
-
expect(debugErrors.length).toBe(errorTest.numberOfElements);
|
|
276
|
-
expect(
|
|
277
|
-
debugErrors[errorTest.indexOfElement].nativeElement.textContent
|
|
278
|
-
).toBe('Hi, this is me, test error!');
|
|
279
|
-
});
|
|
280
|
-
});
|