From 696333726c2971b979823c2e5668c6a960b214e6 Mon Sep 17 00:00:00 2001 From: mehmet-erim Date: Mon, 16 Aug 2021 13:54:35 +0300 Subject: [PATCH] fix all testing problems --- npm/ng-packs/nx/ng-packs/angular.json | 1 + .../ng-packs/apps/dev-app/tsconfig.prod.json | 16 ++++ .../ng-packs/apps/dev-app/tsconfig.spec.json | 3 +- npm/ng-packs/nx/ng-packs/package.json | 5 +- .../src/lib/auth-wrapper.service.spec.ts | 16 ---- .../src/lib/tenant-box.service.spec.ts | 16 ---- .../packages/account-core/tsconfig.spec.json | 3 +- .../packages/account/tsconfig.spec.json | 3 +- .../packages/components/tsconfig.spec.json | 3 +- .../lib/tests/config-state.service.spec.ts | 62 +++++++++---- .../core/src/lib/tests/internal-store.spec.ts | 53 +++++++---- .../src/lib/tests/permission.guard.spec.ts | 93 ++++++++++++------- .../src/lib/tests/profile.service.spec.ts | 21 ++++- .../src/lib/tests/projection.strategy.spec.ts | 65 ++++++++----- .../core/src/lib/tests/rest.service.spec.ts | 41 +++++--- .../ng-packs/packages/core/tsconfig.spec.json | 3 +- .../feature-management/tsconfig.spec.json | 3 +- .../packages/identity/tsconfig.spec.json | 3 +- .../permission-management/tsconfig.spec.json | 3 +- .../packages/schematics/tsconfig.spec.json | 3 +- .../setting-management/tsconfig.spec.json | 3 +- .../tenant-management/tsconfig.spec.json | 3 +- .../auth-wrapper.component.spec.ts | 25 ----- .../tenant-box/tenant-box.component.spec.ts | 25 ----- .../packages/theme-basic/tsconfig.spec.json | 3 +- .../packages/theme-shared/tsconfig.spec.json | 3 +- npm/ng-packs/nx/ng-packs/tsconfig.base.json | 3 +- .../nx/ng-packs/tsconfig.lib.base.json | 3 +- 28 files changed, 272 insertions(+), 212 deletions(-) create mode 100644 npm/ng-packs/nx/ng-packs/apps/dev-app/tsconfig.prod.json delete mode 100644 npm/ng-packs/nx/ng-packs/packages/account-core/src/lib/auth-wrapper.service.spec.ts delete mode 100644 npm/ng-packs/nx/ng-packs/packages/account-core/src/lib/tenant-box.service.spec.ts delete mode 100644 npm/ng-packs/nx/ng-packs/packages/theme-basic/src/lib/components/account-layout/auth-wrapper/auth-wrapper.component.spec.ts delete mode 100644 npm/ng-packs/nx/ng-packs/packages/theme-basic/src/lib/components/account-layout/tenant-box/tenant-box.component.spec.ts diff --git a/npm/ng-packs/nx/ng-packs/angular.json b/npm/ng-packs/nx/ng-packs/angular.json index aabe80328e..f85343931a 100644 --- a/npm/ng-packs/nx/ng-packs/angular.json +++ b/npm/ng-packs/nx/ng-packs/angular.json @@ -228,6 +228,7 @@ }, "configurations": { "production": { + "tsConfig": "apps/dev-app/tsconfig.prod.json", "budgets": [ { "type": "initial", diff --git a/npm/ng-packs/nx/ng-packs/apps/dev-app/tsconfig.prod.json b/npm/ng-packs/nx/ng-packs/apps/dev-app/tsconfig.prod.json new file mode 100644 index 0000000000..fc2fc5abf6 --- /dev/null +++ b/npm/ng-packs/nx/ng-packs/apps/dev-app/tsconfig.prod.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.prod.json", + "compilerOptions": { + "outDir": "../../out-tsc/app", + "types": [], + "paths": {} + }, + "angularCompilerOptions": { + "enableIvy": true, + "fullTemplateTypeCheck": true, + "strictInjectionParameters": true + }, + "files": ["src/main.ts", "src/polyfills.ts"], + "include": ["src/**/*.ts"], + "exclude": ["src/test.ts", "src/**/*.spec.ts", "src/environments/*.ts"] +} diff --git a/npm/ng-packs/nx/ng-packs/apps/dev-app/tsconfig.spec.json b/npm/ng-packs/nx/ng-packs/apps/dev-app/tsconfig.spec.json index cfff29a544..a42c4b02fb 100644 --- a/npm/ng-packs/nx/ng-packs/apps/dev-app/tsconfig.spec.json +++ b/npm/ng-packs/nx/ng-packs/apps/dev-app/tsconfig.spec.json @@ -3,7 +3,8 @@ "compilerOptions": { "outDir": "../../dist/out-tsc", "module": "commonjs", - "types": ["jest", "node"] + "types": ["jest", "node"], + "esModuleInterop": true }, "files": ["src/test-setup.ts"], "include": ["**/*.spec.ts", "**/*.d.ts"] diff --git a/npm/ng-packs/nx/ng-packs/package.json b/npm/ng-packs/nx/ng-packs/package.json index cd8caf0538..a6410e3dd7 100644 --- a/npm/ng-packs/nx/ng-packs/package.json +++ b/npm/ng-packs/nx/ng-packs/package.json @@ -7,7 +7,9 @@ "nx": "nx", "start": "ng serve", "build": "ng build", - "test": "ng test", + "build:all": "nx run-many --target=build --all --exclude=dev-app,schematics", + "test": "ng test --detect-open-handles=true --run-in-band=true --watch-all=true", + "test:all": "nx run-many --target=test --all", "lint": "nx workspace-lint && ng lint", "e2e": "ng e2e", "affected:apps": "nx affected:apps", @@ -25,7 +27,6 @@ "workspace-generator": "nx workspace-generator", "dep-graph": "nx dep-graph", "help": "nx help", - "build-all-packages": "nx run-many --target=build --all --exclude=dev-app,schematics", "compile:ivy": "yarn ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points --tsconfig './tsconfig.prod.json' --source node_modules", "postinstall": "node ./decorate-angular-cli.js && yarn compile:ivy" }, diff --git a/npm/ng-packs/nx/ng-packs/packages/account-core/src/lib/auth-wrapper.service.spec.ts b/npm/ng-packs/nx/ng-packs/packages/account-core/src/lib/auth-wrapper.service.spec.ts deleted file mode 100644 index c09dfff769..0000000000 --- a/npm/ng-packs/nx/ng-packs/packages/account-core/src/lib/auth-wrapper.service.spec.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { TestBed } from '@angular/core/testing'; - -import { AuthWrapperService } from './auth-wrapper.service'; - -describe('AuthWrapperService', () => { - let service: AuthWrapperService; - - beforeEach(() => { - TestBed.configureTestingModule({}); - service = TestBed.inject(AuthWrapperService); - }); - - it('should be created', () => { - expect(service).toBeTruthy(); - }); -}); diff --git a/npm/ng-packs/nx/ng-packs/packages/account-core/src/lib/tenant-box.service.spec.ts b/npm/ng-packs/nx/ng-packs/packages/account-core/src/lib/tenant-box.service.spec.ts deleted file mode 100644 index 521623f116..0000000000 --- a/npm/ng-packs/nx/ng-packs/packages/account-core/src/lib/tenant-box.service.spec.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { TestBed } from '@angular/core/testing'; - -import { TenantBoxService } from './tenant-box.service'; - -describe('TenantBoxService', () => { - let service: TenantBoxService; - - beforeEach(() => { - TestBed.configureTestingModule({}); - service = TestBed.inject(TenantBoxService); - }); - - it('should be created', () => { - expect(service).toBeTruthy(); - }); -}); diff --git a/npm/ng-packs/nx/ng-packs/packages/account-core/tsconfig.spec.json b/npm/ng-packs/nx/ng-packs/packages/account-core/tsconfig.spec.json index cfff29a544..a42c4b02fb 100644 --- a/npm/ng-packs/nx/ng-packs/packages/account-core/tsconfig.spec.json +++ b/npm/ng-packs/nx/ng-packs/packages/account-core/tsconfig.spec.json @@ -3,7 +3,8 @@ "compilerOptions": { "outDir": "../../dist/out-tsc", "module": "commonjs", - "types": ["jest", "node"] + "types": ["jest", "node"], + "esModuleInterop": true }, "files": ["src/test-setup.ts"], "include": ["**/*.spec.ts", "**/*.d.ts"] diff --git a/npm/ng-packs/nx/ng-packs/packages/account/tsconfig.spec.json b/npm/ng-packs/nx/ng-packs/packages/account/tsconfig.spec.json index cfff29a544..a42c4b02fb 100644 --- a/npm/ng-packs/nx/ng-packs/packages/account/tsconfig.spec.json +++ b/npm/ng-packs/nx/ng-packs/packages/account/tsconfig.spec.json @@ -3,7 +3,8 @@ "compilerOptions": { "outDir": "../../dist/out-tsc", "module": "commonjs", - "types": ["jest", "node"] + "types": ["jest", "node"], + "esModuleInterop": true }, "files": ["src/test-setup.ts"], "include": ["**/*.spec.ts", "**/*.d.ts"] diff --git a/npm/ng-packs/nx/ng-packs/packages/components/tsconfig.spec.json b/npm/ng-packs/nx/ng-packs/packages/components/tsconfig.spec.json index cfff29a544..a42c4b02fb 100644 --- a/npm/ng-packs/nx/ng-packs/packages/components/tsconfig.spec.json +++ b/npm/ng-packs/nx/ng-packs/packages/components/tsconfig.spec.json @@ -3,7 +3,8 @@ "compilerOptions": { "outDir": "../../dist/out-tsc", "module": "commonjs", - "types": ["jest", "node"] + "types": ["jest", "node"], + "esModuleInterop": true }, "files": ["src/test-setup.ts"], "include": ["**/*.spec.ts", "**/*.d.ts"] diff --git a/npm/ng-packs/nx/ng-packs/packages/core/src/lib/tests/config-state.service.spec.ts b/npm/ng-packs/nx/ng-packs/packages/core/src/lib/tests/config-state.service.spec.ts index dad7a2c524..c1e00550db 100644 --- a/npm/ng-packs/nx/ng-packs/packages/core/src/lib/tests/config-state.service.spec.ts +++ b/npm/ng-packs/nx/ng-packs/packages/core/src/lib/tests/config-state.service.spec.ts @@ -1,11 +1,12 @@ +import { CoreTestingModule } from '@abp/ng.core/testing'; import { createServiceFactory, SpectatorService } from '@ngneat/spectator/jest'; -import { ApplicationConfiguration } from '../models/application-configuration'; +import { Store } from '@ngxs/store'; import { ApplicationConfigurationDto, CurrentUserDto, } from '../proxy/volo/abp/asp-net-core/mvc/application-configurations/models'; import { ConfigStateService } from '../services'; -import { CoreTestingModule } from '@abp/ng.core/testing'; +import { CORE_OPTIONS } from '../tokens'; export const CONFIG_STATE_DATA = { environment: { @@ -107,6 +108,10 @@ describe('ConfigState', () => { const createService = createServiceFactory({ service: ConfigStateService, imports: [CoreTestingModule.withConfig()], + providers: [ + { provide: CORE_OPTIONS, useValue: { skipGetAppConfiguration: true } }, + { provide: Store, useValue: {} }, + ], }); beforeEach(() => { @@ -119,29 +124,35 @@ describe('ConfigState', () => { describe('#getAll', () => { it('should return CONFIG_STATE_DATA', () => { expect(configState.getAll()).toEqual(CONFIG_STATE_DATA); - configState.getAll$().subscribe(data => expect(data).toEqual(CONFIG_STATE_DATA)); + configState + .getAll$() + .subscribe((data) => expect(data).toEqual(CONFIG_STATE_DATA)); }); }); describe('#getOne', () => { it('should return one property', () => { - expect(configState.getOne('localization')).toEqual(CONFIG_STATE_DATA.localization); + expect(configState.getOne('localization')).toEqual( + CONFIG_STATE_DATA.localization + ); configState .getOne$('localization') - .subscribe(localization => expect(localization).toEqual(CONFIG_STATE_DATA.localization)); + .subscribe((localization) => + expect(localization).toEqual(CONFIG_STATE_DATA.localization) + ); }); }); describe('#getDeep', () => { it('should return deeper', () => { expect(configState.getDeep('localization.languages')).toEqual( - CONFIG_STATE_DATA.localization.languages, + CONFIG_STATE_DATA.localization.languages ); configState .getDeep$('localization.languages') - .subscribe(languages => - expect(languages).toEqual(CONFIG_STATE_DATA.localization.languages), + .subscribe((languages) => + expect(languages).toEqual(CONFIG_STATE_DATA.localization.languages) ); expect(configState.getDeep('test')).toBeFalsy(); @@ -151,22 +162,30 @@ describe('ConfigState', () => { describe('#getFeature', () => { it('should return a setting', () => { expect(configState.getFeature('Chat.Enable')).toEqual( - CONFIG_STATE_DATA.features.values['Chat.Enable'], + CONFIG_STATE_DATA.features.values['Chat.Enable'] ); configState .getFeature$('Chat.Enable') - .subscribe(data => expect(data).toEqual(CONFIG_STATE_DATA.features.values['Chat.Enable'])); + .subscribe((data) => + expect(data).toEqual(CONFIG_STATE_DATA.features.values['Chat.Enable']) + ); }); }); describe('#getSetting', () => { it('should return a setting', () => { - expect(configState.getSetting('Abp.Localization.DefaultLanguage')).toEqual( - CONFIG_STATE_DATA.setting.values['Abp.Localization.DefaultLanguage'], + expect( + configState.getSetting('Abp.Localization.DefaultLanguage') + ).toEqual( + CONFIG_STATE_DATA.setting.values['Abp.Localization.DefaultLanguage'] ); - configState.getSetting$('Abp.Localization.DefaultLanguage').subscribe(data => { - expect(data).toEqual(CONFIG_STATE_DATA.setting.values['Abp.Localization.DefaultLanguage']); - }); + configState + .getSetting$('Abp.Localization.DefaultLanguage') + .subscribe((data) => { + expect(data).toEqual( + CONFIG_STATE_DATA.setting.values['Abp.Localization.DefaultLanguage'] + ); + }); }); }); @@ -177,9 +196,14 @@ describe('ConfigState', () => { ${'Localization'} | ${{ 'Abp.Localization.DefaultLanguage': 'en' }} ${'X'} | ${{}} ${'localization'} | ${{}} - `('should return $expected when keyword is given as $keyword', ({ keyword, expected }) => { - expect(configState.getSettings(keyword)).toEqual(expected); - configState.getSettings$(keyword).subscribe(data => expect(data).toEqual(expected)); - }); + `( + 'should return $expected when keyword is given as $keyword', + ({ keyword, expected }) => { + expect(configState.getSettings(keyword)).toEqual(expected); + configState + .getSettings$(keyword) + .subscribe((data) => expect(data).toEqual(expected)); + } + ); }); }); diff --git a/npm/ng-packs/nx/ng-packs/packages/core/src/lib/tests/internal-store.spec.ts b/npm/ng-packs/nx/ng-packs/packages/core/src/lib/tests/internal-store.spec.ts index c0728db069..7a13adf9e4 100644 --- a/npm/ng-packs/nx/ng-packs/packages/core/src/lib/tests/internal-store.spec.ts +++ b/npm/ng-packs/nx/ng-packs/packages/core/src/lib/tests/internal-store.spec.ts @@ -17,13 +17,17 @@ const mockInitialState = { type MockState = typeof mockInitialState; -const deepPatch1: DeepPartial = { foo: { bar: { baz: [() => {}] } } }; +const deepPatch1: DeepPartial = { + foo: { bar: { baz: [() => {}] } }, +}; const deepPatchExpected1: MockState = clone(mockInitialState); deepPatchExpected1.foo.bar.baz = deepPatch1.foo.bar.baz; -const deepPatch2: DeepPartial = { foo: { bar: { qux: Promise.resolve() } } }; +const deepPatch2: DeepPartial = { + foo: { bar: { qux: Promise.resolve() } }, +}; const deepPatchExpected2: MockState = clone(mockInitialState); -deepPatchExpected2.foo.bar.qux = deepPatch2.foo.bar.qux; +deepPatchExpected2.foo.bar.qux = deepPatch2.foo.bar.qux as any; const deepPatch3: DeepPartial = { foo: { n: 1 } }; const deepPatchExpected3: MockState = clone(mockInitialState); @@ -49,7 +53,9 @@ const patch2: Partial = { const patchExpected2: MockState = clone(mockInitialState); patchExpected2.foo = patch2.foo; -const patch3: Partial = { foo: { n: 1 } as typeof mockInitialState.foo }; +const patch3: Partial = { + foo: { n: 1 } as typeof mockInitialState.foo, +}; const patchExpected3: MockState = clone(mockInitialState); patchExpected3.foo = patch3.foo; @@ -76,10 +82,13 @@ describe('Internal Store', () => { async ({ selector, expected }) => { const store = new InternalStore(mockInitialState); - const value = await store.sliceState(selector).pipe(take(1)).toPromise(); + const value = await store + .sliceState(selector) + .pipe(take(1)) + .toPromise(); expect(value).toEqual(expected); - }, + } ); }); @@ -91,13 +100,16 @@ describe('Internal Store', () => { ${deepPatch3} | ${deepPatchExpected3} ${deepPatch4} | ${deepPatchExpected4} ${deepPatch5} | ${deepPatchExpected5} - `('should set state as $expected when patch is $patch', ({ patch, expected }) => { - const store = new InternalStore(mockInitialState); + `( + 'should set state as $expected when patch is $patch', + ({ patch, expected }) => { + const store = new InternalStore(mockInitialState); - store.deepPatch(patch); + store.deepPatch(patch); - expect(store.state).toEqual(expected); - }); + expect(store.state).toEqual(expected); + } + ); }); describe('patchState', () => { @@ -108,22 +120,25 @@ describe('Internal Store', () => { ${patch3} | ${patchExpected3} ${patch4} | ${patchExpected4} ${patch5} | ${patchExpected5} - `('should set state as $expected when patch is $patch', ({ patch, expected }) => { - const store = new InternalStore(mockInitialState); + `( + 'should set state as $expected when patch is $patch', + ({ patch, expected }) => { + const store = new InternalStore(mockInitialState); - store.patch(patch); + store.patch(patch); - expect(store.state).toEqual(expected); - }); + expect(store.state).toEqual(expected); + } + ); }); describe('sliceUpdate', () => { - it('should return slice of update$ based on selector', done => { + it('should return slice of update$ based on selector', (done) => { const store = new InternalStore(mockInitialState); - const onQux$ = store.sliceUpdate(state => state.foo.bar.qux); + const onQux$ = store.sliceUpdate((state) => state.foo.bar.qux); - onQux$.pipe(take(1)).subscribe(value => { + onQux$.pipe(take(1)).subscribe((value) => { expect(value).toEqual(deepPatch2.foo.bar.qux); done(); }); diff --git a/npm/ng-packs/nx/ng-packs/packages/core/src/lib/tests/permission.guard.spec.ts b/npm/ng-packs/nx/ng-packs/packages/core/src/lib/tests/permission.guard.spec.ts index ef5b3cd1ab..bcd974d8e0 100644 --- a/npm/ng-packs/nx/ng-packs/packages/core/src/lib/tests/permission.guard.spec.ts +++ b/npm/ng-packs/nx/ng-packs/packages/core/src/lib/tests/permission.guard.spec.ts @@ -1,13 +1,19 @@ +import { CoreTestingModule } from '@abp/ng.core/testing'; import { APP_BASE_HREF } from '@angular/common'; import { Component } from '@angular/core'; import { RouterModule } from '@angular/router'; -import { createServiceFactory, SpectatorService, SpyObject } from '@ngneat/spectator/jest'; +import { + createServiceFactory, + SpectatorService, + SpyObject, +} from '@ngneat/spectator/jest'; import { Actions, Store } from '@ngxs/store'; import { of } from 'rxjs'; import { RestOccurError } from '../actions'; import { PermissionGuard } from '../guards/permission.guard'; -import { RoutesService } from '../services/routes.service'; import { PermissionService } from '../services'; +import { RoutesService } from '../services/routes.service'; +import { CORE_OPTIONS } from '../tokens'; describe('PermissionGuard', () => { let spectator: SpectatorService; @@ -24,15 +30,19 @@ describe('PermissionGuard', () => { mocks: [PermissionService, Store], declarations: [DummyComponent], imports: [ - RouterModule.forRoot([ - { - path: 'test', - component: DummyComponent, - data: { - requiredPolicy: 'TestPolicy', - }, - }, -], { relativeLinkResolution: 'legacy' }), + CoreTestingModule.withConfig(), + RouterModule.forRoot( + [ + { + path: 'test', + component: DummyComponent, + data: { + requiredPolicy: 'TestPolicy', + }, + }, + ], + { relativeLinkResolution: 'legacy' } + ), ], providers: [ { @@ -47,6 +57,7 @@ describe('PermissionGuard', () => { }, }, }, + { provide: CORE_OPTIONS, useValue: { skipGetAppConfiguration: true } }, ], }); @@ -58,28 +69,34 @@ describe('PermissionGuard', () => { permissionService = spectator.inject(PermissionService); }); - it('should return true when the grantedPolicy is true', done => { + it('should return true when the grantedPolicy is true', (done) => { permissionService.getGrantedPolicy$.andReturn(of(true)); const spy = jest.spyOn(store, 'dispatch'); - guard.canActivate({ data: { requiredPolicy: 'test' } } as any, null).subscribe(res => { - expect(res).toBe(true); - expect(spy.mock.calls).toHaveLength(0); - done(); - }); + guard + .canActivate({ data: { requiredPolicy: 'test' } } as any, null) + .subscribe((res) => { + expect(res).toBe(true); + expect(spy.mock.calls).toHaveLength(0); + done(); + }); }); - it('should return false and dispatch RestOccurError when the grantedPolicy is false', done => { + it('should return false and dispatch RestOccurError when the grantedPolicy is false', (done) => { permissionService.getGrantedPolicy$.andReturn(of(false)); const spy = jest.spyOn(store, 'dispatch'); - guard.canActivate({ data: { requiredPolicy: 'test' } } as any, null).subscribe(res => { - expect(res).toBe(false); - expect(spy.mock.calls[0][0] instanceof RestOccurError).toBeTruthy(); - expect((spy.mock.calls[0][0] as RestOccurError).payload).toEqual({ status: 403 }); - done(); - }); + guard + .canActivate({ data: { requiredPolicy: 'test' } } as any, null) + .subscribe((res) => { + expect(res).toBe(false); + expect(spy.mock.calls[0][0] instanceof RestOccurError).toBeTruthy(); + expect((spy.mock.calls[0][0] as RestOccurError).payload).toEqual({ + status: 403, + }); + done(); + }); }); - it('should check the requiredPolicy from RoutesService', done => { + it('should check the requiredPolicy from RoutesService', (done) => { routes.add([ { path: '/test', @@ -87,23 +104,29 @@ describe('PermissionGuard', () => { requiredPolicy: 'TestPolicy', }, ]); - permissionService.getGrantedPolicy$.mockImplementation(policy => of(policy === 'TestPolicy')); - guard.canActivate({ data: {} } as any, { url: 'test' } as any).subscribe(result => { - expect(result).toBe(true); - done(); - }); + permissionService.getGrantedPolicy$.mockImplementation((policy) => + of(policy === 'TestPolicy') + ); + guard + .canActivate({ data: {} } as any, { url: 'test' } as any) + .subscribe((result) => { + expect(result).toBe(true); + done(); + }); }); - it('should return Observable if RoutesService does not have requiredPolicy for given URL', done => { + it('should return Observable if RoutesService does not have requiredPolicy for given URL', (done) => { routes.add([ { path: '/test', name: 'Test', }, ]); - guard.canActivate({ data: {} } as any, { url: 'test' } as any).subscribe(result => { - expect(result).toBe(true); - done(); - }); + guard + .canActivate({ data: {} } as any, { url: 'test' } as any) + .subscribe((result) => { + expect(result).toBe(true); + done(); + }); }); }); diff --git a/npm/ng-packs/nx/ng-packs/packages/core/src/lib/tests/profile.service.spec.ts b/npm/ng-packs/nx/ng-packs/packages/core/src/lib/tests/profile.service.spec.ts index 33106e0e29..32dcf030d7 100644 --- a/npm/ng-packs/nx/ng-packs/packages/core/src/lib/tests/profile.service.spec.ts +++ b/npm/ng-packs/nx/ng-packs/packages/core/src/lib/tests/profile.service.spec.ts @@ -1,4 +1,9 @@ -import { createHttpFactory, HttpMethod, SpectatorHttp, SpyObject } from '@ngneat/spectator/jest'; +import { + createHttpFactory, + HttpMethod, + SpectatorHttp, + SpyObject, +} from '@ngneat/spectator/jest'; import { Store } from '@ngxs/store'; import { EnvironmentService, ProfileService, RestService } from '../services'; import { CORE_OPTIONS } from '../tokens'; @@ -8,7 +13,7 @@ describe('ProfileService', () => { let environmentService: SpyObject; const createHttp = createHttpFactory({ - dataService: ProfileService, + service: ProfileService, providers: [ RestService, { provide: CORE_OPTIONS, useValue: {} }, @@ -26,7 +31,10 @@ describe('ProfileService', () => { it('should send a GET to my-profile API', () => { spectator.service.get().subscribe(); - spectator.expectOne('https://abp.io/api/identity/my-profile', HttpMethod.GET); + spectator.expectOne( + 'https://abp.io/api/identity/my-profile', + HttpMethod.GET + ); }); it('should send a POST to change-password API', () => { @@ -34,7 +42,7 @@ describe('ProfileService', () => { spectator.service.changePassword(mock).subscribe(); const req = spectator.expectOne( 'https://abp.io/api/identity/my-profile/change-password', - HttpMethod.POST, + HttpMethod.POST ); expect(req.request.body).toEqual(mock); }); @@ -50,7 +58,10 @@ describe('ProfileService', () => { hasPassword: false, }; spectator.service.update(mock).subscribe(); - const req = spectator.expectOne('https://abp.io/api/identity/my-profile', HttpMethod.PUT); + const req = spectator.expectOne( + 'https://abp.io/api/identity/my-profile', + HttpMethod.PUT + ); expect(req.request.body).toEqual(mock); }); }); diff --git a/npm/ng-packs/nx/ng-packs/packages/core/src/lib/tests/projection.strategy.spec.ts b/npm/ng-packs/nx/ng-packs/packages/core/src/lib/tests/projection.strategy.spec.ts index a0b3bb61bb..8c5cf1fc3a 100644 --- a/npm/ng-packs/nx/ng-packs/packages/core/src/lib/tests/projection.strategy.spec.ts +++ b/npm/ng-packs/nx/ng-packs/packages/core/src/lib/tests/projection.strategy.spec.ts @@ -46,7 +46,9 @@ describe('ComponentProjectionStrategy', () => { beforeEach(() => { spectator = createComponent({}); - containerStrategy = CONTAINER_STRATEGY.Clear(spectator.component.containerRef); + containerStrategy = CONTAINER_STRATEGY.Clear( + spectator.component.containerRef + ); }); afterEach(() => { @@ -56,8 +58,11 @@ describe('ComponentProjectionStrategy', () => { describe('#injectContent', () => { it('should should insert content into container and return a ComponentRef', () => { - const strategy = new ComponentProjectionStrategy(TestComponent, containerStrategy); - componentRef = strategy.injectContent(spectator); + const strategy = new ComponentProjectionStrategy( + TestComponent, + containerStrategy + ); + componentRef = strategy.injectContent({ get: spectator.inject }); spectator.detectChanges(); const div = spectator.query('div.foo'); @@ -70,9 +75,9 @@ describe('ComponentProjectionStrategy', () => { const strategy = new ComponentProjectionStrategy( TestComponent, containerStrategy, - contextStrategy, + contextStrategy ); - componentRef = strategy.injectContent(spectator); + componentRef = strategy.injectContent({ get: spectator.inject }); spectator.detectChanges(); const div = spectator.query('div.foo'); @@ -114,7 +119,7 @@ describe('RootComponentProjectionStrategy', () => { describe('#injectContent', () => { it('should should insert content into body and return a ComponentRef', () => { const strategy = new RootComponentProjectionStrategy(TestComponent); - componentRef = strategy.injectContent(spectator); + componentRef = strategy.injectContent({ get: spectator.inject }); spectator.detectChanges(); const div = document.querySelector('body > ng-component > div.foo'); @@ -126,8 +131,11 @@ describe('RootComponentProjectionStrategy', () => { it('should be able to map context to projected component', () => { const contextStrategy = CONTEXT_STRATEGY.Component({ bar: 'bar' }); - const strategy = new RootComponentProjectionStrategy(TestComponent, contextStrategy); - componentRef = strategy.injectContent(spectator); + const strategy = new RootComponentProjectionStrategy( + TestComponent, + contextStrategy + ); + componentRef = strategy.injectContent({ get: spectator.inject }); spectator.detectChanges(); const div = document.querySelector('body > ng-component > div.foo'); @@ -166,7 +174,9 @@ describe('TemplateProjectionStrategy', () => { beforeEach(() => { spectator = createComponent({}); - containerStrategy = CONTAINER_STRATEGY.Clear(spectator.component.containerRef); + containerStrategy = CONTAINER_STRATEGY.Clear( + spectator.component.containerRef + ); }); afterEach(() => { @@ -177,7 +187,10 @@ describe('TemplateProjectionStrategy', () => { describe('#injectContent', () => { it('should should insert content into container and return an EmbeddedViewRef', () => { const templateRef = spectator.component.templateRef; - const strategy = new TemplateProjectionStrategy(templateRef, containerStrategy); + const strategy = new TemplateProjectionStrategy( + templateRef, + containerStrategy + ); embeddedViewRef = strategy.injectContent(); spectator.detectChanges(); @@ -194,11 +207,13 @@ describe('TemplateProjectionStrategy', () => { it('should be able to map context to projected template', () => { const templateRef = spectator.component.templateRef; - const contextStrategy = CONTEXT_STRATEGY.Template({ $implicit: 'bar' }); + const contextStrategy = CONTEXT_STRATEGY.Template({ + $implicit: 'bar', + }); const strategy = new TemplateProjectionStrategy( templateRef, containerStrategy, - contextStrategy, + contextStrategy ); embeddedViewRef = strategy.injectContent(); spectator.detectChanges(); @@ -212,7 +227,7 @@ describe('TemplateProjectionStrategy', () => { describe('PROJECTION_STRATEGY', () => { const content = undefined; - const containerRef = ({ length: 0 } as any) as ViewContainerRef; + const containerRef = { length: 0 } as any as ViewContainerRef; let context: any; test.each` @@ -227,9 +242,13 @@ describe('PROJECTION_STRATEGY', () => { 'should successfully map $name to $Strategy.name with $containerStrategy.name container strategy and $contextStrategy.name context strategy', ({ name, Strategy, containerStrategy }) => { expect(PROJECTION_STRATEGY[name](content, containerRef, context)).toEqual( - new Strategy(content, containerStrategy(containerRef), CONTEXT_STRATEGY.None()), + new Strategy( + content, + containerStrategy(containerRef), + CONTEXT_STRATEGY.None() + ) ); - }, + } ); test.each` name | Strategy | domStrategy @@ -238,9 +257,9 @@ describe('PROJECTION_STRATEGY', () => { 'should successfully map $name to $Strategy.name with $domStrategy.name dom strategy', ({ name, Strategy, domStrategy }) => { expect(PROJECTION_STRATEGY[name](content, context)).toEqual( - new Strategy(content, CONTEXT_STRATEGY.None(), domStrategy()), + new Strategy(content, CONTEXT_STRATEGY.None(), domStrategy()) ); - }, + } ); test.each` @@ -256,9 +275,13 @@ describe('PROJECTION_STRATEGY', () => { ({ name, Strategy, containerStrategy, contextStrategy }) => { context = { x: true }; expect(PROJECTION_STRATEGY[name](content, containerRef, context)).toEqual( - new Strategy(content, containerStrategy(containerRef), contextStrategy(context)), + new Strategy( + content, + containerStrategy(containerRef), + contextStrategy(context) + ) ); - }, + } ); test.each` @@ -269,8 +292,8 @@ describe('PROJECTION_STRATEGY', () => { ({ name, Strategy, domStrategy, contextStrategy }) => { context = { x: true }; expect(PROJECTION_STRATEGY[name](content, context)).toEqual( - new Strategy(content, contextStrategy(context), domStrategy()), + new Strategy(content, contextStrategy(context), domStrategy()) ); - }, + } ); }); diff --git a/npm/ng-packs/nx/ng-packs/packages/core/src/lib/tests/rest.service.spec.ts b/npm/ng-packs/nx/ng-packs/packages/core/src/lib/tests/rest.service.spec.ts index e9d0ab5ebc..881f85a3c4 100644 --- a/npm/ng-packs/nx/ng-packs/packages/core/src/lib/tests/rest.service.spec.ts +++ b/npm/ng-packs/nx/ng-packs/packages/core/src/lib/tests/rest.service.spec.ts @@ -1,4 +1,9 @@ -import { createHttpFactory, HttpMethod, SpectatorHttp, SpyObject } from '@ngneat/spectator/jest'; +import { + createHttpFactory, + HttpMethod, + SpectatorHttp, + SpyObject, +} from '@ngneat/spectator/jest'; import { Store } from '@ngxs/store'; import { OAuthService } from 'angular-oauth2-oidc'; import { of, throwError } from 'rxjs'; @@ -15,8 +20,11 @@ describe('HttpClient testing', () => { const api = 'https://abp.io'; const createHttp = createHttpFactory({ - dataService: RestService, - providers: [EnvironmentService, { provide: CORE_OPTIONS, useValue: { environment: {} } }], + service: RestService, + providers: [ + EnvironmentService, + { provide: CORE_OPTIONS, useValue: { environment: {} } }, + ], mocks: [OAuthService, Store], }); @@ -57,7 +65,11 @@ describe('HttpClient testing', () => { test('should use the specific api', () => { spectator.service - .request({ method: HttpMethod.GET, url: '/test' }, null, 'http://test.api') + .request( + { method: HttpMethod.GET, url: '/test' }, + null, + 'http://test.api' + ) .subscribe(); spectator.expectOne('http://test.api' + '/test', HttpMethod.GET); }); @@ -70,10 +82,12 @@ describe('HttpClient testing', () => { spectator.expectOne('bar' + '/test', HttpMethod.GET); }); - test('should complete upon successful request', done => { + test('should complete upon successful request', (done) => { const complete = jest.fn(done); - spectator.service.request({ method: HttpMethod.GET, url: '/test' }).subscribe({ complete }); + spectator.service + .request({ method: HttpMethod.GET, url: '/test' }) + .subscribe({ complete }); const req = spectator.expectOne(api + '/test', HttpMethod.GET); spectator.flushAll([req], [{}]); @@ -83,13 +97,16 @@ describe('HttpClient testing', () => { const spy = jest.spyOn(store, 'dispatch'); spectator.service - .request({ method: HttpMethod.GET, url: '/test' }, { observe: Rest.Observe.Events }) + .request( + { method: HttpMethod.GET, url: '/test' }, + { observe: Rest.Observe.Events } + ) .pipe( - catchError(err => { + catchError((err) => { expect(err).toBeTruthy(); expect(spy).toHaveBeenCalled(); return of(null); - }), + }) ) .subscribe(); @@ -103,14 +120,14 @@ describe('HttpClient testing', () => { spectator.service .request( { method: HttpMethod.GET, url: '/test' }, - { observe: Rest.Observe.Events, skipHandleError: true }, + { observe: Rest.Observe.Events, skipHandleError: true } ) .pipe( - catchError(err => { + catchError((err) => { expect(err).toBeTruthy(); expect(spy).toHaveBeenCalledTimes(0); return of(null); - }), + }) ) .subscribe(); diff --git a/npm/ng-packs/nx/ng-packs/packages/core/tsconfig.spec.json b/npm/ng-packs/nx/ng-packs/packages/core/tsconfig.spec.json index cfff29a544..a42c4b02fb 100644 --- a/npm/ng-packs/nx/ng-packs/packages/core/tsconfig.spec.json +++ b/npm/ng-packs/nx/ng-packs/packages/core/tsconfig.spec.json @@ -3,7 +3,8 @@ "compilerOptions": { "outDir": "../../dist/out-tsc", "module": "commonjs", - "types": ["jest", "node"] + "types": ["jest", "node"], + "esModuleInterop": true }, "files": ["src/test-setup.ts"], "include": ["**/*.spec.ts", "**/*.d.ts"] diff --git a/npm/ng-packs/nx/ng-packs/packages/feature-management/tsconfig.spec.json b/npm/ng-packs/nx/ng-packs/packages/feature-management/tsconfig.spec.json index cfff29a544..a42c4b02fb 100644 --- a/npm/ng-packs/nx/ng-packs/packages/feature-management/tsconfig.spec.json +++ b/npm/ng-packs/nx/ng-packs/packages/feature-management/tsconfig.spec.json @@ -3,7 +3,8 @@ "compilerOptions": { "outDir": "../../dist/out-tsc", "module": "commonjs", - "types": ["jest", "node"] + "types": ["jest", "node"], + "esModuleInterop": true }, "files": ["src/test-setup.ts"], "include": ["**/*.spec.ts", "**/*.d.ts"] diff --git a/npm/ng-packs/nx/ng-packs/packages/identity/tsconfig.spec.json b/npm/ng-packs/nx/ng-packs/packages/identity/tsconfig.spec.json index cfff29a544..a42c4b02fb 100644 --- a/npm/ng-packs/nx/ng-packs/packages/identity/tsconfig.spec.json +++ b/npm/ng-packs/nx/ng-packs/packages/identity/tsconfig.spec.json @@ -3,7 +3,8 @@ "compilerOptions": { "outDir": "../../dist/out-tsc", "module": "commonjs", - "types": ["jest", "node"] + "types": ["jest", "node"], + "esModuleInterop": true }, "files": ["src/test-setup.ts"], "include": ["**/*.spec.ts", "**/*.d.ts"] diff --git a/npm/ng-packs/nx/ng-packs/packages/permission-management/tsconfig.spec.json b/npm/ng-packs/nx/ng-packs/packages/permission-management/tsconfig.spec.json index cfff29a544..a42c4b02fb 100644 --- a/npm/ng-packs/nx/ng-packs/packages/permission-management/tsconfig.spec.json +++ b/npm/ng-packs/nx/ng-packs/packages/permission-management/tsconfig.spec.json @@ -3,7 +3,8 @@ "compilerOptions": { "outDir": "../../dist/out-tsc", "module": "commonjs", - "types": ["jest", "node"] + "types": ["jest", "node"], + "esModuleInterop": true }, "files": ["src/test-setup.ts"], "include": ["**/*.spec.ts", "**/*.d.ts"] diff --git a/npm/ng-packs/nx/ng-packs/packages/schematics/tsconfig.spec.json b/npm/ng-packs/nx/ng-packs/packages/schematics/tsconfig.spec.json index cfff29a544..a42c4b02fb 100644 --- a/npm/ng-packs/nx/ng-packs/packages/schematics/tsconfig.spec.json +++ b/npm/ng-packs/nx/ng-packs/packages/schematics/tsconfig.spec.json @@ -3,7 +3,8 @@ "compilerOptions": { "outDir": "../../dist/out-tsc", "module": "commonjs", - "types": ["jest", "node"] + "types": ["jest", "node"], + "esModuleInterop": true }, "files": ["src/test-setup.ts"], "include": ["**/*.spec.ts", "**/*.d.ts"] diff --git a/npm/ng-packs/nx/ng-packs/packages/setting-management/tsconfig.spec.json b/npm/ng-packs/nx/ng-packs/packages/setting-management/tsconfig.spec.json index cfff29a544..a42c4b02fb 100644 --- a/npm/ng-packs/nx/ng-packs/packages/setting-management/tsconfig.spec.json +++ b/npm/ng-packs/nx/ng-packs/packages/setting-management/tsconfig.spec.json @@ -3,7 +3,8 @@ "compilerOptions": { "outDir": "../../dist/out-tsc", "module": "commonjs", - "types": ["jest", "node"] + "types": ["jest", "node"], + "esModuleInterop": true }, "files": ["src/test-setup.ts"], "include": ["**/*.spec.ts", "**/*.d.ts"] diff --git a/npm/ng-packs/nx/ng-packs/packages/tenant-management/tsconfig.spec.json b/npm/ng-packs/nx/ng-packs/packages/tenant-management/tsconfig.spec.json index cfff29a544..a42c4b02fb 100644 --- a/npm/ng-packs/nx/ng-packs/packages/tenant-management/tsconfig.spec.json +++ b/npm/ng-packs/nx/ng-packs/packages/tenant-management/tsconfig.spec.json @@ -3,7 +3,8 @@ "compilerOptions": { "outDir": "../../dist/out-tsc", "module": "commonjs", - "types": ["jest", "node"] + "types": ["jest", "node"], + "esModuleInterop": true }, "files": ["src/test-setup.ts"], "include": ["**/*.spec.ts", "**/*.d.ts"] diff --git a/npm/ng-packs/nx/ng-packs/packages/theme-basic/src/lib/components/account-layout/auth-wrapper/auth-wrapper.component.spec.ts b/npm/ng-packs/nx/ng-packs/packages/theme-basic/src/lib/components/account-layout/auth-wrapper/auth-wrapper.component.spec.ts deleted file mode 100644 index a5c69d2301..0000000000 --- a/npm/ng-packs/nx/ng-packs/packages/theme-basic/src/lib/components/account-layout/auth-wrapper/auth-wrapper.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { AuthWrapperComponent } from './auth-wrapper.component'; - -describe('AuthWrapperComponent', () => { - let component: AuthWrapperComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ AuthWrapperComponent ] - }) - .compileComponents(); - }); - - beforeEach(() => { - fixture = TestBed.createComponent(AuthWrapperComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/npm/ng-packs/nx/ng-packs/packages/theme-basic/src/lib/components/account-layout/tenant-box/tenant-box.component.spec.ts b/npm/ng-packs/nx/ng-packs/packages/theme-basic/src/lib/components/account-layout/tenant-box/tenant-box.component.spec.ts deleted file mode 100644 index 86dd8a0cf5..0000000000 --- a/npm/ng-packs/nx/ng-packs/packages/theme-basic/src/lib/components/account-layout/tenant-box/tenant-box.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { TenantBoxComponent } from './tenant-box.component'; - -describe('TenantBoxComponent', () => { - let component: TenantBoxComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ TenantBoxComponent ] - }) - .compileComponents(); - }); - - beforeEach(() => { - fixture = TestBed.createComponent(TenantBoxComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/npm/ng-packs/nx/ng-packs/packages/theme-basic/tsconfig.spec.json b/npm/ng-packs/nx/ng-packs/packages/theme-basic/tsconfig.spec.json index cfff29a544..a42c4b02fb 100644 --- a/npm/ng-packs/nx/ng-packs/packages/theme-basic/tsconfig.spec.json +++ b/npm/ng-packs/nx/ng-packs/packages/theme-basic/tsconfig.spec.json @@ -3,7 +3,8 @@ "compilerOptions": { "outDir": "../../dist/out-tsc", "module": "commonjs", - "types": ["jest", "node"] + "types": ["jest", "node"], + "esModuleInterop": true }, "files": ["src/test-setup.ts"], "include": ["**/*.spec.ts", "**/*.d.ts"] diff --git a/npm/ng-packs/nx/ng-packs/packages/theme-shared/tsconfig.spec.json b/npm/ng-packs/nx/ng-packs/packages/theme-shared/tsconfig.spec.json index cfff29a544..a42c4b02fb 100644 --- a/npm/ng-packs/nx/ng-packs/packages/theme-shared/tsconfig.spec.json +++ b/npm/ng-packs/nx/ng-packs/packages/theme-shared/tsconfig.spec.json @@ -3,7 +3,8 @@ "compilerOptions": { "outDir": "../../dist/out-tsc", "module": "commonjs", - "types": ["jest", "node"] + "types": ["jest", "node"], + "esModuleInterop": true }, "files": ["src/test-setup.ts"], "include": ["**/*.spec.ts", "**/*.d.ts"] diff --git a/npm/ng-packs/nx/ng-packs/tsconfig.base.json b/npm/ng-packs/nx/ng-packs/tsconfig.base.json index 7aa4976345..9db2d0c66a 100644 --- a/npm/ng-packs/nx/ng-packs/tsconfig.base.json +++ b/npm/ng-packs/nx/ng-packs/tsconfig.base.json @@ -11,9 +11,8 @@ "target": "es2015", "module": "esnext", "lib": ["es2017", "dom"], - "skipLibCheck": true, - "skipDefaultLibCheck": true, "baseUrl": ".", + "allowSyntheticDefaultImports": true, "paths": { "@abp/ng.account": ["packages/account/src/public-api.ts"], "@abp/ng.account.core": ["packages/account-core/src/public-api.ts"], diff --git a/npm/ng-packs/nx/ng-packs/tsconfig.lib.base.json b/npm/ng-packs/nx/ng-packs/tsconfig.lib.base.json index edae640cd1..452f037f59 100644 --- a/npm/ng-packs/nx/ng-packs/tsconfig.lib.base.json +++ b/npm/ng-packs/nx/ng-packs/tsconfig.lib.base.json @@ -11,8 +11,7 @@ "target": "es2015", "module": "esnext", "lib": ["es2017", "dom"], - "skipLibCheck": true, - "skipDefaultLibCheck": true, + "allowSyntheticDefaultImports": true, "baseUrl": ".", "paths": { "@abp/ng.account": ["dist/packages/account"],