imng-kendo-schematics 6.233.2 → 7.209.3
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/package.json +1 -1
- package/schematics/imng-crud/files/add.component.spec.ts.template +5 -5
- package/schematics/imng-crud/files/crud.facade.spec.ts.template +1 -1
- package/schematics/imng-crud/files/edit.component.spec.ts.template +5 -5
- package/schematics/imng-list/files/list.component.spec.ts.template +13 -9
- package/schematics/imng-list/files/list.facade.spec.ts.template +4 -4
- package/schematics/imng-module/files/+state/__singularizedName@dasherize__.effects.ts.template +2 -1
- package/schematics/imng-module/files/__pluralizedName@dasherize__.routing.ts.template +2 -2
- package/schematics/imng-sub-list/files/__pluralizedName@dasherize__-list/list.component.spec.ts.template +5 -5
- package/schematics/imng-sub-list/files/__pluralizedName@dasherize__-list/list.facade.spec.ts.template +4 -4
package/package.json
CHANGED
|
@@ -68,8 +68,8 @@ describe('<%= classify(name) %>AddComponent', () => {
|
|
|
68
68
|
facade.updateExistingEntity = jest.fn();
|
|
69
69
|
expect(component.getFormErrors()).toStrictEqual([]);
|
|
70
70
|
component.onSubmit();
|
|
71
|
-
expect(facade.saveNewEntity).
|
|
72
|
-
expect(facade.updateExistingEntity).
|
|
71
|
+
expect(facade.saveNewEntity).toHaveBeenCalledTimes(1);
|
|
72
|
+
expect(facade.updateExistingEntity).toHaveBeenCalledTimes(0);
|
|
73
73
|
<% if (hasDates) { %>
|
|
74
74
|
expect(item).toMatchSnapshot({
|
|
75
75
|
<% swaggerProperties.filter(t=> t.format === 'date-time' || t.format === 'date').forEach(function(swaggerProperty)
|
|
@@ -87,15 +87,15 @@ describe('<%= classify(name) %>AddComponent', () => {
|
|
|
87
87
|
const consoleErrorMock = mockConsoleError();
|
|
88
88
|
component.addEditForm?.patchValue({});
|
|
89
89
|
component.onSubmit();
|
|
90
|
-
expect(facade.saveNewEntity).
|
|
91
|
-
expect(facade.updateExistingEntity).
|
|
90
|
+
expect(facade.saveNewEntity).toHaveBeenCalledTimes(0);
|
|
91
|
+
expect(facade.updateExistingEntity).toHaveBeenCalledTimes(0);
|
|
92
92
|
consoleErrorMock.mockRestore();
|
|
93
93
|
});
|
|
94
94
|
|
|
95
95
|
test('should cancel', () => {
|
|
96
96
|
facade.clearCurrentEntity = jest.fn();
|
|
97
97
|
component.cancel();
|
|
98
|
-
expect(facade.clearCurrentEntity).
|
|
98
|
+
expect(facade.clearCurrentEntity).toHaveBeenCalledTimes(1);
|
|
99
99
|
});<% swaggerObjectProperties.filter(t=> !t.enum).forEach(function(swaggerProperty){ %>
|
|
100
100
|
|
|
101
101
|
test('should support <%= classify(swaggerProperty.name) %> filters', async () => {
|
|
@@ -80,7 +80,7 @@ describe('<%= classify(name) %>CrudFacade', () => {
|
|
|
80
80
|
|
|
81
81
|
test('should load <%= classify(swaggerProperty.pluralizedName) %>', async () => {
|
|
82
82
|
facade.load<%= classify(swaggerProperty.pluralizedName) %>({});
|
|
83
|
-
expect(httpClient.get).
|
|
83
|
+
expect(httpClient.get).toHaveBeenCalledTimes(1);
|
|
84
84
|
const result = await readFirst(facade.<%= camelize(swaggerProperty.pluralizedName) %>$);
|
|
85
85
|
expect(result.length).toBe(1);
|
|
86
86
|
});<% }); %>
|
|
@@ -50,8 +50,8 @@ describe('<%= classify(name) %>EditComponent', () => {
|
|
|
50
50
|
facade.updateExistingEntity = jest.fn(x => (item = x));
|
|
51
51
|
expect(component.getFormErrors()).toStrictEqual([]);
|
|
52
52
|
component.onSubmit();
|
|
53
|
-
expect(facade.saveNewEntity).
|
|
54
|
-
expect(facade.updateExistingEntity).
|
|
53
|
+
expect(facade.saveNewEntity).toHaveBeenCalledTimes(0);
|
|
54
|
+
expect(facade.updateExistingEntity).toHaveBeenCalledTimes(1);
|
|
55
55
|
<% if (hasDates) { %>
|
|
56
56
|
expect(item).toMatchSnapshot({
|
|
57
57
|
<% swaggerProperties.filter(t=> t.format === 'date-time' || t.format === 'date').forEach(function(swaggerProperty)
|
|
@@ -70,14 +70,14 @@ describe('<%= classify(name) %>EditComponent', () => {
|
|
|
70
70
|
const consoleErrorMock = mockConsoleError();
|
|
71
71
|
component.addEditForm?.patchValue({});
|
|
72
72
|
component.onSubmit();
|
|
73
|
-
expect(facade.saveNewEntity).
|
|
74
|
-
expect(facade.updateExistingEntity).
|
|
73
|
+
expect(facade.saveNewEntity).toHaveBeenCalledTimes(0);
|
|
74
|
+
expect(facade.updateExistingEntity).toHaveBeenCalledTimes(0);
|
|
75
75
|
consoleErrorMock.mockRestore();
|
|
76
76
|
});
|
|
77
77
|
|
|
78
78
|
test('should cancel', () => {
|
|
79
79
|
component.cancel();
|
|
80
|
-
expect(facade.clearCurrentEntity).
|
|
80
|
+
expect(facade.clearCurrentEntity).toHaveBeenCalledTimes(1);
|
|
81
81
|
});<% swaggerObjectProperties.filter(t=> !t.enum).forEach(function(swaggerProperty){ %>
|
|
82
82
|
|
|
83
83
|
test('should support <%= classify(swaggerProperty.name) %> filters', async () => {
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from '@angular/core';
|
|
2
2
|
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
3
|
-
import {
|
|
3
|
+
import { provideRouter } from '@angular/router';
|
|
4
4
|
import { createDataEntryMockFacade, createDataDeleteMockFacade } from 'imng-kendo-data-entry/testing';
|
|
5
5
|
import { createODataGridMockFacade } from 'imng-kendo-grid-odata/testing';
|
|
6
|
+
import { provideOidcMockFacade } from 'imng-oidc-client/testing';
|
|
6
7
|
|
|
7
8
|
import { <%= classify(singularizedName) %>ListComponent } from './list.component';
|
|
8
9
|
import { <%= classify(singularizedName) %>ListFacade } from './list.facade';
|
|
9
10
|
import { <%= classify(singularizedName) %>CrudFacade } from '../<%= dasherize(pluralizedName) %>-crud';
|
|
11
|
+
import { <%= camelize(singularizedName) %>Routes } from '../<%= dasherize(pluralizedName) %>.routing';
|
|
10
12
|
|
|
11
13
|
describe('<%= classify(singularizedName) %>ListComponent', () => {
|
|
12
14
|
let component: <%= classify(singularizedName) %>ListComponent;
|
|
@@ -17,10 +19,12 @@ describe('<%= classify(singularizedName) %>ListComponent', () => {
|
|
|
17
19
|
beforeEach(waitForAsync(() => {
|
|
18
20
|
TestBed.configureTestingModule({
|
|
19
21
|
declarations: [<%= classify(singularizedName) %>ListComponent],
|
|
20
|
-
imports: [
|
|
22
|
+
imports: [],
|
|
21
23
|
providers: [
|
|
22
24
|
{ provide: <%= classify(singularizedName) %>ListFacade, useValue: createODataGridMockFacade(createDataDeleteMockFacade()) },
|
|
23
25
|
{ provide: <%= classify(singularizedName) %>CrudFacade, useValue: createDataEntryMockFacade() },
|
|
26
|
+
provideRouter(<%= camelize(singularizedName) %>Routes),
|
|
27
|
+
provideOidcMockFacade(),
|
|
24
28
|
],
|
|
25
29
|
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA]
|
|
26
30
|
}).compileComponents();
|
|
@@ -50,26 +54,26 @@ describe('<%= classify(singularizedName) %>ListComponent', () => {
|
|
|
50
54
|
|
|
51
55
|
test('it should handle reload', () => {
|
|
52
56
|
component.reloadEntities();
|
|
53
|
-
expect(listFacade.reloadEntities).
|
|
57
|
+
expect(listFacade.reloadEntities).toHaveBeenCalledTimes(1);
|
|
54
58
|
});
|
|
55
59
|
|
|
56
60
|
test('it should handle AddItem', () => {
|
|
57
61
|
component.addItem();
|
|
58
|
-
expect(crudFacade.setCurrentEntity).
|
|
59
|
-
expect(crudFacade.setCurrentEntity).
|
|
62
|
+
expect(crudFacade.setCurrentEntity).toHaveBeenCalledTimes(1);
|
|
63
|
+
expect(crudFacade.setCurrentEntity).toHaveBeenCalledWith({});
|
|
60
64
|
});
|
|
61
65
|
|
|
62
66
|
test('it should handle EditItem', () => {
|
|
63
67
|
const item = createTest<%= classify(singularizedName) %>();
|
|
64
68
|
component.editItem(item);
|
|
65
|
-
expect(crudFacade.setCurrentEntity).
|
|
66
|
-
expect(crudFacade.setCurrentEntity).
|
|
69
|
+
expect(crudFacade.setCurrentEntity).toHaveBeenCalledTimes(1);
|
|
70
|
+
expect(crudFacade.setCurrentEntity).toHaveBeenCalledWith(item);
|
|
67
71
|
});
|
|
68
72
|
|
|
69
73
|
test('it should handle DeleteItem', () => {
|
|
70
74
|
const item = createTest<%= classify(singularizedName) %>();
|
|
71
75
|
component.deleteItem(item);
|
|
72
|
-
expect(listFacade.deleteExistingEntity).
|
|
73
|
-
expect(listFacade.deleteExistingEntity).
|
|
76
|
+
expect(listFacade.deleteExistingEntity).toHaveBeenCalledTimes(1);
|
|
77
|
+
expect(listFacade.deleteExistingEntity).toHaveBeenCalledWith(item);
|
|
74
78
|
});
|
|
75
79
|
});
|
|
@@ -63,11 +63,11 @@ describe('<%= classify(singularizedName) %>ListFacade', () => {
|
|
|
63
63
|
const loading = await readFirst(facade.loading$);
|
|
64
64
|
expect(list?.data.length).toBe(1);
|
|
65
65
|
expect(loading).toBe(false);
|
|
66
|
-
expect(httpClient.get).
|
|
67
|
-
expect(httpClient.get).
|
|
66
|
+
expect(httpClient.get).toHaveBeenCalledTimes(1);
|
|
67
|
+
expect(httpClient.get).toHaveBeenCalledWith('<%= dasherize(pluralizedStoreName) %>-odata/odata/v1/<%= classify(pluralizedName) %>?&$count=true');
|
|
68
68
|
|
|
69
69
|
facade.reloadEntities();
|
|
70
|
-
expect(httpClient.get).
|
|
70
|
+
expect(httpClient.get).toHaveBeenCalledTimes(2);
|
|
71
71
|
});
|
|
72
72
|
|
|
73
73
|
test('reloadEntities() should return empty list with loaded == true', async () => {
|
|
@@ -87,7 +87,7 @@ describe('<%= classify(singularizedName) %>ListFacade', () => {
|
|
|
87
87
|
|
|
88
88
|
expect(list?.data.length).toBe(3);
|
|
89
89
|
expect(isloading).toBe(false);
|
|
90
|
-
expect(service.fetch).
|
|
90
|
+
expect(service.fetch).toHaveBeenCalledTimes(1);
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
test('it should get the grid state', async () => {
|
package/schematics/imng-module/files/+state/__singularizedName@dasherize__.effects.ts.template
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Injectable } from '@angular/core';
|
|
2
2
|
import { Store } from '@ngrx/store';
|
|
3
|
-
import { createEffect, Actions, ofType
|
|
3
|
+
import { createEffect, Actions, ofType } from '@ngrx/effects';
|
|
4
|
+
import { concatLatestFrom } from '@ngrx/operators';
|
|
4
5
|
import { ODataService } from 'imng-kendo-odata';
|
|
5
6
|
import { handleEffectError } from 'imng-ngrx-utils';
|
|
6
7
|
import { map, switchMap } from 'rxjs/operators';
|
|
@@ -4,12 +4,12 @@ import { AuthGuard } from 'imng-oidc-client';<% if (openApiJsonUrl || openApiJso
|
|
|
4
4
|
import { <%= classify(singularizedName) %>ListComponent } from './<%= dasherize(pluralizedName) %>-list';
|
|
5
5
|
<% } %>
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
export const <%= camelize(singularizedName) %>Routes: Routes = [
|
|
8
8
|
{ path: '', component: <% if (openApiJsonUrl || openApiJsonFileName) { %><%= classify(singularizedName) %>ListComponent<% } %>, canActivate: [AuthGuard] }
|
|
9
9
|
];
|
|
10
10
|
|
|
11
11
|
@NgModule({
|
|
12
|
-
imports: [RouterModule.forChild(
|
|
12
|
+
imports: [RouterModule.forChild(<%= camelize(singularizedName) %>Routes)],
|
|
13
13
|
exports: [RouterModule]
|
|
14
14
|
})
|
|
15
15
|
export class <%= classify(pluralizedName) %>RoutingModule { }
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from '@angular/core';
|
|
2
2
|
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
3
|
-
import { RouterTestingModule } from '@angular/router/testing';
|
|
4
3
|
import { createDataDeleteMockFacade } from 'imng-kendo-data-entry/testing';
|
|
5
4
|
import { createODataGridMockFacade } from 'imng-kendo-grid-odata/testing';
|
|
6
5
|
|
|
7
6
|
import { <%= classify(singularizedName) %>ListComponent } from './list.component';
|
|
8
7
|
import { <%= classify(singularizedName) %>ListFacade } from './list.facade';
|
|
9
8
|
|
|
9
|
+
|
|
10
10
|
describe('<%= classify(singularizedName) %>ListComponent', () => {
|
|
11
11
|
let component: <%= classify(singularizedName) %>ListComponent;
|
|
12
12
|
let fixture: ComponentFixture<<%= classify(singularizedName) %>ListComponent>;
|
|
@@ -15,7 +15,7 @@ describe('<%= classify(singularizedName) %>ListComponent', () => {
|
|
|
15
15
|
beforeEach(waitForAsync(() => {
|
|
16
16
|
TestBed.configureTestingModule({
|
|
17
17
|
declarations: [<%= classify(singularizedName) %>ListComponent],
|
|
18
|
-
imports: [
|
|
18
|
+
imports: [],
|
|
19
19
|
providers: [
|
|
20
20
|
{ provide: <%= classify(singularizedName) %>ListFacade, useValue: createODataGridMockFacade(createDataDeleteMockFacade()) },
|
|
21
21
|
],
|
|
@@ -41,13 +41,13 @@ describe('<%= classify(singularizedName) %>ListComponent', () => {
|
|
|
41
41
|
|
|
42
42
|
test('it should handle reload', () => {
|
|
43
43
|
component.reloadEntities();
|
|
44
|
-
expect(listFacade.reloadEntities).
|
|
44
|
+
expect(listFacade.reloadEntities).toHaveBeenCalledTimes(1);
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
test('it should handle DeleteItem', () => {
|
|
48
48
|
const item = createTest<%= classify(singularizedName) %>();
|
|
49
49
|
component.deleteItem(item);
|
|
50
|
-
expect(listFacade.deleteExistingEntity).
|
|
51
|
-
expect(listFacade.deleteExistingEntity).
|
|
50
|
+
expect(listFacade.deleteExistingEntity).toHaveBeenCalledTimes(1);
|
|
51
|
+
expect(listFacade.deleteExistingEntity).toHaveBeenCalledWith(item);
|
|
52
52
|
});
|
|
53
53
|
});
|
|
@@ -73,12 +73,12 @@ describe('<%= classify(singularizedName) %>ListFacade', () => {
|
|
|
73
73
|
const gridPagerSettings$ = await readFirst(facade.gridPagerSettings$);
|
|
74
74
|
expect(gridPagerSettings$).toBe(false);
|
|
75
75
|
|
|
76
|
-
expect(httpClient.get).
|
|
77
|
-
expect(httpClient.get).
|
|
76
|
+
expect(httpClient.get).toHaveBeenCalledTimes(1);
|
|
77
|
+
expect(httpClient.get).toHaveBeenCalledWith(
|
|
78
78
|
`<%= dasherize(pluralizedStoreName) %>-odata/odata/v1/<%= classify(pluralizedName) %>?$filter=<%= camelize(singularizedParentName) %>Id eq '<%= snakeCasedParentName %>_ID'&$count=true`);
|
|
79
79
|
|
|
80
80
|
facade.reloadEntities();
|
|
81
|
-
expect(httpClient.get).
|
|
81
|
+
expect(httpClient.get).toHaveBeenCalledTimes(2);
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
test('reloadEntities() should return empty list with loaded == true', async () => {
|
|
@@ -101,7 +101,7 @@ describe('<%= classify(singularizedName) %>ListFacade', () => {
|
|
|
101
101
|
|
|
102
102
|
expect(list?.data.length).toBe(3);
|
|
103
103
|
expect(isloading).toBe(false);
|
|
104
|
-
expect(service.fetch).
|
|
104
|
+
expect(service.fetch).toHaveBeenCalledTimes(1);
|
|
105
105
|
});
|
|
106
106
|
|
|
107
107
|
test('it should get the grid state', async () => {
|