@ngxs/store 3.8.2-dev.master-a75608e → 3.8.2-dev.master-59b0c4a
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/esm2020/internals/testing/index.mjs +2 -2
- package/fesm2015/ngxs-store-internals-testing.mjs +74 -74
- package/fesm2015/ngxs-store-internals-testing.mjs.map +1 -1
- package/fesm2020/ngxs-store-internals-testing.mjs +71 -71
- package/fesm2020/ngxs-store-internals-testing.mjs.map +1 -1
- package/internals/testing/index.d.ts +2 -2
- package/package.json +1 -1
- package/schematics/src/starter-kit/files/store/auth/auth.state.spec.ts__template__ +3 -2
- package/schematics/src/starter-kit/files/store/dashboard/states/dictionary/dictionary.state.spec.ts__template__ +3 -2
- package/schematics/src/starter-kit/files/store/dashboard/states/user/user.state.spec.ts__template__ +3 -2
- package/schematics/src/starter-kit/starter-kit.factory.js +9 -3
- package/schematics/src/starter-kit/starter-kit.factory.js.map +1 -1
- package/schematics/src/state/files/__name__.state.spec.ts__template__ +3 -2
- package/schematics/src/state/schema.json +4 -0
- package/schematics/src/state/state.factory.js +16 -10
- package/schematics/src/state/state.factory.js.map +1 -1
- package/schematics/src/store/files/__name__.state.spec.ts__template__ +3 -2
- package/schematics/src/store/schema.json +4 -0
- package/schematics/src/store/store.factory.js +16 -10
- package/schematics/src/store/store.factory.js.map +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { NgxsTestBed } from './ngxs.setup';
|
|
2
1
|
export { freshPlatform } from './fresh-platform';
|
|
2
|
+
export { NgxsTestBed } from './ngxs.setup';
|
|
3
3
|
export { skipConsoleLogging } from './skip-console-logging';
|
|
4
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9zdG9yZS9pbnRlcm5hbHMvdGVzdGluZy9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLGFBQWEsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBQ2pELE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxjQUFjLENBQUM7QUFDM0MsT0FBTyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sd0JBQXdCLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgeyBmcmVzaFBsYXRmb3JtIH0gZnJvbSAnLi9mcmVzaC1wbGF0Zm9ybSc7XG5leHBvcnQgeyBOZ3hzVGVzdEJlZCB9IGZyb20gJy4vbmd4cy5zZXR1cCc7XG5leHBvcnQgeyBza2lwQ29uc29sZUxvZ2dpbmcgfSBmcm9tICcuL3NraXAtY29uc29sZS1sb2dnaW5nJztcbmV4cG9ydCB7IE5neHNUZXN0aW5nIH0gZnJvbSAnLi9zeW1ib2wnO1xuIl19
|
|
@@ -1,11 +1,81 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Component, NgModule, ApplicationRef, destroyPlatform, VERSION, createPlatform } from '@angular/core';
|
|
1
|
+
import { __awaiter } from 'tslib';
|
|
3
2
|
import { TestBed } from '@angular/core/testing';
|
|
4
3
|
import { DOCUMENT } from '@angular/common';
|
|
5
|
-
import { BrowserModule, ɵBrowserDomAdapter
|
|
4
|
+
import { ɵgetDOM, BrowserModule, ɵBrowserDomAdapter } from '@angular/platform-browser';
|
|
5
|
+
import * as i0 from '@angular/core';
|
|
6
|
+
import { destroyPlatform, VERSION, createPlatform, Component, NgModule, ApplicationRef } from '@angular/core';
|
|
6
7
|
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
|
|
7
8
|
import { NgxsModule, Store } from '@ngxs/store';
|
|
8
|
-
|
|
9
|
+
|
|
10
|
+
function createRootElement() {
|
|
11
|
+
const document = TestBed.inject(DOCUMENT);
|
|
12
|
+
const root = ɵgetDOM().createElement('app-root', document);
|
|
13
|
+
document.body.appendChild(root);
|
|
14
|
+
}
|
|
15
|
+
function removeRootElement() {
|
|
16
|
+
const root = document.getElementsByTagName('app-root').item(0);
|
|
17
|
+
try {
|
|
18
|
+
document.body.removeChild(root);
|
|
19
|
+
}
|
|
20
|
+
catch (_a) { }
|
|
21
|
+
}
|
|
22
|
+
function destroyPlatformBeforeBootstrappingTheNewOne(freshUrl) {
|
|
23
|
+
destroyPlatform();
|
|
24
|
+
resetLocationToUrl(freshUrl);
|
|
25
|
+
createRootElement();
|
|
26
|
+
}
|
|
27
|
+
// As we create our custom platform via `bootstrapModule`
|
|
28
|
+
// we have to destroy it after assetions and revert
|
|
29
|
+
// the previous one
|
|
30
|
+
function resetPlatformAfterBootstrapping() {
|
|
31
|
+
removeRootElement();
|
|
32
|
+
destroyPlatform();
|
|
33
|
+
const version = +VERSION.major;
|
|
34
|
+
// https://github.com/angular/angular/commit/e250db4f261741b04ee4cbad4dec41a8908a12aa
|
|
35
|
+
if (version < 14) {
|
|
36
|
+
createPlatform(TestBed);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function resetLocationToUrl(freshUrl) {
|
|
40
|
+
window.history.replaceState({}, 'Test', freshUrl);
|
|
41
|
+
}
|
|
42
|
+
function freshPlatform(fn) {
|
|
43
|
+
let resolve = null;
|
|
44
|
+
let reject = null;
|
|
45
|
+
let whenDoneIsCalledPromise = null;
|
|
46
|
+
const hasDoneArgument = fn.length === 1;
|
|
47
|
+
if (hasDoneArgument) {
|
|
48
|
+
whenDoneIsCalledPromise = new Promise((_resolve, _reject) => {
|
|
49
|
+
resolve = _resolve;
|
|
50
|
+
reject = _reject;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return function testWithAFreshPlatform() {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
try {
|
|
56
|
+
const freshUrl = '/';
|
|
57
|
+
destroyPlatformBeforeBootstrappingTheNewOne(freshUrl);
|
|
58
|
+
if (hasDoneArgument) {
|
|
59
|
+
yield fn((error) => {
|
|
60
|
+
if (error) {
|
|
61
|
+
reject(error);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
resolve();
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
yield whenDoneIsCalledPromise;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
yield fn();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
resetPlatformAfterBootstrapping();
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
}
|
|
9
79
|
|
|
10
80
|
class NgxsTestComponent {
|
|
11
81
|
ngOnInit() { }
|
|
@@ -78,76 +148,6 @@ class NgxsTestBed {
|
|
|
78
148
|
}
|
|
79
149
|
}
|
|
80
150
|
|
|
81
|
-
function createRootElement() {
|
|
82
|
-
const document = TestBed.inject(DOCUMENT);
|
|
83
|
-
const root = ɵgetDOM().createElement('app-root', document);
|
|
84
|
-
document.body.appendChild(root);
|
|
85
|
-
}
|
|
86
|
-
function removeRootElement() {
|
|
87
|
-
const root = document.getElementsByTagName('app-root').item(0);
|
|
88
|
-
try {
|
|
89
|
-
document.body.removeChild(root);
|
|
90
|
-
}
|
|
91
|
-
catch (_a) { }
|
|
92
|
-
}
|
|
93
|
-
function destroyPlatformBeforeBootstrappingTheNewOne(freshUrl) {
|
|
94
|
-
destroyPlatform();
|
|
95
|
-
resetLocationToUrl(freshUrl);
|
|
96
|
-
createRootElement();
|
|
97
|
-
}
|
|
98
|
-
// As we create our custom platform via `bootstrapModule`
|
|
99
|
-
// we have to destroy it after assetions and revert
|
|
100
|
-
// the previous one
|
|
101
|
-
function resetPlatformAfterBootstrapping() {
|
|
102
|
-
removeRootElement();
|
|
103
|
-
destroyPlatform();
|
|
104
|
-
const version = +VERSION.major;
|
|
105
|
-
// https://github.com/angular/angular/commit/e250db4f261741b04ee4cbad4dec41a8908a12aa
|
|
106
|
-
if (version < 14) {
|
|
107
|
-
createPlatform(TestBed);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
function resetLocationToUrl(freshUrl) {
|
|
111
|
-
window.history.replaceState({}, 'Test', freshUrl);
|
|
112
|
-
}
|
|
113
|
-
function freshPlatform(fn) {
|
|
114
|
-
let resolve = null;
|
|
115
|
-
let reject = null;
|
|
116
|
-
let whenDoneIsCalledPromise = null;
|
|
117
|
-
const hasDoneArgument = fn.length === 1;
|
|
118
|
-
if (hasDoneArgument) {
|
|
119
|
-
whenDoneIsCalledPromise = new Promise((_resolve, _reject) => {
|
|
120
|
-
resolve = _resolve;
|
|
121
|
-
reject = _reject;
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
return function testWithAFreshPlatform() {
|
|
125
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
-
try {
|
|
127
|
-
const freshUrl = '/';
|
|
128
|
-
destroyPlatformBeforeBootstrappingTheNewOne(freshUrl);
|
|
129
|
-
if (hasDoneArgument) {
|
|
130
|
-
yield fn((error) => {
|
|
131
|
-
if (error) {
|
|
132
|
-
reject(error);
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
resolve();
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
yield whenDoneIsCalledPromise;
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
yield fn();
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
finally {
|
|
145
|
-
resetPlatformAfterBootstrapping();
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
|
|
151
151
|
/// <reference types="jest" />
|
|
152
152
|
function skipConsoleLogging(fn) {
|
|
153
153
|
const consoleSpies = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngxs-store-internals-testing.mjs","sources":["../../../packages/store/internals/testing/src/helpers/ngxs-test.component.ts","../../../packages/store/internals/testing/src/helpers/ngxs-test.module.ts","../../../packages/store/internals/testing/src/ngxs.setup.ts","../../../packages/store/internals/testing/src/fresh-platform.ts","../../../packages/store/internals/testing/src/skip-console-logging.ts","../../../packages/store/internals/testing/src/ngxs-store-internals-testing.ts"],"sourcesContent":["import { AfterViewInit, Component, OnInit } from '@angular/core';\n\n@Component({\n selector: 'app-root',\n template: ''\n})\nexport class NgxsTestComponent implements OnInit, AfterViewInit {\n public ngOnInit(): void {}\n public ngAfterViewInit(): void {}\n}\n","import { ApplicationRef, NgModule } from '@angular/core';\nimport { BrowserModule } from '@angular/platform-browser';\n\nimport { NgxsTestComponent } from './ngxs-test.component';\n\n@NgModule({\n imports: [BrowserModule],\n declarations: [NgxsTestComponent]\n})\nexport class NgxsTestModule {\n public static ngDoBootstrap(app: ApplicationRef): void {\n app.bootstrap(NgxsTestComponent);\n }\n}\n","import { ApplicationRef } from '@angular/core';\nimport { TestBed, TestBedStatic } from '@angular/core/testing';\nimport { DOCUMENT } from '@angular/common';\nimport { ɵBrowserDomAdapter as BrowserDomAdapter } from '@angular/platform-browser';\nimport {\n BrowserDynamicTestingModule,\n platformBrowserDynamicTesting\n} from '@angular/platform-browser-dynamic/testing';\nimport { NgxsModule, Store } from '@ngxs/store';\n\nimport { NgxsTestModule } from './helpers/ngxs-test.module';\nimport { NgxsOptionsTesting, NgxsTesting } from './symbol';\n\nexport class NgxsTestBed {\n public static configureTestingStates(options: NgxsOptionsTesting): NgxsTesting {\n this.resetTestBed();\n\n if (options.before) {\n options.before();\n }\n\n TestBed.configureTestingModule({\n imports: [\n NgxsTestModule,\n NgxsModule.forRoot(options.states || [], options.ngxsOptions || {}),\n ...(options.imports || [])\n ]\n }).compileComponents();\n\n NgxsTestBed.ngxsBootstrap();\n\n return {\n get store(): Store {\n return TestBed.inject(Store);\n },\n get getTestBed(): TestBedStatic {\n return TestBed;\n }\n };\n }\n\n private static ngxsBootstrap(): void {\n NgxsTestBed.createRootNode();\n NgxsTestModule.ngDoBootstrap(TestBed.inject(ApplicationRef));\n }\n\n private static resetTestBed(): void {\n TestBed.resetTestEnvironment();\n TestBed.initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), {\n teardown: { destroyAfterEach: true }\n });\n }\n\n private static createRootNode(selector = 'app-root'): void {\n const document = TestBed.inject(DOCUMENT);\n const adapter = new BrowserDomAdapter();\n const root = adapter.createElement(selector);\n document.body.appendChild(root);\n }\n}\n","import { TestBed } from '@angular/core/testing';\nimport { DOCUMENT } from '@angular/common';\nimport { ɵgetDOM as getDOM } from '@angular/platform-browser';\nimport { VERSION, destroyPlatform, createPlatform } from '@angular/core';\n\nfunction createRootElement() {\n const document = TestBed.inject(DOCUMENT);\n const root = getDOM().createElement('app-root', document);\n document.body.appendChild(root);\n}\n\nfunction removeRootElement() {\n const root: Element = document.getElementsByTagName('app-root').item(0)!;\n try {\n document.body.removeChild(root);\n } catch {}\n}\n\nfunction destroyPlatformBeforeBootstrappingTheNewOne(freshUrl: string) {\n destroyPlatform();\n resetLocationToUrl(freshUrl);\n createRootElement();\n}\n\n// As we create our custom platform via `bootstrapModule`\n// we have to destroy it after assetions and revert\n// the previous one\nfunction resetPlatformAfterBootstrapping() {\n removeRootElement();\n destroyPlatform();\n const version = +VERSION.major;\n // https://github.com/angular/angular/commit/e250db4f261741b04ee4cbad4dec41a8908a12aa\n if (version < 14) {\n createPlatform(TestBed);\n }\n}\n\nfunction resetLocationToUrl(freshUrl: string) {\n window.history.replaceState({}, 'Test', freshUrl);\n}\n\nexport function freshPlatform(fn: (done?: VoidFunction) => Promise<void>) {\n let resolve: VoidFunction | null = null;\n let reject: ((error: Error) => void) | null = null;\n let whenDoneIsCalledPromise: Promise<void> | null = null;\n\n const hasDoneArgument = fn.length === 1;\n\n if (hasDoneArgument) {\n whenDoneIsCalledPromise = new Promise<void>((_resolve, _reject) => {\n resolve = _resolve;\n reject = _reject;\n });\n }\n\n return async function testWithAFreshPlatform() {\n try {\n const freshUrl = '/';\n destroyPlatformBeforeBootstrappingTheNewOne(freshUrl);\n\n if (hasDoneArgument) {\n await fn((error?: Error) => {\n if (error) {\n reject!(error);\n } else {\n resolve!();\n }\n });\n await whenDoneIsCalledPromise!;\n } else {\n await fn();\n }\n } finally {\n resetPlatformAfterBootstrapping();\n }\n };\n}\n","/// <reference types=\"jest\" />\n\nexport function skipConsoleLogging<T extends (...args: any[]) => any>(fn: T): ReturnType<T> {\n const consoleSpies = [\n jest.spyOn(console, 'log').mockImplementation(() => {}),\n jest.spyOn(console, 'warn').mockImplementation(() => {}),\n jest.spyOn(console, 'error').mockImplementation(() => {}),\n jest.spyOn(console, 'info').mockImplementation(() => {})\n ];\n function restoreSpies() {\n consoleSpies.forEach(spy => spy.mockRestore());\n }\n let restoreSpyAsync = false;\n try {\n const returnValue = fn();\n if (returnValue instanceof Promise) {\n restoreSpyAsync = true;\n return returnValue.finally(() => restoreSpies()) as ReturnType<T>;\n }\n return returnValue;\n } finally {\n if (!restoreSpyAsync) {\n restoreSpies();\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["BrowserDomAdapter","getDOM"],"mappings":";;;;;;;;;MAMa,iBAAiB,CAAA;AACrB,IAAA,QAAQ,MAAW;AACnB,IAAA,eAAe,MAAW;;iIAFtB,iBAAiB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA,CAAA;AAAjB,mBAAA,iBAAA,CAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,iBAAiB,gDAFlB,EAAE,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,CAAA;2FAED,iBAAiB,EAAA,UAAA,EAAA,CAAA;kBAJ7B,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,UAAU;AACpB,oBA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ACzB,IAAI,WAAW,YAAY,OAAO,EAAE;YAClC,eAAe,GAAG,IAAI,CAAC;YACvB,OAAO,WAAW,CAAC,OAAO,CAAC,MAAM,YAAY,EAAE,CAAkB,CAAC;AACnE,SAAA;AACD,QAAA,OAAO,WAAW,CAAC;AACpB,KAAA;AAAS,YAAA;QACR,IAAI,CAAC,eAAe,EAAE;AACpB,YAAA,YAAY,EAAE,CAAC;AAChB,SAAA;AACF,KAAA;AACH;;ACzBA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ngxs-store-internals-testing.mjs","sources":["../../../packages/store/internals/testing/src/fresh-platform.ts","../../../packages/store/internals/testing/src/helpers/ngxs-test.component.ts","../../../packages/store/internals/testing/src/helpers/ngxs-test.module.ts","../../../packages/store/internals/testing/src/ngxs.setup.ts","../../../packages/store/internals/testing/src/skip-console-logging.ts","../../../packages/store/internals/testing/src/ngxs-store-internals-testing.ts"],"sourcesContent":["import { TestBed } from '@angular/core/testing';\nimport { DOCUMENT } from '@angular/common';\nimport { ɵgetDOM as getDOM } from '@angular/platform-browser';\nimport { VERSION, destroyPlatform, createPlatform } from '@angular/core';\n\nfunction createRootElement() {\n const document = TestBed.inject(DOCUMENT);\n const root = getDOM().createElement('app-root', document);\n document.body.appendChild(root);\n}\n\nfunction removeRootElement() {\n const root: Element = document.getElementsByTagName('app-root').item(0)!;\n try {\n document.body.removeChild(root);\n } catch {}\n}\n\nfunction destroyPlatformBeforeBootstrappingTheNewOne(freshUrl: string) {\n destroyPlatform();\n resetLocationToUrl(freshUrl);\n createRootElement();\n}\n\n// As we create our custom platform via `bootstrapModule`\n// we have to destroy it after assetions and revert\n// the previous one\nfunction resetPlatformAfterBootstrapping() {\n removeRootElement();\n destroyPlatform();\n const version = +VERSION.major;\n // https://github.com/angular/angular/commit/e250db4f261741b04ee4cbad4dec41a8908a12aa\n if (version < 14) {\n createPlatform(TestBed);\n }\n}\n\nfunction resetLocationToUrl(freshUrl: string) {\n window.history.replaceState({}, 'Test', freshUrl);\n}\n\nexport function freshPlatform(fn: (done?: VoidFunction) => Promise<void>) {\n let resolve: VoidFunction | null = null;\n let reject: ((error: Error) => void) | null = null;\n let whenDoneIsCalledPromise: Promise<void> | null = null;\n\n const hasDoneArgument = fn.length === 1;\n\n if (hasDoneArgument) {\n whenDoneIsCalledPromise = new Promise<void>((_resolve, _reject) => {\n resolve = _resolve;\n reject = _reject;\n });\n }\n\n return async function testWithAFreshPlatform() {\n try {\n const freshUrl = '/';\n destroyPlatformBeforeBootstrappingTheNewOne(freshUrl);\n\n if (hasDoneArgument) {\n await fn((error?: Error) => {\n if (error) {\n reject!(error);\n } else {\n resolve!();\n }\n });\n await whenDoneIsCalledPromise!;\n } else {\n await fn();\n }\n } finally {\n resetPlatformAfterBootstrapping();\n }\n };\n}\n","import { AfterViewInit, Component, OnInit } from '@angular/core';\n\n@Component({\n selector: 'app-root',\n template: ''\n})\nexport class NgxsTestComponent implements OnInit, AfterViewInit {\n public ngOnInit(): void {}\n public ngAfterViewInit(): void {}\n}\n","import { ApplicationRef, NgModule } from '@angular/core';\nimport { BrowserModule } from '@angular/platform-browser';\n\nimport { NgxsTestComponent } from './ngxs-test.component';\n\n@NgModule({\n imports: [BrowserModule],\n declarations: [NgxsTestComponent]\n})\nexport class NgxsTestModule {\n public static ngDoBootstrap(app: ApplicationRef): void {\n app.bootstrap(NgxsTestComponent);\n }\n}\n","import { ApplicationRef } from '@angular/core';\nimport { TestBed, TestBedStatic } from '@angular/core/testing';\nimport { DOCUMENT } from '@angular/common';\nimport { ɵBrowserDomAdapter as BrowserDomAdapter } from '@angular/platform-browser';\nimport {\n BrowserDynamicTestingModule,\n platformBrowserDynamicTesting\n} from '@angular/platform-browser-dynamic/testing';\nimport { NgxsModule, Store } from '@ngxs/store';\n\nimport { NgxsTestModule } from './helpers/ngxs-test.module';\nimport { NgxsOptionsTesting, NgxsTesting } from './symbol';\n\nexport class NgxsTestBed {\n public static configureTestingStates(options: NgxsOptionsTesting): NgxsTesting {\n this.resetTestBed();\n\n if (options.before) {\n options.before();\n }\n\n TestBed.configureTestingModule({\n imports: [\n NgxsTestModule,\n NgxsModule.forRoot(options.states || [], options.ngxsOptions || {}),\n ...(options.imports || [])\n ]\n }).compileComponents();\n\n NgxsTestBed.ngxsBootstrap();\n\n return {\n get store(): Store {\n return TestBed.inject(Store);\n },\n get getTestBed(): TestBedStatic {\n return TestBed;\n }\n };\n }\n\n private static ngxsBootstrap(): void {\n NgxsTestBed.createRootNode();\n NgxsTestModule.ngDoBootstrap(TestBed.inject(ApplicationRef));\n }\n\n private static resetTestBed(): void {\n TestBed.resetTestEnvironment();\n TestBed.initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), {\n teardown: { destroyAfterEach: true }\n });\n }\n\n private static createRootNode(selector = 'app-root'): void {\n const document = TestBed.inject(DOCUMENT);\n const adapter = new BrowserDomAdapter();\n const root = adapter.createElement(selector);\n document.body.appendChild(root);\n }\n}\n","/// <reference types=\"jest\" />\n\nexport function skipConsoleLogging<T extends (...args: any[]) => any>(fn: T): ReturnType<T> {\n const consoleSpies = [\n jest.spyOn(console, 'log').mockImplementation(() => {}),\n jest.spyOn(console, 'warn').mockImplementation(() => {}),\n jest.spyOn(console, 'error').mockImplementation(() => {}),\n jest.spyOn(console, 'info').mockImplementation(() => {})\n ];\n function restoreSpies() {\n consoleSpies.forEach(spy => spy.mockRestore());\n }\n let restoreSpyAsync = false;\n try {\n const returnValue = fn();\n if (returnValue instanceof Promise) {\n restoreSpyAsync = true;\n return returnValue.finally(() => restoreSpies()) as ReturnType<T>;\n }\n return returnValue;\n } finally {\n if (!restoreSpyAsync) {\n restoreSpies();\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["getDOM","BrowserDomAdapter"],"mappings":";;;;;;;;;AAKA,SAAS,iBAAiB,GAAA;IACxB,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC1C,M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,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,kBAAkB,CAAC,MAAK,GAAG,CAAC;AACzD,QAAA,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,kBAAkB,CAAC,MAAK,GAAG,CAAC;KACzD,CAAC;AACF,IAAA,SAAS,YAAY,GAAA;AACnB,QAAA,YAAY,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;KAChD;IACD,IAAI,eAAe,GAAG,KAAK,CAAC;IAC5B,IAAI;AACF,QAAA,MAAM,WAAW,GAAG,EAAE,EAAE,CAAC;QACzB,IAAI,WAAW,YAAY,OAAO,EAAE;YAClC,eAAe,GAAG,IAAI,CAAC;YACvB,OAAO,WAAW,CAAC,OAAO,CAAC,MAAM,YAAY,EAAE,CAAkB,CAAC;AACnE,SAAA;AACD,QAAA,OAAO,WAAW,CAAC;AACpB,KAAA;AAAS,YAAA;QACR,IAAI,CAAC,eAAe,EAAE;AACpB,YAAA,YAAY,EAAE,CAAC;AAChB,SAAA;AACF,KAAA;AACH;;ACzBA;;AAEG;;;;"}
|
|
@@ -1,11 +1,79 @@
|
|
|
1
|
-
import * as i0 from '@angular/core';
|
|
2
|
-
import { Component, NgModule, ApplicationRef, destroyPlatform, VERSION, createPlatform } from '@angular/core';
|
|
3
1
|
import { TestBed } from '@angular/core/testing';
|
|
4
2
|
import { DOCUMENT } from '@angular/common';
|
|
5
|
-
import { BrowserModule, ɵBrowserDomAdapter
|
|
3
|
+
import { ɵgetDOM, BrowserModule, ɵBrowserDomAdapter } from '@angular/platform-browser';
|
|
4
|
+
import * as i0 from '@angular/core';
|
|
5
|
+
import { destroyPlatform, VERSION, createPlatform, Component, NgModule, ApplicationRef } from '@angular/core';
|
|
6
6
|
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
|
|
7
7
|
import { NgxsModule, Store } from '@ngxs/store';
|
|
8
8
|
|
|
9
|
+
function createRootElement() {
|
|
10
|
+
const document = TestBed.inject(DOCUMENT);
|
|
11
|
+
const root = ɵgetDOM().createElement('app-root', document);
|
|
12
|
+
document.body.appendChild(root);
|
|
13
|
+
}
|
|
14
|
+
function removeRootElement() {
|
|
15
|
+
const root = document.getElementsByTagName('app-root').item(0);
|
|
16
|
+
try {
|
|
17
|
+
document.body.removeChild(root);
|
|
18
|
+
}
|
|
19
|
+
catch { }
|
|
20
|
+
}
|
|
21
|
+
function destroyPlatformBeforeBootstrappingTheNewOne(freshUrl) {
|
|
22
|
+
destroyPlatform();
|
|
23
|
+
resetLocationToUrl(freshUrl);
|
|
24
|
+
createRootElement();
|
|
25
|
+
}
|
|
26
|
+
// As we create our custom platform via `bootstrapModule`
|
|
27
|
+
// we have to destroy it after assetions and revert
|
|
28
|
+
// the previous one
|
|
29
|
+
function resetPlatformAfterBootstrapping() {
|
|
30
|
+
removeRootElement();
|
|
31
|
+
destroyPlatform();
|
|
32
|
+
const version = +VERSION.major;
|
|
33
|
+
// https://github.com/angular/angular/commit/e250db4f261741b04ee4cbad4dec41a8908a12aa
|
|
34
|
+
if (version < 14) {
|
|
35
|
+
createPlatform(TestBed);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function resetLocationToUrl(freshUrl) {
|
|
39
|
+
window.history.replaceState({}, 'Test', freshUrl);
|
|
40
|
+
}
|
|
41
|
+
function freshPlatform(fn) {
|
|
42
|
+
let resolve = null;
|
|
43
|
+
let reject = null;
|
|
44
|
+
let whenDoneIsCalledPromise = null;
|
|
45
|
+
const hasDoneArgument = fn.length === 1;
|
|
46
|
+
if (hasDoneArgument) {
|
|
47
|
+
whenDoneIsCalledPromise = new Promise((_resolve, _reject) => {
|
|
48
|
+
resolve = _resolve;
|
|
49
|
+
reject = _reject;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return async function testWithAFreshPlatform() {
|
|
53
|
+
try {
|
|
54
|
+
const freshUrl = '/';
|
|
55
|
+
destroyPlatformBeforeBootstrappingTheNewOne(freshUrl);
|
|
56
|
+
if (hasDoneArgument) {
|
|
57
|
+
await fn((error) => {
|
|
58
|
+
if (error) {
|
|
59
|
+
reject(error);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
resolve();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
await whenDoneIsCalledPromise;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
await fn();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
resetPlatformAfterBootstrapping();
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
9
77
|
class NgxsTestComponent {
|
|
10
78
|
ngOnInit() { }
|
|
11
79
|
ngAfterViewInit() { }
|
|
@@ -77,74 +145,6 @@ class NgxsTestBed {
|
|
|
77
145
|
}
|
|
78
146
|
}
|
|
79
147
|
|
|
80
|
-
function createRootElement() {
|
|
81
|
-
const document = TestBed.inject(DOCUMENT);
|
|
82
|
-
const root = ɵgetDOM().createElement('app-root', document);
|
|
83
|
-
document.body.appendChild(root);
|
|
84
|
-
}
|
|
85
|
-
function removeRootElement() {
|
|
86
|
-
const root = document.getElementsByTagName('app-root').item(0);
|
|
87
|
-
try {
|
|
88
|
-
document.body.removeChild(root);
|
|
89
|
-
}
|
|
90
|
-
catch { }
|
|
91
|
-
}
|
|
92
|
-
function destroyPlatformBeforeBootstrappingTheNewOne(freshUrl) {
|
|
93
|
-
destroyPlatform();
|
|
94
|
-
resetLocationToUrl(freshUrl);
|
|
95
|
-
createRootElement();
|
|
96
|
-
}
|
|
97
|
-
// As we create our custom platform via `bootstrapModule`
|
|
98
|
-
// we have to destroy it after assetions and revert
|
|
99
|
-
// the previous one
|
|
100
|
-
function resetPlatformAfterBootstrapping() {
|
|
101
|
-
removeRootElement();
|
|
102
|
-
destroyPlatform();
|
|
103
|
-
const version = +VERSION.major;
|
|
104
|
-
// https://github.com/angular/angular/commit/e250db4f261741b04ee4cbad4dec41a8908a12aa
|
|
105
|
-
if (version < 14) {
|
|
106
|
-
createPlatform(TestBed);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
function resetLocationToUrl(freshUrl) {
|
|
110
|
-
window.history.replaceState({}, 'Test', freshUrl);
|
|
111
|
-
}
|
|
112
|
-
function freshPlatform(fn) {
|
|
113
|
-
let resolve = null;
|
|
114
|
-
let reject = null;
|
|
115
|
-
let whenDoneIsCalledPromise = null;
|
|
116
|
-
const hasDoneArgument = fn.length === 1;
|
|
117
|
-
if (hasDoneArgument) {
|
|
118
|
-
whenDoneIsCalledPromise = new Promise((_resolve, _reject) => {
|
|
119
|
-
resolve = _resolve;
|
|
120
|
-
reject = _reject;
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
return async function testWithAFreshPlatform() {
|
|
124
|
-
try {
|
|
125
|
-
const freshUrl = '/';
|
|
126
|
-
destroyPlatformBeforeBootstrappingTheNewOne(freshUrl);
|
|
127
|
-
if (hasDoneArgument) {
|
|
128
|
-
await fn((error) => {
|
|
129
|
-
if (error) {
|
|
130
|
-
reject(error);
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
resolve();
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
await whenDoneIsCalledPromise;
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
await fn();
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
finally {
|
|
143
|
-
resetPlatformAfterBootstrapping();
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
|
|
148
148
|
/// <reference types="jest" />
|
|
149
149
|
function skipConsoleLogging(fn) {
|
|
150
150
|
const consoleSpies = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngxs-store-internals-testing.mjs","sources":["../../../packages/store/internals/testing/src/helpers/ngxs-test.component.ts","../../../packages/store/internals/testing/src/helpers/ngxs-test.module.ts","../../../packages/store/internals/testing/src/ngxs.setup.ts","../../../packages/store/internals/testing/src/fresh-platform.ts","../../../packages/store/internals/testing/src/skip-console-logging.ts","../../../packages/store/internals/testing/src/ngxs-store-internals-testing.ts"],"sourcesContent":["import { AfterViewInit, Component, OnInit } from '@angular/core';\n\n@Component({\n selector: 'app-root',\n template: ''\n})\nexport class NgxsTestComponent implements OnInit, AfterViewInit {\n public ngOnInit(): void {}\n public ngAfterViewInit(): void {}\n}\n","import { ApplicationRef, NgModule } from '@angular/core';\nimport { BrowserModule } from '@angular/platform-browser';\n\nimport { NgxsTestComponent } from './ngxs-test.component';\n\n@NgModule({\n imports: [BrowserModule],\n declarations: [NgxsTestComponent]\n})\nexport class NgxsTestModule {\n public static ngDoBootstrap(app: ApplicationRef): void {\n app.bootstrap(NgxsTestComponent);\n }\n}\n","import { ApplicationRef } from '@angular/core';\nimport { TestBed, TestBedStatic } from '@angular/core/testing';\nimport { DOCUMENT } from '@angular/common';\nimport { ɵBrowserDomAdapter as BrowserDomAdapter } from '@angular/platform-browser';\nimport {\n BrowserDynamicTestingModule,\n platformBrowserDynamicTesting\n} from '@angular/platform-browser-dynamic/testing';\nimport { NgxsModule, Store } from '@ngxs/store';\n\nimport { NgxsTestModule } from './helpers/ngxs-test.module';\nimport { NgxsOptionsTesting, NgxsTesting } from './symbol';\n\nexport class NgxsTestBed {\n public static configureTestingStates(options: NgxsOptionsTesting): NgxsTesting {\n this.resetTestBed();\n\n if (options.before) {\n options.before();\n }\n\n TestBed.configureTestingModule({\n imports: [\n NgxsTestModule,\n NgxsModule.forRoot(options.states || [], options.ngxsOptions || {}),\n ...(options.imports || [])\n ]\n }).compileComponents();\n\n NgxsTestBed.ngxsBootstrap();\n\n return {\n get store(): Store {\n return TestBed.inject(Store);\n },\n get getTestBed(): TestBedStatic {\n return TestBed;\n }\n };\n }\n\n private static ngxsBootstrap(): void {\n NgxsTestBed.createRootNode();\n NgxsTestModule.ngDoBootstrap(TestBed.inject(ApplicationRef));\n }\n\n private static resetTestBed(): void {\n TestBed.resetTestEnvironment();\n TestBed.initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), {\n teardown: { destroyAfterEach: true }\n });\n }\n\n private static createRootNode(selector = 'app-root'): void {\n const document = TestBed.inject(DOCUMENT);\n const adapter = new BrowserDomAdapter();\n const root = adapter.createElement(selector);\n document.body.appendChild(root);\n }\n}\n","import { TestBed } from '@angular/core/testing';\nimport { DOCUMENT } from '@angular/common';\nimport { ɵgetDOM as getDOM } from '@angular/platform-browser';\nimport { VERSION, destroyPlatform, createPlatform } from '@angular/core';\n\nfunction createRootElement() {\n const document = TestBed.inject(DOCUMENT);\n const root = getDOM().createElement('app-root', document);\n document.body.appendChild(root);\n}\n\nfunction removeRootElement() {\n const root: Element = document.getElementsByTagName('app-root').item(0)!;\n try {\n document.body.removeChild(root);\n } catch {}\n}\n\nfunction destroyPlatformBeforeBootstrappingTheNewOne(freshUrl: string) {\n destroyPlatform();\n resetLocationToUrl(freshUrl);\n createRootElement();\n}\n\n// As we create our custom platform via `bootstrapModule`\n// we have to destroy it after assetions and revert\n// the previous one\nfunction resetPlatformAfterBootstrapping() {\n removeRootElement();\n destroyPlatform();\n const version = +VERSION.major;\n // https://github.com/angular/angular/commit/e250db4f261741b04ee4cbad4dec41a8908a12aa\n if (version < 14) {\n createPlatform(TestBed);\n }\n}\n\nfunction resetLocationToUrl(freshUrl: string) {\n window.history.replaceState({}, 'Test', freshUrl);\n}\n\nexport function freshPlatform(fn: (done?: VoidFunction) => Promise<void>) {\n let resolve: VoidFunction | null = null;\n let reject: ((error: Error) => void) | null = null;\n let whenDoneIsCalledPromise: Promise<void> | null = null;\n\n const hasDoneArgument = fn.length === 1;\n\n if (hasDoneArgument) {\n whenDoneIsCalledPromise = new Promise<void>((_resolve, _reject) => {\n resolve = _resolve;\n reject = _reject;\n });\n }\n\n return async function testWithAFreshPlatform() {\n try {\n const freshUrl = '/';\n destroyPlatformBeforeBootstrappingTheNewOne(freshUrl);\n\n if (hasDoneArgument) {\n await fn((error?: Error) => {\n if (error) {\n reject!(error);\n } else {\n resolve!();\n }\n });\n await whenDoneIsCalledPromise!;\n } else {\n await fn();\n }\n } finally {\n resetPlatformAfterBootstrapping();\n }\n };\n}\n","/// <reference types=\"jest\" />\n\nexport function skipConsoleLogging<T extends (...args: any[]) => any>(fn: T): ReturnType<T> {\n const consoleSpies = [\n jest.spyOn(console, 'log').mockImplementation(() => {}),\n jest.spyOn(console, 'warn').mockImplementation(() => {}),\n jest.spyOn(console, 'error').mockImplementation(() => {}),\n jest.spyOn(console, 'info').mockImplementation(() => {})\n ];\n function restoreSpies() {\n consoleSpies.forEach(spy => spy.mockRestore());\n }\n let restoreSpyAsync = false;\n try {\n const returnValue = fn();\n if (returnValue instanceof Promise) {\n restoreSpyAsync = true;\n return returnValue.finally(() => restoreSpies()) as ReturnType<T>;\n }\n return returnValue;\n } finally {\n if (!restoreSpyAsync) {\n restoreSpies();\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["BrowserDomAdapter","getDOM"],"mappings":";;;;;;;;MAMa,iBAAiB,CAAA;AACrB,IAAA,QAAQ,MAAW;AACnB,IAAA,eAAe,MAAW;;iIAFtB,iBAAiB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA,CAAA;AAAjB,mBAAA,iBAAA,CAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,iBAAiB,gDAFlB,EAAE,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,CAAA;2FAED,iBAAiB,EAAA,UAAA,EAAA,CAAA;kBAJ7B,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,UAAU;AACpB,oBAAA,QAAQ,EAAE,EAAE;AACb,iBAAA,CAAA;;;MCIY,cAAc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W,CAAC,OAAO,CAAC,MAAM,YAAY,EAAE,CAAkB,CAAC;AACnE,SAAA;AACD,QAAA,OAAO,WAAW,CAAC;AACpB,KAAA;AAAS,YAAA;QACR,IAAI,CAAC,eAAe,EAAE;AACpB,YAAA,YAAY,EAAE,CAAC;AAChB,SAAA;AACF,KAAA;AACH;;ACzBA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ngxs-store-internals-testing.mjs","sources":["../../../packages/store/internals/testing/src/fresh-platform.ts","../../../packages/store/internals/testing/src/helpers/ngxs-test.component.ts","../../../packages/store/internals/testing/src/helpers/ngxs-test.module.ts","../../../packages/store/internals/testing/src/ngxs.setup.ts","../../../packages/store/internals/testing/src/skip-console-logging.ts","../../../packages/store/internals/testing/src/ngxs-store-internals-testing.ts"],"sourcesContent":["import { TestBed } from '@angular/core/testing';\nimport { DOCUMENT } from '@angular/common';\nimport { ɵgetDOM as getDOM } from '@angular/platform-browser';\nimport { VERSION, destroyPlatform, createPlatform } from '@angular/core';\n\nfunction createRootElement() {\n const document = TestBed.inject(DOCUMENT);\n const root = getDOM().createElement('app-root', document);\n document.body.appendChild(root);\n}\n\nfunction removeRootElement() {\n const root: Element = document.getElementsByTagName('app-root').item(0)!;\n try {\n document.body.removeChild(root);\n } catch {}\n}\n\nfunction destroyPlatformBeforeBootstrappingTheNewOne(freshUrl: string) {\n destroyPlatform();\n resetLocationToUrl(freshUrl);\n createRootElement();\n}\n\n// As we create our custom platform via `bootstrapModule`\n// we have to destroy it after assetions and revert\n// the previous one\nfunction resetPlatformAfterBootstrapping() {\n removeRootElement();\n destroyPlatform();\n const version = +VERSION.major;\n // https://github.com/angular/angular/commit/e250db4f261741b04ee4cbad4dec41a8908a12aa\n if (version < 14) {\n createPlatform(TestBed);\n }\n}\n\nfunction resetLocationToUrl(freshUrl: string) {\n window.history.replaceState({}, 'Test', freshUrl);\n}\n\nexport function freshPlatform(fn: (done?: VoidFunction) => Promise<void>) {\n let resolve: VoidFunction | null = null;\n let reject: ((error: Error) => void) | null = null;\n let whenDoneIsCalledPromise: Promise<void> | null = null;\n\n const hasDoneArgument = fn.length === 1;\n\n if (hasDoneArgument) {\n whenDoneIsCalledPromise = new Promise<void>((_resolve, _reject) => {\n resolve = _resolve;\n reject = _reject;\n });\n }\n\n return async function testWithAFreshPlatform() {\n try {\n const freshUrl = '/';\n destroyPlatformBeforeBootstrappingTheNewOne(freshUrl);\n\n if (hasDoneArgument) {\n await fn((error?: Error) => {\n if (error) {\n reject!(error);\n } else {\n resolve!();\n }\n });\n await whenDoneIsCalledPromise!;\n } else {\n await fn();\n }\n } finally {\n resetPlatformAfterBootstrapping();\n }\n };\n}\n","import { AfterViewInit, Component, OnInit } from '@angular/core';\n\n@Component({\n selector: 'app-root',\n template: ''\n})\nexport class NgxsTestComponent implements OnInit, AfterViewInit {\n public ngOnInit(): void {}\n public ngAfterViewInit(): void {}\n}\n","import { ApplicationRef, NgModule } from '@angular/core';\nimport { BrowserModule } from '@angular/platform-browser';\n\nimport { NgxsTestComponent } from './ngxs-test.component';\n\n@NgModule({\n imports: [BrowserModule],\n declarations: [NgxsTestComponent]\n})\nexport class NgxsTestModule {\n public static ngDoBootstrap(app: ApplicationRef): void {\n app.bootstrap(NgxsTestComponent);\n }\n}\n","import { ApplicationRef } from '@angular/core';\nimport { TestBed, TestBedStatic } from '@angular/core/testing';\nimport { DOCUMENT } from '@angular/common';\nimport { ɵBrowserDomAdapter as BrowserDomAdapter } from '@angular/platform-browser';\nimport {\n BrowserDynamicTestingModule,\n platformBrowserDynamicTesting\n} from '@angular/platform-browser-dynamic/testing';\nimport { NgxsModule, Store } from '@ngxs/store';\n\nimport { NgxsTestModule } from './helpers/ngxs-test.module';\nimport { NgxsOptionsTesting, NgxsTesting } from './symbol';\n\nexport class NgxsTestBed {\n public static configureTestingStates(options: NgxsOptionsTesting): NgxsTesting {\n this.resetTestBed();\n\n if (options.before) {\n options.before();\n }\n\n TestBed.configureTestingModule({\n imports: [\n NgxsTestModule,\n NgxsModule.forRoot(options.states || [], options.ngxsOptions || {}),\n ...(options.imports || [])\n ]\n }).compileComponents();\n\n NgxsTestBed.ngxsBootstrap();\n\n return {\n get store(): Store {\n return TestBed.inject(Store);\n },\n get getTestBed(): TestBedStatic {\n return TestBed;\n }\n };\n }\n\n private static ngxsBootstrap(): void {\n NgxsTestBed.createRootNode();\n NgxsTestModule.ngDoBootstrap(TestBed.inject(ApplicationRef));\n }\n\n private static resetTestBed(): void {\n TestBed.resetTestEnvironment();\n TestBed.initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), {\n teardown: { destroyAfterEach: true }\n });\n }\n\n private static createRootNode(selector = 'app-root'): void {\n const document = TestBed.inject(DOCUMENT);\n const adapter = new BrowserDomAdapter();\n const root = adapter.createElement(selector);\n document.body.appendChild(root);\n }\n}\n","/// <reference types=\"jest\" />\n\nexport function skipConsoleLogging<T extends (...args: any[]) => any>(fn: T): ReturnType<T> {\n const consoleSpies = [\n jest.spyOn(console, 'log').mockImplementation(() => {}),\n jest.spyOn(console, 'warn').mockImplementation(() => {}),\n jest.spyOn(console, 'error').mockImplementation(() => {}),\n jest.spyOn(console, 'info').mockImplementation(() => {})\n ];\n function restoreSpies() {\n consoleSpies.forEach(spy => spy.mockRestore());\n }\n let restoreSpyAsync = false;\n try {\n const returnValue = fn();\n if (returnValue instanceof Promise) {\n restoreSpyAsync = true;\n return returnValue.finally(() => restoreSpies()) as ReturnType<T>;\n }\n return returnValue;\n } finally {\n if (!restoreSpyAsync) {\n restoreSpies();\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["getDOM","BrowserDomAdapter"],"mappings":";;;;;;;;AAKA,SAAS,iBAAiB,GAAA;IACxB,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAGA,OAAM,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AA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AO,EAAE,MAAM,CAAC,CAAC,kBAAkB,CAAC,MAAK,GAAG,CAAC;KACzD,CAAC;AACF,IAAA,SAAS,YAAY,GAAA;AACnB,QAAA,YAAY,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;KAChD;IACD,IAAI,eAAe,GAAG,KAAK,CAAC;IAC5B,IAAI;AACF,QAAA,MAAM,WAAW,GAAG,EAAE,EAAE,CAAC;QACzB,IAAI,WAAW,YAAY,OAAO,EAAE;YAClC,eAAe,GAAG,IAAI,CAAC;YACvB,OAAO,WAAW,CAAC,OAAO,CAAC,MAAM,YAAY,EAAE,CAAkB,CAAC;AACnE,SAAA;AACD,QAAA,OAAO,WAAW,CAAC;AACpB,KAAA;AAAS,YAAA;QACR,IAAI,CAAC,eAAe,EAAE;AACpB,YAAA,YAAY,EAAE,CAAC;AAChB,SAAA;AACF,KAAA;AACH;;ACzBA;;AAEG;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { NgxsTestBed } from './ngxs.setup';
|
|
2
|
-
export { NgxsTesting } from './symbol';
|
|
3
1
|
export { freshPlatform } from './fresh-platform';
|
|
2
|
+
export { NgxsTestBed } from './ngxs.setup';
|
|
4
3
|
export { skipConsoleLogging } from './skip-console-logging';
|
|
4
|
+
export { NgxsTesting } from './symbol';
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NgxsModule, Store } from '@ngxs/store';
|
|
1
|
+
import { <% if (isStandalone) { %> provideStore, <% } else { %> NgxsModule, <% } %> Store } from '@ngxs/store';
|
|
2
2
|
import { TestBed } from '@angular/core/testing';
|
|
3
3
|
import { AuthenticationStateModel, AuthState } from './auth.state';
|
|
4
4
|
import { SetAuthData } from './auth.actions';
|
|
@@ -8,7 +8,8 @@ describe('[TEST]: AuthStore', () => {
|
|
|
8
8
|
|
|
9
9
|
beforeEach(() => {
|
|
10
10
|
TestBed.configureTestingModule({
|
|
11
|
-
|
|
11
|
+
<% if (isStandalone) { %> providers: [provideStore([AuthState])]
|
|
12
|
+
<% } else { %> imports: [NgxsModule.forRoot([AuthState])] <% } %>
|
|
12
13
|
});
|
|
13
14
|
|
|
14
15
|
store = TestBed.inject(Store);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NgxsModule, Store } from '@ngxs/store';
|
|
1
|
+
import { <% if (isStandalone) { %> provideStore, <% } else { %> NgxsModule, <% } %> Store } from '@ngxs/store';
|
|
2
2
|
import { TestBed } from '@angular/core/testing';
|
|
3
3
|
import { DictionaryState, DictionaryStateModel } from './dictionary.state';
|
|
4
4
|
import { DictionaryReset, SetDictionaryData } from './dictionary.actions';
|
|
@@ -29,7 +29,8 @@ describe('[TEST]: Dictionary state', () => {
|
|
|
29
29
|
|
|
30
30
|
beforeEach(() => {
|
|
31
31
|
TestBed.configureTestingModule({
|
|
32
|
-
|
|
32
|
+
<% if (isStandalone) { %> providers: [provideStore([DictionaryState])]
|
|
33
|
+
<% } else { %> imports: [NgxsModule.forRoot([DictionaryState])] <% } %>
|
|
33
34
|
});
|
|
34
35
|
|
|
35
36
|
store = TestBed.inject(Store);
|
package/schematics/src/starter-kit/files/store/dashboard/states/user/user.state.spec.ts__template__
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NgxsModule, Store } from '@ngxs/store';
|
|
1
|
+
import { <% if (isStandalone) { %> provideStore, <% } else { %> NgxsModule, <% } %> Store } from '@ngxs/store';
|
|
2
2
|
import { TestBed } from '@angular/core/testing';
|
|
3
3
|
import { UserStateModel, UserState } from './user.state';
|
|
4
4
|
import { SetUser } from './user.actions';
|
|
@@ -8,7 +8,8 @@ describe('[TEST]: User state', () => {
|
|
|
8
8
|
|
|
9
9
|
beforeEach(() => {
|
|
10
10
|
TestBed.configureTestingModule({
|
|
11
|
-
|
|
11
|
+
<% if (isStandalone) { %> providers: [provideStore([UserState])]
|
|
12
|
+
<% } else { %> imports: [NgxsModule.forRoot([UserState])] <% } %>
|
|
12
13
|
});
|
|
13
14
|
|
|
14
15
|
store = TestBed.inject(Store);
|
|
@@ -2,11 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.starterKit = void 0;
|
|
4
4
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
-
const normalize_options_1 = require("../utils/normalize-options");
|
|
6
5
|
const generate_utils_1 = require("../utils/generate-utils");
|
|
6
|
+
const ng_ast_utils_1 = require("../utils/ng-utils/ng-ast-utils");
|
|
7
|
+
const project_1 = require("../utils/ng-utils/project");
|
|
8
|
+
const normalize_options_1 = require("../utils/normalize-options");
|
|
7
9
|
function starterKit(options) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
return (host) => {
|
|
11
|
+
const mainFile = (0, project_1.getProjectMainFile)(host, options.project);
|
|
12
|
+
const isStandalone = (0, ng_ast_utils_1.isStandaloneApp)(host, mainFile);
|
|
13
|
+
const normalizedPath = (0, normalize_options_1.normalizePath)(options.path);
|
|
14
|
+
return (0, generate_utils_1.generateFiles)((0, schematics_1.url)('./files'), normalizedPath, Object.assign(Object.assign({}, options), { isStandalone }), options.spec);
|
|
15
|
+
};
|
|
10
16
|
}
|
|
11
17
|
exports.starterKit = starterKit;
|
|
12
18
|
//# sourceMappingURL=starter-kit.factory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"starter-kit.factory.js","sourceRoot":"","sources":["../../../../../packages/store/schematics/src/starter-kit/starter-kit.factory.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"starter-kit.factory.js","sourceRoot":"","sources":["../../../../../packages/store/schematics/src/starter-kit/starter-kit.factory.ts"],"names":[],"mappings":";;;AAAA,2DAA6D;AAC7D,4DAAwD;AACxD,iEAAiE;AACjE,uDAA+D;AAC/D,kEAA2D;AAG3D,SAAgB,UAAU,CAAC,OAAyB;IAClD,OAAO,CAAC,IAAU,EAAE,EAAE;QACpB,MAAM,QAAQ,GAAG,IAAA,4BAAkB,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAC3D,MAAM,YAAY,GAAG,IAAA,8BAAe,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAErD,MAAM,cAAc,GAAG,IAAA,iCAAa,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAEnD,OAAO,IAAA,8BAAa,EAClB,IAAA,gBAAG,EAAC,SAAS,CAAC,EACd,cAAc,kCACT,OAAO,KAAE,YAAY,KAC1B,OAAO,CAAC,IAAI,CACb,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAdD,gCAcC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TestBed } from '@angular/core/testing';
|
|
2
|
-
import { NgxsModule, Store } from '@ngxs/store';
|
|
2
|
+
import { <% if (isStandalone) { %> provideStore, <% } else { %> NgxsModule, <% } %> Store } from '@ngxs/store';
|
|
3
3
|
import { <%= classify(name) %>State, <%= classify(name) %>StateModel } from './<%= dasherize(name) %>.state';
|
|
4
4
|
|
|
5
5
|
describe('<%= classify(name) %> state', () => {
|
|
@@ -7,7 +7,8 @@ describe('<%= classify(name) %> state', () => {
|
|
|
7
7
|
|
|
8
8
|
beforeEach(() => {
|
|
9
9
|
TestBed.configureTestingModule({
|
|
10
|
-
|
|
10
|
+
<% if (isStandalone) { %> providers: [provideStore([<%= classify(name) %>State])]
|
|
11
|
+
<% } else { %> imports: [NgxsModule.forRoot([<%= classify(name) %>State])] <% } %>
|
|
11
12
|
});
|
|
12
13
|
|
|
13
14
|
store = TestBed.inject(Store);
|
|
@@ -2,19 +2,25 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.state = void 0;
|
|
4
4
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
+
const path_1 = require("path");
|
|
5
6
|
const properties_1 = require("../utils/common/properties");
|
|
6
|
-
const normalize_options_1 = require("../utils/normalize-options");
|
|
7
7
|
const generate_utils_1 = require("../utils/generate-utils");
|
|
8
|
-
const
|
|
8
|
+
const ng_ast_utils_1 = require("../utils/ng-utils/ng-ast-utils");
|
|
9
|
+
const project_1 = require("../utils/ng-utils/project");
|
|
10
|
+
const normalize_options_1 = require("../utils/normalize-options");
|
|
9
11
|
function state(options) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
return (host) => {
|
|
13
|
+
if ((0, properties_1.isEmpty)(options.name)) {
|
|
14
|
+
throw new schematics_1.SchematicsException('Invalid options, "name" is required.');
|
|
15
|
+
}
|
|
16
|
+
const mainFile = (0, project_1.getProjectMainFile)(host, options.project);
|
|
17
|
+
const isStandalone = (0, ng_ast_utils_1.isStandaloneApp)(host, mainFile);
|
|
18
|
+
const normalizedOptions = (0, normalize_options_1.normalizeBaseOptions)(options);
|
|
19
|
+
const path = options.flat
|
|
20
|
+
? normalizedOptions.path
|
|
21
|
+
: (0, path_1.join)(normalizedOptions.path, normalizedOptions.name);
|
|
22
|
+
return (0, generate_utils_1.generateFiles)((0, schematics_1.url)('./files'), path, Object.assign(Object.assign({}, options), { isStandalone }), options.spec);
|
|
23
|
+
};
|
|
18
24
|
}
|
|
19
25
|
exports.state = state;
|
|
20
26
|
//# sourceMappingURL=state.factory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.factory.js","sourceRoot":"","sources":["../../../../../packages/store/schematics/src/state/state.factory.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"state.factory.js","sourceRoot":"","sources":["../../../../../packages/store/schematics/src/state/state.factory.ts"],"names":[],"mappings":";;;AAAA,2DAAkF;AAClF,+BAA4B;AAC5B,2DAAqD;AACrD,4DAAwD;AACxD,iEAAiE;AACjE,uDAA+D;AAC/D,kEAAkE;AAGlE,SAAgB,KAAK,CAAC,OAAoB;IACxC,OAAO,CAAC,IAAU,EAAE,EAAE;QACpB,IAAI,IAAA,oBAAO,EAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACzB,MAAM,IAAI,gCAAmB,CAAC,sCAAsC,CAAC,CAAC;SACvE;QAED,MAAM,QAAQ,GAAG,IAAA,4BAAkB,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAC3D,MAAM,YAAY,GAAG,IAAA,8BAAe,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAErD,MAAM,iBAAiB,GAAG,IAAA,wCAAoB,EAAC,OAAO,CAAC,CAAC;QACxD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI;YACvB,CAAC,CAAC,iBAAiB,CAAC,IAAI;YACxB,CAAC,CAAC,IAAA,WAAI,EAAC,iBAAiB,CAAC,IAAI,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAEzD,OAAO,IAAA,8BAAa,EAAC,IAAA,gBAAG,EAAC,SAAS,CAAC,EAAE,IAAI,kCAAO,OAAO,KAAE,YAAY,KAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzF,CAAC,CAAC;AACJ,CAAC;AAhBD,sBAgBC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TestBed } from '@angular/core/testing';
|
|
2
|
-
import { NgxsModule, Store } from '@ngxs/store';
|
|
2
|
+
import { <% if (isStandalone) { %> provideStore, <% } else { %> NgxsModule, <% } %> Store } from '@ngxs/store';
|
|
3
3
|
import { <%= classify(name) %>State, <%= classify(name) %>StateModel } from './<%= dasherize(name) %>.state';
|
|
4
4
|
import { <%= classify(name) %>Action } from './<%= dasherize(name) %>.actions';
|
|
5
5
|
|
|
@@ -7,7 +7,8 @@ describe('<%= classify(name) %> store', () => {
|
|
|
7
7
|
let store: Store;
|
|
8
8
|
beforeEach(() => {
|
|
9
9
|
TestBed.configureTestingModule({
|
|
10
|
-
|
|
10
|
+
<% if (isStandalone) { %> providers: [provideStore([<%= classify(name) %>State])]
|
|
11
|
+
<% } else { %> imports: [NgxsModule.forRoot([<%= classify(name) %>State])] <% } %>
|
|
11
12
|
});
|
|
12
13
|
|
|
13
14
|
store = TestBed.inject(Store);
|
|
@@ -2,19 +2,25 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.store = void 0;
|
|
4
4
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
+
const path_1 = require("path");
|
|
5
6
|
const properties_1 = require("../utils/common/properties");
|
|
6
|
-
const normalize_options_1 = require("../utils/normalize-options");
|
|
7
7
|
const generate_utils_1 = require("../utils/generate-utils");
|
|
8
|
-
const
|
|
8
|
+
const ng_ast_utils_1 = require("../utils/ng-utils/ng-ast-utils");
|
|
9
|
+
const project_1 = require("../utils/ng-utils/project");
|
|
10
|
+
const normalize_options_1 = require("../utils/normalize-options");
|
|
9
11
|
function store(options) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
return (host) => {
|
|
13
|
+
if ((0, properties_1.isEmpty)(options.name)) {
|
|
14
|
+
throw new schematics_1.SchematicsException('Invalid options, "name" is required.');
|
|
15
|
+
}
|
|
16
|
+
const mainFile = (0, project_1.getProjectMainFile)(host, options.project);
|
|
17
|
+
const isStandalone = (0, ng_ast_utils_1.isStandaloneApp)(host, mainFile);
|
|
18
|
+
const normalizedOptions = (0, normalize_options_1.normalizeBaseOptions)(options);
|
|
19
|
+
const path = options.flat
|
|
20
|
+
? normalizedOptions.path
|
|
21
|
+
: (0, path_1.join)(normalizedOptions.path, normalizedOptions.name);
|
|
22
|
+
return (0, generate_utils_1.generateFiles)((0, schematics_1.url)('./files'), path, Object.assign(Object.assign({}, options), { isStandalone }), options.spec);
|
|
23
|
+
};
|
|
18
24
|
}
|
|
19
25
|
exports.store = store;
|
|
20
26
|
//# sourceMappingURL=store.factory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.factory.js","sourceRoot":"","sources":["../../../../../packages/store/schematics/src/store/store.factory.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"store.factory.js","sourceRoot":"","sources":["../../../../../packages/store/schematics/src/store/store.factory.ts"],"names":[],"mappings":";;;AAAA,2DAAkF;AAClF,+BAA4B;AAC5B,2DAAqD;AACrD,4DAAwD;AACxD,iEAAiE;AACjE,uDAA+D;AAC/D,kEAAkE;AAGlE,SAAgB,KAAK,CAAC,OAAoB;IACxC,OAAO,CAAC,IAAU,EAAE,EAAE;QACpB,IAAI,IAAA,oBAAO,EAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACzB,MAAM,IAAI,gCAAmB,CAAC,sCAAsC,CAAC,CAAC;SACvE;QAED,MAAM,QAAQ,GAAG,IAAA,4BAAkB,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAC3D,MAAM,YAAY,GAAG,IAAA,8BAAe,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAErD,MAAM,iBAAiB,GAAG,IAAA,wCAAoB,EAAC,OAAO,CAAC,CAAC;QACxD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI;YACvB,CAAC,CAAC,iBAAiB,CAAC,IAAI;YACxB,CAAC,CAAC,IAAA,WAAI,EAAC,iBAAiB,CAAC,IAAI,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAEzD,OAAO,IAAA,8BAAa,EAAC,IAAA,gBAAG,EAAC,SAAS,CAAC,EAAE,IAAI,kCAAO,OAAO,KAAE,YAAY,KAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzF,CAAC,CAAC;AACJ,CAAC;AAhBD,sBAgBC"}
|