From a4e403ce0f92b9426513d9f1e65cb234fda5c79e Mon Sep 17 00:00:00 2001 From: Danilo Hoffmann Date: Tue, 15 Mar 2022 09:08:13 +0100 Subject: [PATCH] fix: repair cleanup testbed script and apply changes (#1057) * fix: repair cleanup-testbed script * chore: add cleanup-testbed to npm scripts * chore: run cleanup-testbed --- .github/workflows/dead-code.yml | 4 +- .github/workflows/development.yml | 4 +- package.json | 1 + scripts/cleanup-testbed.ts | 65 +++++++++---------- src/app/core/guards/auth.guard.spec.ts | 11 +--- .../guards/authorization-toggle.guard.spec.ts | 11 +--- .../core/guards/feature-toggle.guard.spec.ts | 11 +--- .../auth0.identity-provider.spec.ts | 13 ++-- .../routing/category/category.route.spec.ts | 10 +-- .../routing/product/product.route.spec.ts | 10 +-- src/app/core/services/api/api.service.spec.ts | 7 +- .../store/customer/customer-store.spec.ts | 9 +-- .../store/shopping/shopping-store.spec.ts | 19 ++---- .../http-status-code.service.spec.ts | 11 +--- src/app/core/utils/meta-reducers.spec.ts | 2 - .../punchout-identity-provider.spec.ts | 15 +---- .../account-addresses-page.component.spec.ts | 7 +- .../account-order-page.component.spec.ts | 4 +- .../account-order.component.spec.ts | 5 +- .../account-overview.component.spec.ts | 13 ++-- .../account-payment-page.component.spec.ts | 7 +- ...unt-profile-company-page.component.spec.ts | 7 +- ...count-profile-email-page.component.spec.ts | 7 +- ...nt-profile-password-page.component.spec.ts | 7 +- ...ccount-profile-user-page.component.spec.ts | 7 +- .../shopping-basket.component.spec.ts | 2 - .../checkout-address-page.component.spec.ts | 3 - .../checkout-payment-page.component.spec.ts | 7 +- .../checkout-payment.component.spec.ts | 16 +---- .../payment-concardis.component.spec.ts | 4 +- .../payment-parameter-form.component.spec.ts | 6 +- .../checkout-receipt-page.component.spec.ts | 4 -- .../checkout-receipt.component.spec.ts | 2 - .../checkout-review.component.spec.ts | 6 -- .../checkout-shipping-page.component.spec.ts | 4 -- .../product-compare-list.component.spec.ts | 8 --- .../product-compare-paging.component.spec.ts | 2 - .../contact/contact-page.component.spec.ts | 4 -- .../pages/error/error-page.component.spec.ts | 3 +- .../request-reminder.component.spec.ts | 2 - .../update-password.component.spec.ts | 2 - .../loading/loading-page.component.spec.ts | 17 +++-- .../pages/login/login-page.component.spec.ts | 7 +- .../product-bundle-parts.component.spec.ts | 2 - .../product-detail-actions.component.spec.ts | 8 +-- .../product-detail-info.component.spec.ts | 14 +--- .../product-detail.component.spec.ts | 32 ++++++++- .../product-links-carousel.component.spec.ts | 4 +- .../product-links-list.component.spec.ts | 9 +-- .../product-links.component.spec.ts | 12 +--- .../retail-set-parts.component.spec.ts | 2 - .../registration-page.component.spec.ts | 3 +- .../footer-top/footer-top.component.spec.ts | 3 +- .../footer/footer/footer.component.spec.ts | 8 +-- .../header-checkout.component.spec.ts | 6 +- .../header-default.component.spec.ts | 2 - .../header/header/header.component.spec.ts | 8 +-- 57 files changed, 136 insertions(+), 343 deletions(-) diff --git a/.github/workflows/dead-code.yml b/.github/workflows/dead-code.yml index f9da4f7268..97e52401e8 100644 --- a/.github/workflows/dead-code.yml +++ b/.github/workflows/dead-code.yml @@ -25,6 +25,4 @@ jobs: run: npm ci - name: Find Unused TestBed declarations - run: | - npx ts-node scripts/cleanup-testbed - npm run check-no-changes + run: npx npm-run-all cleanup-testbed check-no-changes diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index 7a66ebc78e..bcb4c1255f 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -124,9 +124,7 @@ jobs: run: npx ts-node scripts/find-dead-code - name: Find Unused TestBed declarations - run: | - npx ts-node scripts/cleanup-testbed origin/develop - npm run check-no-changes + run: npx npm-run-all "cleanup-testbed origin/develop" check-no-changes Schematics: needs: [Quality, Jest] diff --git a/package.json b/package.json index 7046e41b0a..3fa284b191 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "compile": "tsc --project tsconfig.all.json", "dead-code": "npx ts-node scripts/find-dead-code.ts", "clean-localizations": "node scripts/clean-up-localizations", + "cleanup-testbed": "npx ts-node scripts/cleanup-testbed", "spell-check": "cspell lint --no-summary --no-progress \"{src,projects,docs}/**/*.{html,ts,scss,md}\"", "spell-check-localizations": "cspell lint --no-summary --no-progress \"src/assets/i18n/{de_DE,en_US,fr_FR}.json\"", "clean": "git clean -xdf -e \"*environment.local.ts\" -e \"*environment.development.ts\" -e \"*node_modules\"", diff --git a/scripts/cleanup-testbed.ts b/scripts/cleanup-testbed.ts index 5b7e490324..d3e1fa312d 100644 --- a/scripts/cleanup-testbed.ts +++ b/scripts/cleanup-testbed.ts @@ -1,7 +1,5 @@ -import { tsquery } from '@phenomnomnominal/tsquery'; import { execSync, spawnSync } from 'child_process'; import { LeftHandSideExpression, Node, Project, PropertyAccessExpression, SourceFile } from 'ts-morph'; -import * as ts from 'typescript'; /* eslint-disable no-console */ @@ -38,44 +36,44 @@ console.log(`found ${files.length} test file(s)`); let processedFiles = 0; +const lintFiles = []; + for (const file of files) { processedFiles++; + const hasTestBedModule = file.getText().includes('configureTestingModule'); + const copyPath = `${file.getFilePath()}.ut.spec.ts`; - let foundSomething = false; top: while (true) { const percent = ((processedFiles / files.length) * 100).toFixed(0); - if ( - !tsquery( - file.getSourceFile().compilerNode as unknown as ts.Node, - 'PropertyAccessExpression[expression.text=TestBed][name.text=configureTestingModule]' - ).length - ) { + if (!hasTestBedModule) { console.log(`at ${percent}% - ${path(file)}`, 0, `test(s)`); } else { const configs: { tb: number; type: string; index: number }[] = []; let tb = 0; - file.forEachDescendant(node => { - if (Node.isCallExpression(node) && isTestBedConfigure(node.getExpression())) { - const configObject = node.getArguments().find(Node.isObjectLiteralExpression); - if (configObject) { - for (const type of ['declarations', 'providers', 'imports']) { - const array = configObject.getProperty(type); - if (Node.isPropertyAssignment(array)) { - const initializer = array.getInitializer(); - if (Node.isArrayLiteralExpression(initializer)) { - for (let index = 0; index < initializer.getElements().length; index++) { - configs.push({ tb, type, index }); + project.forgetNodesCreatedInBlock(() => { + file.forEachDescendant(node => { + if (Node.isCallExpression(node) && isTestBedConfigure(node.getExpression())) { + const configObject = node.getArguments().find(Node.isObjectLiteralExpression); + if (configObject) { + for (const type of ['declarations', 'providers', 'imports']) { + const array = configObject.getProperty(type); + if (Node.isPropertyAssignment(array)) { + const initializer = array.getInitializer(); + if (Node.isArrayLiteralExpression(initializer)) { + for (let index = initializer.getElements().length - 1; index >= 0; index--) { + configs.push({ tb, type, index }); + } } } } } + tb++; } - tb++; - } + }); }); console.log(`at ${percent}% - ${path(file)}`, configs.length, `test(s)`); @@ -94,7 +92,7 @@ for (const file of files) { if (Node.isPropertyAssignment(array)) { const initializer = array.getInitializer(); if (Node.isArrayLiteralExpression(initializer)) { - const element = initializer.getElements()[config.index].getText(); + const element = initializer.getElements()[config.index]?.getText(); if (initializer.getElements().length === 1) { array.remove(); @@ -113,7 +111,10 @@ for (const file of files) { `${path(file)} - removing '${element}' from ${config.type} in TestBed #${config.tb + 1}` ); copy.copyImmediatelySync(file.getFilePath(), { overwrite: true }); - foundSomething = true; + lintFiles.push(file.getFilePath()); + copy.forget(); + copy.deleteImmediatelySync(); + continue top; } catch (err) { continue next; @@ -130,18 +131,12 @@ for (const file of files) { } if (project.getSourceFile(copyPath)) { - project.getSourceFile(copyPath).delete(); - } - - if (foundSomething) { - const filePath = file.getFilePath(); - execSync(`node scripts/fix-imports ${filePath}`); - try { - execSync(`npx prettier --write ${filePath}`); - } catch (err) { - // do nothing - } + project.getSourceFile(copyPath).deleteImmediatelySync(); } } project.saveSync(); + +if (lintFiles.length) { + execSync(`npx eslint --fix ${lintFiles.join(' ')}`); +} diff --git a/src/app/core/guards/auth.guard.spec.ts b/src/app/core/guards/auth.guard.spec.ts index 2b501ebce4..a3ef016b80 100644 --- a/src/app/core/guards/auth.guard.spec.ts +++ b/src/app/core/guards/auth.guard.spec.ts @@ -1,4 +1,3 @@ -import { Component } from '@angular/core'; import { TestBed } from '@angular/core/testing'; import { ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; @@ -19,16 +18,8 @@ describe('Auth Guard', () => { let store$: Store; beforeEach(async () => { - @Component({ template: 'dummy' }) - class DummyComponent {} - await TestBed.configureTestingModule({ - imports: [ - CoreStoreModule.forTesting(), - CustomerStoreModule.forTesting('user'), - RouterTestingModule.withRoutes([{ path: 'login', component: DummyComponent }]), - ], - declarations: [DummyComponent], + imports: [CoreStoreModule.forTesting(), CustomerStoreModule.forTesting('user'), RouterTestingModule], providers: [{ provide: CookiesService, useFactory: () => instance(mock(CookiesService)) }], }).compileComponents(); }); diff --git a/src/app/core/guards/authorization-toggle.guard.spec.ts b/src/app/core/guards/authorization-toggle.guard.spec.ts index 6ff3ce15df..f02cd40398 100644 --- a/src/app/core/guards/authorization-toggle.guard.spec.ts +++ b/src/app/core/guards/authorization-toggle.guard.spec.ts @@ -1,4 +1,3 @@ -import { Component } from '@angular/core'; import { TestBed, fakeAsync, tick } from '@angular/core/testing'; import { Router } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; @@ -11,27 +10,23 @@ describe('Authorization Toggle Guard', () => { let router: Router; beforeEach(() => { - @Component({ template: 'dummy' }) - class DummyComponent {} - TestBed.configureTestingModule({ - declarations: [DummyComponent], imports: [ AuthorizationToggleModule.forTesting('DO_THIS'), RouterTestingModule.withRoutes([ { path: 'error', - component: DummyComponent, + children: [], }, { path: 'page1', - component: DummyComponent, + children: [], canActivate: [AuthorizationToggleGuard], data: { permission: 'DO_THIS' }, }, { path: 'page2', - component: DummyComponent, + children: [], canActivate: [AuthorizationToggleGuard], data: { permission: 'DO_THAT' }, }, diff --git a/src/app/core/guards/feature-toggle.guard.spec.ts b/src/app/core/guards/feature-toggle.guard.spec.ts index 044461d8f5..a629fe952a 100644 --- a/src/app/core/guards/feature-toggle.guard.spec.ts +++ b/src/app/core/guards/feature-toggle.guard.spec.ts @@ -1,4 +1,3 @@ -import { ChangeDetectionStrategy, Component } from '@angular/core'; import { TestBed, fakeAsync, tick } from '@angular/core/testing'; import { Router } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; @@ -9,27 +8,23 @@ describe('Feature Toggle Guard', () => { let router: Router; beforeEach(() => { - @Component({ template: 'dummy', changeDetection: ChangeDetectionStrategy.OnPush }) - class DummyComponent {} - TestBed.configureTestingModule({ - declarations: [DummyComponent], imports: [ FeatureToggleModule.forTesting('feature1'), RouterTestingModule.withRoutes([ { path: 'error', - component: DummyComponent, + children: [], }, { path: 'feature1', - component: DummyComponent, + children: [], canActivate: [FeatureToggleGuard], data: { feature: 'feature1' }, }, { path: 'feature2', - component: DummyComponent, + children: [], canActivate: [FeatureToggleGuard], data: { feature: 'feature2' }, }, diff --git a/src/app/core/identity-provider/auth0.identity-provider.spec.ts b/src/app/core/identity-provider/auth0.identity-provider.spec.ts index 1ce00b64f3..54a0290c5f 100644 --- a/src/app/core/identity-provider/auth0.identity-provider.spec.ts +++ b/src/app/core/identity-provider/auth0.identity-provider.spec.ts @@ -1,5 +1,4 @@ import { APP_BASE_HREF } from '@angular/common'; -import { Component } from '@angular/core'; import { TestBed, fakeAsync, tick } from '@angular/core/testing'; import { Router } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; @@ -17,9 +16,6 @@ import { ApiTokenService } from 'ish-core/utils/api-token/api-token.service'; import { Auth0Config, Auth0IdentityProvider } from './auth0.identity-provider'; -@Component({ template: 'dummy' }) -class DummyComponent {} - const idToken = 'abc123'; const userData: UserData = { @@ -47,13 +43,12 @@ describe('Auth0 Identity Provider', () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [DummyComponent], imports: [ RouterTestingModule.withRoutes([ - { path: 'register', component: DummyComponent }, - { path: 'register/sso', component: DummyComponent }, - { path: 'account', component: DummyComponent }, - { path: 'logout', component: DummyComponent }, + { path: 'register', children: [] }, + { path: 'register/sso', children: [] }, + { path: 'account', children: [] }, + { path: 'logout', children: [] }, ]), ], providers: [ diff --git a/src/app/core/routing/category/category.route.spec.ts b/src/app/core/routing/category/category.route.spec.ts index bb0c769c9d..4bff3f5657 100644 --- a/src/app/core/routing/category/category.route.spec.ts +++ b/src/app/core/routing/category/category.route.spec.ts @@ -1,4 +1,3 @@ -import { Component } from '@angular/core'; import { TestBed, fakeAsync, tick } from '@angular/core/testing'; import { Router, UrlMatchResult, UrlSegment } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; @@ -166,15 +165,8 @@ describe('Category Route', () => { let store$: Store; beforeEach(() => { - @Component({ template: 'dummy' }) - class DummyComponent {} - TestBed.configureTestingModule({ - declarations: [DummyComponent], - imports: [ - CoreStoreModule.forTesting(['router']), - RouterTestingModule.withRoutes([{ path: '**', component: DummyComponent }]), - ], + imports: [CoreStoreModule.forTesting(['router']), RouterTestingModule.withRoutes([{ path: '**', children: [] }])], }); router = TestBed.inject(Router); diff --git a/src/app/core/routing/product/product.route.spec.ts b/src/app/core/routing/product/product.route.spec.ts index edf239b429..5815404e79 100644 --- a/src/app/core/routing/product/product.route.spec.ts +++ b/src/app/core/routing/product/product.route.spec.ts @@ -1,4 +1,3 @@ -import { Component } from '@angular/core'; import { TestBed, fakeAsync, tick } from '@angular/core/testing'; import { Router, UrlMatchResult, UrlSegment } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; @@ -338,15 +337,8 @@ describe('Product Route', () => { let store$: Store; beforeEach(() => { - @Component({ template: 'dummy' }) - class DummyComponent {} - TestBed.configureTestingModule({ - declarations: [DummyComponent], - imports: [ - CoreStoreModule.forTesting(['router']), - RouterTestingModule.withRoutes([{ path: '**', component: DummyComponent }]), - ], + imports: [CoreStoreModule.forTesting(['router']), RouterTestingModule.withRoutes([{ path: '**', children: [] }])], }); router = TestBed.inject(Router); diff --git a/src/app/core/services/api/api.service.spec.ts b/src/app/core/services/api/api.service.spec.ts index 7da8a86bd5..2173cb13b7 100644 --- a/src/app/core/services/api/api.service.spec.ts +++ b/src/app/core/services/api/api.service.spec.ts @@ -18,7 +18,6 @@ import { import { CoreStoreModule } from 'ish-core/store/core/core-store.module'; import { serverError } from 'ish-core/store/core/error'; import { loadServerConfigSuccess } from 'ish-core/store/core/server-config'; -import { CustomerStoreModule } from 'ish-core/store/customer/customer-store.module'; import { getPGID } from 'ish-core/store/customer/user'; import { ApiService, unpackEnvelope } from './api.service'; @@ -554,11 +553,7 @@ describe('Api Service', () => { beforeEach(() => { TestBed.configureTestingModule({ // https://angular.io/guide/http#testing-http-requests - imports: [ - CoreStoreModule.forTesting(['configuration', 'serverConfig']), - CustomerStoreModule.forTesting('user'), - HttpClientTestingModule, - ], + imports: [CoreStoreModule.forTesting(['configuration', 'serverConfig']), HttpClientTestingModule], }); apiService = TestBed.inject(ApiService); diff --git a/src/app/core/store/customer/customer-store.spec.ts b/src/app/core/store/customer/customer-store.spec.ts index 7ae4046d21..76c6370608 100644 --- a/src/app/core/store/customer/customer-store.spec.ts +++ b/src/app/core/store/customer/customer-store.spec.ts @@ -1,4 +1,3 @@ -import { Component } from '@angular/core'; import { TestBed } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { TranslateModule } from '@ngx-translate/core'; @@ -106,9 +105,6 @@ describe('Customer Store', () => { } as Promotion; beforeEach(() => { - @Component({ template: 'dummy' }) - class DummyComponent {} - const categoriesServiceMock = mock(CategoriesService); when(categoriesServiceMock.getTopLevelCategories(anyNumber())).thenReturn(of(categoryTree())); @@ -154,18 +150,17 @@ describe('Customer Store', () => { when(productPriceServiceMock.getProductPrices(anything())).thenReturn(of([])); TestBed.configureTestingModule({ - declarations: [DummyComponent], imports: [ CoreStoreModule.forTesting(['configuration', 'serverConfig'], true), CustomerStoreModule, RouterTestingModule.withRoutes([ { path: 'account', - component: DummyComponent, + children: [], }, { path: 'checkout/address', - component: DummyComponent, + children: [], }, ]), ShoppingStoreModule, diff --git a/src/app/core/store/shopping/shopping-store.spec.ts b/src/app/core/store/shopping/shopping-store.spec.ts index 46e5c31a8b..8f95e372d0 100644 --- a/src/app/core/store/shopping/shopping-store.spec.ts +++ b/src/app/core/store/shopping/shopping-store.spec.ts @@ -1,4 +1,3 @@ -import { Component } from '@angular/core'; import { TestBed, fakeAsync, tick } from '@angular/core/testing'; import { Router } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; @@ -48,9 +47,6 @@ describe('Shopping Store', () => { let priceServiceMock: PricesService; beforeEach(() => { - @Component({ template: 'dummy' }) - class DummyComponent {} - const catA = { uniqueId: 'A', categoryPath: ['A'], name: 'nA' } as Category; const catA123 = { uniqueId: 'A.123', categoryPath: ['A', 'A.123'], name: 'nA123' } as Category; const catA123456 = { @@ -147,39 +143,38 @@ describe('Shopping Store', () => { when(priceServiceMock.getProductPrices(anything())).thenReturn(of([])); TestBed.configureTestingModule({ - declarations: [DummyComponent], imports: [ CoreStoreModule.forTesting(['router', 'configuration', 'serverConfig'], true), CustomerStoreModule.forTesting('user'), RouterTestingModule.withRoutes([ { path: 'home', - component: DummyComponent, + children: [], }, { path: 'compare', - component: DummyComponent, + children: [], }, { path: 'error', - component: DummyComponent, + children: [], data: { headerType: 'simple' }, }, { path: 'category/:categoryUniqueId', - component: DummyComponent, + children: [], }, { path: 'category/:categoryUniqueId/product/:sku', - component: DummyComponent, + children: [], }, { path: 'product/:sku', - component: DummyComponent, + children: [], }, { path: 'search/:searchTerm', - component: DummyComponent, + children: [], }, ]), ShoppingStoreModule, diff --git a/src/app/core/utils/http-status-code/http-status-code.service.spec.ts b/src/app/core/utils/http-status-code/http-status-code.service.spec.ts index edd5d26268..3eaf7fb787 100644 --- a/src/app/core/utils/http-status-code/http-status-code.service.spec.ts +++ b/src/app/core/utils/http-status-code/http-status-code.service.spec.ts @@ -1,5 +1,5 @@ import { Location } from '@angular/common'; -import { Component, PLATFORM_ID } from '@angular/core'; +import { PLATFORM_ID } from '@angular/core'; import { TestBed, fakeAsync, tick } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { RESPONSE } from '@nguniversal/express-engine/tokens'; @@ -14,9 +14,6 @@ describe('Http Status Code Service', () => { let resSpy: { status(status: number): void }; let location: Location; - @Component({ template: 'dummy' }) - class DummyComponent {} - beforeEach(() => { RES = { status: noop, @@ -29,8 +26,7 @@ describe('Http Status Code Service', () => { describe('on browser', () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [DummyComponent], - imports: [RouterTestingModule.withRoutes([{ path: 'error', component: DummyComponent }])], + imports: [RouterTestingModule.withRoutes([{ path: 'error', children: [] }])], }); httpStatusCodeService = TestBed.inject(HttpStatusCodeService); location = TestBed.inject(Location); @@ -67,8 +63,7 @@ describe('Http Status Code Service', () => { describe('on server', () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [DummyComponent], - imports: [RouterTestingModule.withRoutes([{ path: 'error', component: DummyComponent }])], + imports: [RouterTestingModule.withRoutes([{ path: 'error', children: [] }])], providers: [ { provide: PLATFORM_ID, useValue: 'server' }, { provide: RESPONSE, useValue: RES }, diff --git a/src/app/core/utils/meta-reducers.spec.ts b/src/app/core/utils/meta-reducers.spec.ts index 1cb0464cd1..ac1ee3a3b7 100644 --- a/src/app/core/utils/meta-reducers.spec.ts +++ b/src/app/core/utils/meta-reducers.spec.ts @@ -5,7 +5,6 @@ import { identity } from 'rxjs'; import { applyConfiguration, getICMBaseURL } from 'ish-core/store/core/configuration'; import { CoreState } from 'ish-core/store/core/core-store'; import { CoreStoreModule } from 'ish-core/store/core/core-store.module'; -import { CustomerStoreModule } from 'ish-core/store/customer/customer-store.module'; import { loginUser, logoutUser } from 'ish-core/store/customer/user'; import { StoreWithSnapshots, provideStoreSnapshots } from './dev/ngrx-testing'; @@ -22,7 +21,6 @@ describe('Meta Reducers', () => { CoreStoreModule.forTesting(['configuration'], true, [ resetSubStatesOnActionsMeta(['configuration'], [logoutUser]), ]), - CustomerStoreModule.forTesting('user'), ], providers: [provideStoreSnapshots()], }); diff --git a/src/app/extensions/punchout/identity-provider/punchout-identity-provider.spec.ts b/src/app/extensions/punchout/identity-provider/punchout-identity-provider.spec.ts index 6eb8ec9c23..960fdc30cb 100644 --- a/src/app/extensions/punchout/identity-provider/punchout-identity-provider.spec.ts +++ b/src/app/extensions/punchout/identity-provider/punchout-identity-provider.spec.ts @@ -1,4 +1,3 @@ -import { Component } from '@angular/core'; import { TestBed, fakeAsync, tick } from '@angular/core/testing'; import { ActivatedRouteSnapshot, Params, Router, UrlTree, convertToParamMap } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; @@ -10,7 +9,6 @@ import { anyString, anything, capture, instance, mock, resetCalls, spy, verify, import { AccountFacade } from 'ish-core/facades/account.facade'; import { AppFacade } from 'ish-core/facades/app.facade'; import { CheckoutFacade } from 'ish-core/facades/checkout.facade'; -import { ApiService } from 'ish-core/services/api/api.service'; import { selectQueryParam } from 'ish-core/store/core/router'; import { ApiTokenService } from 'ish-core/utils/api-token/api-token.service'; import { CookiesService } from 'ish-core/utils/cookies/cookies.service'; @@ -22,9 +20,6 @@ import { PunchoutService } from '../services/punchout/punchout.service'; import { PunchoutIdentityProvider } from './punchout-identity-provider'; -@Component({ template: 'dummy' }) -class DummyComponent {} - type ApiTokenCookieType = 'user' | 'basket' | 'order'; function getSnapshot(queryParams: Params): ActivatedRouteSnapshot { @@ -35,7 +30,6 @@ function getSnapshot(queryParams: Params): ActivatedRouteSnapshot { describe('Punchout Identity Provider', () => { const punchoutService = mock(PunchoutService); - const apiService = mock(ApiService); const apiTokenService = mock(ApiTokenService); const appFacade = mock(AppFacade); const accountFacade = mock(AccountFacade); @@ -50,17 +44,15 @@ describe('Punchout Identity Provider', () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [DummyComponent], imports: [ RouterTestingModule.withRoutes([ - { path: 'home', component: DummyComponent }, - { path: 'logout', component: DummyComponent }, - { path: 'error', component: DummyComponent }, + { path: 'home', children: [] }, + { path: 'logout', children: [] }, + { path: 'error', children: [] }, ]), ], providers: [ { provide: AccountFacade, useFactory: () => instance(accountFacade) }, - { provide: ApiService, useFactory: () => instance(apiService) }, { provide: ApiTokenService, useFactory: () => instance(apiTokenService) }, { provide: AppFacade, useFactory: () => instance(appFacade) }, { provide: CheckoutFacade, useFactory: () => instance(checkoutFacade) }, @@ -82,7 +74,6 @@ describe('Punchout Identity Provider', () => { when(checkoutFacade.basket$).thenReturn(EMPTY); when(apiTokenService.cookieVanishes$).thenReturn(cookieVanishes$); - resetCalls(apiService); resetCalls(apiTokenService); resetCalls(punchoutService); resetCalls(appFacade); diff --git a/src/app/pages/account-addresses/account-addresses-page.component.spec.ts b/src/app/pages/account-addresses/account-addresses-page.component.spec.ts index 91c98955b5..ec08ac4fde 100644 --- a/src/app/pages/account-addresses/account-addresses-page.component.spec.ts +++ b/src/app/pages/account-addresses/account-addresses-page.component.spec.ts @@ -3,7 +3,6 @@ import { MockComponent } from 'ng-mocks'; import { instance, mock } from 'ts-mockito'; import { AccountFacade } from 'ish-core/facades/account.facade'; -import { LoadingComponent } from 'ish-shared/components/common/loading/loading.component'; import { AccountAddressesPageComponent } from './account-addresses-page.component'; import { AccountAddressesComponent } from './account-addresses/account-addresses.component'; @@ -15,11 +14,7 @@ describe('Account Addresses Page Component', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ - AccountAddressesPageComponent, - MockComponent(AccountAddressesComponent), - MockComponent(LoadingComponent), - ], + declarations: [AccountAddressesPageComponent, MockComponent(AccountAddressesComponent)], providers: [{ provide: AccountFacade, useFactory: () => instance(mock(AccountFacade)) }], }).compileComponents(); }); diff --git a/src/app/pages/account-order/account-order-page.component.spec.ts b/src/app/pages/account-order/account-order-page.component.spec.ts index 92e3d2dbc6..f51a0bcca6 100644 --- a/src/app/pages/account-order/account-order-page.component.spec.ts +++ b/src/app/pages/account-order/account-order-page.component.spec.ts @@ -1,11 +1,9 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { MockComponent } from 'ng-mocks'; import { instance, mock } from 'ts-mockito'; import { AccountFacade } from 'ish-core/facades/account.facade'; import { AccountOrderPageComponent } from './account-order-page.component'; -import { AccountOrderComponent } from './account-order/account-order.component'; describe('Account Order Page Component', () => { let component: AccountOrderPageComponent; @@ -14,7 +12,7 @@ describe('Account Order Page Component', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [AccountOrderPageComponent, MockComponent(AccountOrderComponent)], + declarations: [AccountOrderPageComponent], providers: [{ provide: AccountFacade, useFactory: () => instance(mock(AccountFacade)) }], }).compileComponents(); }); diff --git a/src/app/pages/account-order/account-order/account-order.component.spec.ts b/src/app/pages/account-order/account-order/account-order.component.spec.ts index 71bc4f9170..4d44985c85 100644 --- a/src/app/pages/account-order/account-order/account-order.component.spec.ts +++ b/src/app/pages/account-order/account-order/account-order.component.spec.ts @@ -1,5 +1,4 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { RouterTestingModule } from '@angular/router/testing'; import { FaIconComponent } from '@fortawesome/angular-fontawesome'; import { TranslateModule } from '@ngx-translate/core'; import { MockComponent, MockDirective, MockPipe } from 'ng-mocks'; @@ -8,7 +7,6 @@ import { FeatureToggleDirective } from 'ish-core/directives/feature-toggle.direc import { DatePipe } from 'ish-core/pipes/date.pipe'; import { BasketMockData } from 'ish-core/utils/dev/basket-mock-data'; import { AddressComponent } from 'ish-shared/components/address/address/address.component'; -import { BasketBuyerComponent } from 'ish-shared/components/basket/basket-buyer/basket-buyer.component'; import { BasketCostSummaryComponent } from 'ish-shared/components/basket/basket-cost-summary/basket-cost-summary.component'; import { InfoBoxComponent } from 'ish-shared/components/common/info-box/info-box.component'; import { LineItemListComponent } from 'ish-shared/components/line-item/line-item-list/line-item-list.component'; @@ -25,7 +23,6 @@ describe('Account Order Component', () => { declarations: [ AccountOrderComponent, MockComponent(AddressComponent), - MockComponent(BasketBuyerComponent), MockComponent(BasketCostSummaryComponent), MockComponent(FaIconComponent), MockComponent(InfoBoxComponent), @@ -33,7 +30,7 @@ describe('Account Order Component', () => { MockDirective(FeatureToggleDirective), MockPipe(DatePipe), ], - imports: [RouterTestingModule, TranslateModule.forRoot()], + imports: [TranslateModule.forRoot()], }).compileComponents(); }); diff --git a/src/app/pages/account-overview/account-overview/account-overview.component.spec.ts b/src/app/pages/account-overview/account-overview/account-overview.component.spec.ts index 204dbd7314..775545c705 100644 --- a/src/app/pages/account-overview/account-overview/account-overview.component.spec.ts +++ b/src/app/pages/account-overview/account-overview/account-overview.component.spec.ts @@ -2,12 +2,12 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FaIconComponent } from '@fortawesome/angular-fontawesome'; import { TranslateModule, TranslateService } from '@ngx-translate/core'; import { MockComponent, MockDirective, MockPipe } from 'ng-mocks'; -import { LazyBudgetWidgetComponent, LazyCostCenterWidgetComponent } from 'organization-management'; -import { LazyApprovalWidgetComponent, LazyRequisitionWidgetComponent } from 'requisition-management'; +import { LazyBudgetWidgetComponent } from 'organization-management'; +import { LazyRequisitionWidgetComponent } from 'requisition-management'; import { AuthorizationToggleDirective } from 'ish-core/directives/authorization-toggle.directive'; -import { FeatureToggleDirective } from 'ish-core/directives/feature-toggle.directive'; import { ServerHtmlDirective } from 'ish-core/directives/server-html.directive'; +import { FeatureToggleModule } from 'ish-core/feature-toggle.module'; import { Customer } from 'ish-core/models/customer/customer.model'; import { User } from 'ish-core/models/user/user.model'; import { ServerSettingPipe } from 'ish-core/pipes/server-setting.pipe'; @@ -15,7 +15,6 @@ import { RoleToggleModule } from 'ish-core/role-toggle.module'; import { OrderWidgetComponent } from 'ish-shared/components/order/order-widget/order-widget.component'; import { LazyOrderTemplateWidgetComponent } from '../../../extensions/order-templates/exports/lazy-order-template-widget/lazy-order-template-widget.component'; -import { LazyQuoteWidgetComponent } from '../../../extensions/quoting/exports/lazy-quote-widget/lazy-quote-widget.component'; import { LazyWishlistWidgetComponent } from '../../../extensions/wishlists/exports/lazy-wishlist-widget/lazy-wishlist-widget.component'; import { AccountOverviewComponent } from './account-overview.component'; @@ -34,20 +33,16 @@ describe('Account Overview Component', () => { declarations: [ AccountOverviewComponent, MockComponent(FaIconComponent), - MockComponent(LazyApprovalWidgetComponent), MockComponent(LazyBudgetWidgetComponent), - MockComponent(LazyCostCenterWidgetComponent), MockComponent(LazyOrderTemplateWidgetComponent), - MockComponent(LazyQuoteWidgetComponent), MockComponent(LazyRequisitionWidgetComponent), MockComponent(OrderWidgetComponent), MockDirective(AuthorizationToggleDirective), - MockDirective(FeatureToggleDirective), MockDirective(LazyWishlistWidgetComponent), MockDirective(ServerHtmlDirective), MockPipe(ServerSettingPipe, () => true), ], - imports: [RoleToggleModule.forTesting(), TranslateModule.forRoot()], + imports: [FeatureToggleModule.forTesting(), RoleToggleModule.forTesting(), TranslateModule.forRoot()], }).compileComponents(); }); diff --git a/src/app/pages/account-payment/account-payment-page.component.spec.ts b/src/app/pages/account-payment/account-payment-page.component.spec.ts index 3ebab1d809..e956786571 100644 --- a/src/app/pages/account-payment/account-payment-page.component.spec.ts +++ b/src/app/pages/account-payment/account-payment-page.component.spec.ts @@ -3,7 +3,6 @@ import { MockComponent } from 'ng-mocks'; import { instance, mock } from 'ts-mockito'; import { AccountFacade } from 'ish-core/facades/account.facade'; -import { LoadingComponent } from 'ish-shared/components/common/loading/loading.component'; import { AccountPaymentPageComponent } from './account-payment-page.component'; import { AccountPaymentComponent } from './account-payment/account-payment.component'; @@ -16,11 +15,7 @@ describe('Account Payment Page Component', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ - AccountPaymentPageComponent, - MockComponent(AccountPaymentComponent), - MockComponent(LoadingComponent), - ], + declarations: [AccountPaymentPageComponent, MockComponent(AccountPaymentComponent)], providers: [{ provide: AccountFacade, useFactory: () => instance(accountFacade) }], }).compileComponents(); }); diff --git a/src/app/pages/account-profile-company/account-profile-company-page.component.spec.ts b/src/app/pages/account-profile-company/account-profile-company-page.component.spec.ts index 7c76502976..c46d6a1965 100644 --- a/src/app/pages/account-profile-company/account-profile-company-page.component.spec.ts +++ b/src/app/pages/account-profile-company/account-profile-company-page.component.spec.ts @@ -6,7 +6,6 @@ import { instance, mock, when } from 'ts-mockito'; import { AccountFacade } from 'ish-core/facades/account.facade'; import { Customer } from 'ish-core/models/customer/customer.model'; -import { LoadingComponent } from 'ish-shared/components/common/loading/loading.component'; import { AccountProfileCompanyPageComponent } from './account-profile-company-page.component'; import { AccountProfileCompanyComponent } from './account-profile-company/account-profile-company.component'; @@ -23,11 +22,7 @@ describe('Account Profile Company Page Component', () => { await TestBed.configureTestingModule({ imports: [RouterTestingModule], - declarations: [ - AccountProfileCompanyPageComponent, - MockComponent(AccountProfileCompanyComponent), - MockComponent(LoadingComponent), - ], + declarations: [AccountProfileCompanyPageComponent, MockComponent(AccountProfileCompanyComponent)], providers: [{ provide: AccountFacade, useFactory: () => instance(accountFacade) }], }).compileComponents(); }); diff --git a/src/app/pages/account-profile-email/account-profile-email-page.component.spec.ts b/src/app/pages/account-profile-email/account-profile-email-page.component.spec.ts index ef11e3bc8d..26b0dc458c 100644 --- a/src/app/pages/account-profile-email/account-profile-email-page.component.spec.ts +++ b/src/app/pages/account-profile-email/account-profile-email-page.component.spec.ts @@ -3,7 +3,6 @@ import { MockComponent } from 'ng-mocks'; import { instance, mock } from 'ts-mockito'; import { AccountFacade } from 'ish-core/facades/account.facade'; -import { LoadingComponent } from 'ish-shared/components/common/loading/loading.component'; import { AccountProfileEmailPageComponent } from './account-profile-email-page.component'; import { AccountProfileEmailComponent } from './account-profile-email/account-profile-email.component'; @@ -15,11 +14,7 @@ describe('Account Profile Email Page Component', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ - AccountProfileEmailPageComponent, - MockComponent(AccountProfileEmailComponent), - MockComponent(LoadingComponent), - ], + declarations: [AccountProfileEmailPageComponent, MockComponent(AccountProfileEmailComponent)], providers: [{ provide: AccountFacade, useFactory: () => instance(mock(AccountFacade)) }], }).compileComponents(); }); diff --git a/src/app/pages/account-profile-password/account-profile-password-page.component.spec.ts b/src/app/pages/account-profile-password/account-profile-password-page.component.spec.ts index cdfa4af5b7..d566da1d9e 100644 --- a/src/app/pages/account-profile-password/account-profile-password-page.component.spec.ts +++ b/src/app/pages/account-profile-password/account-profile-password-page.component.spec.ts @@ -3,7 +3,6 @@ import { MockComponent } from 'ng-mocks'; import { instance, mock } from 'ts-mockito'; import { AccountFacade } from 'ish-core/facades/account.facade'; -import { LoadingComponent } from 'ish-shared/components/common/loading/loading.component'; import { AccountProfilePasswordPageComponent } from './account-profile-password-page.component'; import { AccountProfilePasswordComponent } from './account-profile-password/account-profile-password.component'; @@ -15,11 +14,7 @@ describe('Account Profile Password Page Component', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ - AccountProfilePasswordPageComponent, - MockComponent(AccountProfilePasswordComponent), - MockComponent(LoadingComponent), - ], + declarations: [AccountProfilePasswordPageComponent, MockComponent(AccountProfilePasswordComponent)], providers: [{ provide: AccountFacade, useFactory: () => instance(mock(AccountFacade)) }], }).compileComponents(); }); diff --git a/src/app/pages/account-profile-user/account-profile-user-page.component.spec.ts b/src/app/pages/account-profile-user/account-profile-user-page.component.spec.ts index 58a3c94892..d8d4481863 100644 --- a/src/app/pages/account-profile-user/account-profile-user-page.component.spec.ts +++ b/src/app/pages/account-profile-user/account-profile-user-page.component.spec.ts @@ -3,7 +3,6 @@ import { MockComponent } from 'ng-mocks'; import { instance, mock } from 'ts-mockito'; import { AccountFacade } from 'ish-core/facades/account.facade'; -import { LoadingComponent } from 'ish-shared/components/common/loading/loading.component'; import { AccountProfileUserPageComponent } from './account-profile-user-page.component'; import { AccountProfileUserComponent } from './account-profile-user/account-profile-user.component'; @@ -15,11 +14,7 @@ describe('Account Profile User Page Component', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ - AccountProfileUserPageComponent, - MockComponent(AccountProfileUserComponent), - MockComponent(LoadingComponent), - ], + declarations: [AccountProfileUserPageComponent, MockComponent(AccountProfileUserComponent)], providers: [{ provide: AccountFacade, useFactory: () => instance(mock(AccountFacade)) }], }).compileComponents(); }); diff --git a/src/app/pages/basket/shopping-basket/shopping-basket.component.spec.ts b/src/app/pages/basket/shopping-basket/shopping-basket.component.spec.ts index 2b5eb16f18..d419892072 100644 --- a/src/app/pages/basket/shopping-basket/shopping-basket.component.spec.ts +++ b/src/app/pages/basket/shopping-basket/shopping-basket.component.spec.ts @@ -18,7 +18,6 @@ import { ModalDialogLinkComponent } from 'ish-shared/components/common/modal-dia import { LineItemListComponent } from 'ish-shared/components/line-item/line-item-list/line-item-list.component'; import { LazyBasketCreateOrderTemplateComponent } from '../../../extensions/order-templates/exports/lazy-basket-create-order-template/lazy-basket-create-order-template.component'; -import { LazyPunchoutTransferBasketComponent } from '../../../extensions/punchout/exports/lazy-punchout-transfer-basket/lazy-punchout-transfer-basket.component'; import { LazyDirectOrderComponent } from '../../../extensions/quickorder/exports/lazy-direct-order/lazy-direct-order.component'; import { LazyBasketAddToQuoteComponent } from '../../../extensions/quoting/exports/lazy-basket-add-to-quote/lazy-basket-add-to-quote.component'; @@ -42,7 +41,6 @@ describe('Shopping Basket Component', () => { MockComponent(LazyBasketAddToQuoteComponent), MockComponent(LazyBasketCreateOrderTemplateComponent), MockComponent(LazyDirectOrderComponent), - MockComponent(LazyPunchoutTransferBasketComponent), MockComponent(LineItemListComponent), MockComponent(ModalDialogLinkComponent), ShoppingBasketComponent, diff --git a/src/app/pages/checkout-address/checkout-address-page.component.spec.ts b/src/app/pages/checkout-address/checkout-address-page.component.spec.ts index a0d5c52456..0f3c0f075a 100644 --- a/src/app/pages/checkout-address/checkout-address-page.component.spec.ts +++ b/src/app/pages/checkout-address/checkout-address-page.component.spec.ts @@ -11,7 +11,6 @@ import { CheckoutFacade } from 'ish-core/facades/checkout.facade'; import { BasketView } from 'ish-core/models/basket/basket.model'; import { User } from 'ish-core/models/user/user.model'; import { BasketMockData } from 'ish-core/utils/dev/basket-mock-data'; -import { LoadingComponent } from 'ish-shared/components/common/loading/loading.component'; import { CheckoutAddressAnonymousComponent } from './checkout-address-anonymous/checkout-address-anonymous.component'; import { CheckoutAddressPageComponent } from './checkout-address-page.component'; @@ -35,10 +34,8 @@ describe('Checkout Address Page Component', () => { await TestBed.configureTestingModule({ declarations: [ CheckoutAddressPageComponent, - DummyComponent, MockComponent(CheckoutAddressAnonymousComponent), MockComponent(CheckoutAddressComponent), - MockComponent(LoadingComponent), ], imports: [ diff --git a/src/app/pages/checkout-payment/checkout-payment-page.component.spec.ts b/src/app/pages/checkout-payment/checkout-payment-page.component.spec.ts index 015443f7dc..481143aa47 100644 --- a/src/app/pages/checkout-payment/checkout-payment-page.component.spec.ts +++ b/src/app/pages/checkout-payment/checkout-payment-page.component.spec.ts @@ -6,7 +6,6 @@ import { instance, mock, when } from 'ts-mockito'; import { CheckoutFacade } from 'ish-core/facades/checkout.facade'; import { BasketMockData } from 'ish-core/utils/dev/basket-mock-data'; -import { LoadingComponent } from 'ish-shared/components/common/loading/loading.component'; import { CheckoutPaymentPageComponent } from './checkout-payment-page.component'; import { CheckoutPaymentComponent } from './checkout-payment/checkout-payment.component'; @@ -22,11 +21,7 @@ describe('Checkout Payment Page Component', () => { when(checkoutFacade.basket$).thenReturn(of(BasketMockData.getBasket())); await TestBed.configureTestingModule({ - declarations: [ - CheckoutPaymentPageComponent, - MockComponent(CheckoutPaymentComponent), - MockComponent(LoadingComponent), - ], + declarations: [CheckoutPaymentPageComponent, MockComponent(CheckoutPaymentComponent)], imports: [TranslateModule.forRoot()], providers: [{ provide: CheckoutFacade, useFactory: () => instance(checkoutFacade) }], diff --git a/src/app/pages/checkout-payment/checkout-payment/checkout-payment.component.spec.ts b/src/app/pages/checkout-payment/checkout-payment/checkout-payment.component.spec.ts index 8b112fa328..d6e2bac4dc 100644 --- a/src/app/pages/checkout-payment/checkout-payment/checkout-payment.component.spec.ts +++ b/src/app/pages/checkout-payment/checkout-payment/checkout-payment.component.spec.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, Component, SimpleChange, SimpleChanges } from '@angular/core'; +import { ChangeDetectionStrategy, SimpleChange, SimpleChanges } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FormControl, ReactiveFormsModule, Validators } from '@angular/forms'; import { RouterTestingModule } from '@angular/router/testing'; @@ -21,12 +21,8 @@ import { ErrorMessageComponent } from 'ish-shared/components/common/error-messag import { InfoMessageComponent } from 'ish-shared/components/common/info-message/info-message.component'; import { PaymentSaveCheckboxComponent } from '../formly/payment-save-checkbox/payment-save-checkbox.component'; -import { PaymentConcardisCreditcardCvcDetailComponent } from '../payment-concardis-creditcard-cvc-detail/payment-concardis-creditcard-cvc-detail.component'; import { PaymentConcardisCreditcardComponent } from '../payment-concardis-creditcard/payment-concardis-creditcard.component'; -import { PaymentConcardisDirectdebitComponent } from '../payment-concardis-directdebit/payment-concardis-directdebit.component'; -import { PaymentCybersourceCreditcardComponent } from '../payment-cybersource-creditcard/payment-cybersource-creditcard.component'; import { PaymentParameterFormComponent } from '../payment-parameter-form/payment-parameter-form.component'; -import { PaymentPayoneCreditcardComponent } from '../payment-payone-creditcard/payment-payone-creditcard.component'; import { CheckoutPaymentComponent } from './checkout-payment.component'; @@ -37,13 +33,9 @@ describe('Checkout Payment Component', () => { let paymentMethodChange: SimpleChanges; beforeEach(async () => { - @Component({ template: 'dummy' }) - class DummyComponent {} - await TestBed.configureTestingModule({ declarations: [ CheckoutPaymentComponent, - DummyComponent, MockComponent(BasketAddressSummaryComponent), MockComponent(BasketCostSummaryComponent), MockComponent(BasketItemsSummaryComponent), @@ -54,10 +46,6 @@ describe('Checkout Payment Component', () => { MockComponent(InfoMessageComponent), MockComponent(NgbCollapse), MockComponent(PaymentConcardisCreditcardComponent), - MockComponent(PaymentConcardisCreditcardCvcDetailComponent), - MockComponent(PaymentConcardisDirectdebitComponent), - MockComponent(PaymentCybersourceCreditcardComponent), - MockComponent(PaymentPayoneCreditcardComponent), MockComponent(PaymentSaveCheckboxComponent), MockDirective(ServerHtmlDirective), MockPipe(PricePipe), @@ -65,7 +53,7 @@ describe('Checkout Payment Component', () => { ], imports: [ ReactiveFormsModule, - RouterTestingModule.withRoutes([{ path: 'checkout/review', component: DummyComponent }]), + RouterTestingModule.withRoutes([{ path: 'checkout/review', children: [] }]), TranslateModule.forRoot(), ], }) diff --git a/src/app/pages/checkout-payment/payment-concardis/payment-concardis.component.spec.ts b/src/app/pages/checkout-payment/payment-concardis/payment-concardis.component.spec.ts index d349fadfa4..0da30ea4d9 100644 --- a/src/app/pages/checkout-payment/payment-concardis/payment-concardis.component.spec.ts +++ b/src/app/pages/checkout-payment/payment-concardis/payment-concardis.component.spec.ts @@ -10,9 +10,7 @@ describe('Payment Concardis Component', () => { let element: HTMLElement; beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [PaymentConcardisComponent], - }).compileComponents(); + await TestBed.configureTestingModule({}).compileComponents(); }); beforeEach(() => { diff --git a/src/app/pages/checkout-payment/payment-parameter-form/payment-parameter-form.component.spec.ts b/src/app/pages/checkout-payment/payment-parameter-form/payment-parameter-form.component.spec.ts index 74b8bbd350..ee90f5828b 100644 --- a/src/app/pages/checkout-payment/payment-parameter-form/payment-parameter-form.component.spec.ts +++ b/src/app/pages/checkout-payment/payment-parameter-form/payment-parameter-form.component.spec.ts @@ -4,7 +4,6 @@ import { FormlyModule } from '@ngx-formly/core'; import { TranslatePipe } from '@ngx-translate/core'; import { MockComponent, MockPipe } from 'ng-mocks'; -import { FormlyTestingComponentsModule } from 'ish-shared/formly/dev/testing/formly-testing-components.module'; import { FormlyTestingExampleComponent } from 'ish-shared/formly/dev/testing/formly-testing-example/formly-testing-example.component'; import { PaymentSaveCheckboxComponent } from '../formly/payment-save-checkbox/payment-save-checkbox.component'; @@ -18,10 +17,7 @@ describe('Payment Parameter Form Component', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [ - FormlyModule.forRoot({ types: [{ name: 'example', component: FormlyTestingExampleComponent }] }), - FormlyTestingComponentsModule, - ], + imports: [FormlyModule.forRoot({ types: [{ name: 'example', component: FormlyTestingExampleComponent }] })], declarations: [ MockComponent(PaymentSaveCheckboxComponent), MockPipe(TranslatePipe), diff --git a/src/app/pages/checkout-receipt/checkout-receipt-page.component.spec.ts b/src/app/pages/checkout-receipt/checkout-receipt-page.component.spec.ts index 6b8071d1e5..f60d95cae5 100644 --- a/src/app/pages/checkout-receipt/checkout-receipt-page.component.spec.ts +++ b/src/app/pages/checkout-receipt/checkout-receipt-page.component.spec.ts @@ -1,10 +1,8 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { MockComponent } from 'ng-mocks'; -import { LazyCheckoutReceiptRequisitionComponent } from 'requisition-management'; import { instance, mock } from 'ts-mockito'; import { CheckoutFacade } from 'ish-core/facades/checkout.facade'; -import { LoadingComponent } from 'ish-shared/components/common/loading/loading.component'; import { CheckoutReceiptOrderComponent } from './checkout-receipt-order/checkout-receipt-order.component'; import { CheckoutReceiptPageComponent } from './checkout-receipt-page.component'; @@ -21,8 +19,6 @@ describe('Checkout Receipt Page Component', () => { CheckoutReceiptPageComponent, MockComponent(CheckoutReceiptComponent), MockComponent(CheckoutReceiptOrderComponent), - MockComponent(LazyCheckoutReceiptRequisitionComponent), - MockComponent(LoadingComponent), ], providers: [{ provide: CheckoutFacade, useFactory: () => instance(mock(CheckoutFacade)) }], }).compileComponents(); diff --git a/src/app/pages/checkout-receipt/checkout-receipt/checkout-receipt.component.spec.ts b/src/app/pages/checkout-receipt/checkout-receipt/checkout-receipt.component.spec.ts index aa54ad9e56..2d9905723b 100644 --- a/src/app/pages/checkout-receipt/checkout-receipt/checkout-receipt.component.spec.ts +++ b/src/app/pages/checkout-receipt/checkout-receipt/checkout-receipt.component.spec.ts @@ -6,7 +6,6 @@ import { MockComponent, MockDirective } from 'ng-mocks'; import { FeatureToggleDirective } from 'ish-core/directives/feature-toggle.directive'; import { BasketMockData } from 'ish-core/utils/dev/basket-mock-data'; import { AddressComponent } from 'ish-shared/components/address/address/address.component'; -import { BasketBuyerComponent } from 'ish-shared/components/basket/basket-buyer/basket-buyer.component'; import { BasketCostSummaryComponent } from 'ish-shared/components/basket/basket-cost-summary/basket-cost-summary.component'; import { InfoBoxComponent } from 'ish-shared/components/common/info-box/info-box.component'; import { LineItemListComponent } from 'ish-shared/components/line-item/line-item-list/line-item-list.component'; @@ -23,7 +22,6 @@ describe('Checkout Receipt Component', () => { declarations: [ CheckoutReceiptComponent, MockComponent(AddressComponent), - MockComponent(BasketBuyerComponent), MockComponent(BasketCostSummaryComponent), MockComponent(FaIconComponent), MockComponent(InfoBoxComponent), diff --git a/src/app/pages/checkout-review/checkout-review/checkout-review.component.spec.ts b/src/app/pages/checkout-review/checkout-review/checkout-review.component.spec.ts index 6ac34ced93..a2d859300b 100644 --- a/src/app/pages/checkout-review/checkout-review/checkout-review.component.spec.ts +++ b/src/app/pages/checkout-review/checkout-review/checkout-review.component.spec.ts @@ -1,6 +1,5 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ReactiveFormsModule } from '@angular/forms'; -import { FaIconComponent } from '@fortawesome/angular-fontawesome'; import { FormlyModule } from '@ngx-formly/core'; import { TranslateModule } from '@ngx-translate/core'; import { MockComponent, MockDirective } from 'ng-mocks'; @@ -14,14 +13,12 @@ import { BasketMockData } from 'ish-core/utils/dev/basket-mock-data'; import { ContentIncludeComponent } from 'ish-shared/cms/components/content-include/content-include.component'; import { AddressComponent } from 'ish-shared/components/address/address/address.component'; import { BasketApprovalInfoComponent } from 'ish-shared/components/basket/basket-approval-info/basket-approval-info.component'; -import { BasketBuyerComponent } from 'ish-shared/components/basket/basket-buyer/basket-buyer.component'; import { BasketCostSummaryComponent } from 'ish-shared/components/basket/basket-cost-summary/basket-cost-summary.component'; import { BasketValidationResultsComponent } from 'ish-shared/components/basket/basket-validation-results/basket-validation-results.component'; import { ErrorMessageComponent } from 'ish-shared/components/common/error-message/error-message.component'; import { InfoBoxComponent } from 'ish-shared/components/common/info-box/info-box.component'; import { ModalDialogLinkComponent } from 'ish-shared/components/common/modal-dialog-link/modal-dialog-link.component'; import { LineItemListComponent } from 'ish-shared/components/line-item/line-item-list/line-item-list.component'; -import { ValidationMessageComponent } from 'ish-shared/formly/components/validation-message/validation-message.component'; import { CheckoutReviewTacFieldComponent } from '../formly/checkout-review-tac-field/checkout-review-tac-field.component'; @@ -39,16 +36,13 @@ describe('Checkout Review Component', () => { CheckoutReviewTacFieldComponent, MockComponent(AddressComponent), MockComponent(BasketApprovalInfoComponent), - MockComponent(BasketBuyerComponent), MockComponent(BasketCostSummaryComponent), MockComponent(BasketValidationResultsComponent), MockComponent(ContentIncludeComponent), MockComponent(ErrorMessageComponent), - MockComponent(FaIconComponent), MockComponent(InfoBoxComponent), MockComponent(LineItemListComponent), MockComponent(ModalDialogLinkComponent), - MockComponent(ValidationMessageComponent), MockDirective(FeatureToggleDirective), MockDirective(ServerHtmlDirective), ], diff --git a/src/app/pages/checkout-shipping/checkout-shipping-page.component.spec.ts b/src/app/pages/checkout-shipping/checkout-shipping-page.component.spec.ts index 99e0fe9694..3d1034029d 100644 --- a/src/app/pages/checkout-shipping/checkout-shipping-page.component.spec.ts +++ b/src/app/pages/checkout-shipping/checkout-shipping-page.component.spec.ts @@ -12,10 +12,8 @@ import { BasketMockData } from 'ish-core/utils/dev/basket-mock-data'; import { BasketAddressSummaryComponent } from 'ish-shared/components/basket/basket-address-summary/basket-address-summary.component'; import { BasketCostSummaryComponent } from 'ish-shared/components/basket/basket-cost-summary/basket-cost-summary.component'; import { BasketItemsSummaryComponent } from 'ish-shared/components/basket/basket-items-summary/basket-items-summary.component'; -import { BasketOrderReferenceComponent } from 'ish-shared/components/basket/basket-order-reference/basket-order-reference.component'; import { BasketValidationResultsComponent } from 'ish-shared/components/basket/basket-validation-results/basket-validation-results.component'; import { ErrorMessageComponent } from 'ish-shared/components/common/error-message/error-message.component'; -import { LoadingComponent } from 'ish-shared/components/common/loading/loading.component'; import { CheckoutShippingPageComponent } from './checkout-shipping-page.component'; import { CheckoutShippingComponent } from './checkout-shipping/checkout-shipping.component'; @@ -34,11 +32,9 @@ describe('Checkout Shipping Page Component', () => { MockComponent(BasketAddressSummaryComponent), MockComponent(BasketCostSummaryComponent), MockComponent(BasketItemsSummaryComponent), - MockComponent(BasketOrderReferenceComponent), MockComponent(BasketValidationResultsComponent), MockComponent(CheckoutShippingComponent), MockComponent(ErrorMessageComponent), - MockComponent(LoadingComponent), MockDirective(ServerHtmlDirective), ], imports: [TranslateModule.forRoot()], diff --git a/src/app/pages/compare/product-compare-list/product-compare-list.component.spec.ts b/src/app/pages/compare/product-compare-list/product-compare-list.component.spec.ts index bd34bcf13a..a88ebdd9d0 100644 --- a/src/app/pages/compare/product-compare-list/product-compare-list.component.spec.ts +++ b/src/app/pages/compare/product-compare-list/product-compare-list.component.spec.ts @@ -12,14 +12,10 @@ import { AttributeToStringPipe } from 'ish-core/models/attribute/attribute.pipe' import { ProductPriceDetails } from 'ish-core/models/product-prices/product-prices.model'; import { ProductView, createProductView } from 'ish-core/models/product-view/product-view.model'; import { Product } from 'ish-core/models/product/product.model'; -import { ProductAddToBasketComponent } from 'ish-shared/components/product/product-add-to-basket/product-add-to-basket.component'; import { ProductAttributesComponent } from 'ish-shared/components/product/product-attributes/product-attributes.component'; -import { ProductIdComponent } from 'ish-shared/components/product/product-id/product-id.component'; import { ProductImageComponent } from 'ish-shared/components/product/product-image/product-image.component'; -import { ProductInventoryComponent } from 'ish-shared/components/product/product-inventory/product-inventory.component'; import { ProductNameComponent } from 'ish-shared/components/product/product-name/product-name.component'; import { ProductPriceComponent } from 'ish-shared/components/product/product-price/product-price.component'; -import { ProductRatingComponent } from 'ish-shared/components/product/product-rating/product-rating.component'; import { ProductComparePagingComponent } from '../product-compare-paging/product-compare-paging.component'; @@ -74,15 +70,11 @@ describe('Product Compare List Component', () => { imports: [TranslateModule.forRoot()], declarations: [ MockComponent(FaIconComponent), - MockComponent(ProductAddToBasketComponent), MockComponent(ProductAttributesComponent), MockComponent(ProductComparePagingComponent), - MockComponent(ProductIdComponent), MockComponent(ProductImageComponent), - MockComponent(ProductInventoryComponent), MockComponent(ProductNameComponent), MockComponent(ProductPriceComponent), - MockComponent(ProductRatingComponent), MockDirective(FeatureToggleDirective), MockDirective(ProductContextDirective), MockPipe(AttributeToStringPipe), diff --git a/src/app/pages/compare/product-compare-paging/product-compare-paging.component.spec.ts b/src/app/pages/compare/product-compare-paging/product-compare-paging.component.spec.ts index 565f3872e3..4844858d57 100644 --- a/src/app/pages/compare/product-compare-paging/product-compare-paging.component.spec.ts +++ b/src/app/pages/compare/product-compare-paging/product-compare-paging.component.spec.ts @@ -1,5 +1,4 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { TranslateModule } from '@ngx-translate/core'; import { anything, capture, spy, verify } from 'ts-mockito'; import { ProductComparePagingComponent } from './product-compare-paging.component'; @@ -11,7 +10,6 @@ describe('Product Compare Paging Component', () => { beforeEach(async () => { await TestBed.configureTestingModule({ declarations: [ProductComparePagingComponent], - imports: [TranslateModule.forRoot()], }).compileComponents(); }); diff --git a/src/app/pages/contact/contact-page.component.spec.ts b/src/app/pages/contact/contact-page.component.spec.ts index 44585748b8..c57f0239d5 100644 --- a/src/app/pages/contact/contact-page.component.spec.ts +++ b/src/app/pages/contact/contact-page.component.spec.ts @@ -6,10 +6,8 @@ import { instance, mock } from 'ts-mockito'; import { AccountFacade } from 'ish-core/facades/account.facade'; import { BreadcrumbComponent } from 'ish-shared/components/common/breadcrumb/breadcrumb.component'; -import { LoadingComponent } from 'ish-shared/components/common/loading/loading.component'; import { ContactConfirmationComponent } from './contact-confirmation/contact-confirmation.component'; -import { ContactFormComponent } from './contact-form/contact-form.component'; import { ContactPageComponent } from './contact-page.component'; describe('Contact Page Component', () => { @@ -24,8 +22,6 @@ describe('Contact Page Component', () => { ContactPageComponent, MockComponent(BreadcrumbComponent), MockComponent(ContactConfirmationComponent), - MockComponent(ContactFormComponent), - MockComponent(LoadingComponent), ], providers: [{ provide: AccountFacade, useFactory: () => instance(mock(AccountFacade)) }], }).compileComponents(); diff --git a/src/app/pages/error/error-page.component.spec.ts b/src/app/pages/error/error-page.component.spec.ts index 9a6dfff07c..90868a28ca 100644 --- a/src/app/pages/error/error-page.component.spec.ts +++ b/src/app/pages/error/error-page.component.spec.ts @@ -6,7 +6,6 @@ import { AppFacade } from 'ish-core/facades/app.facade'; import { ErrorPageComponent } from './error-page.component'; import { ErrorComponent } from './error/error.component'; -import { ServerErrorComponent } from './server-error/server-error.component'; describe('Error Page Component', () => { let component: ErrorPageComponent; @@ -15,7 +14,7 @@ describe('Error Page Component', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ErrorPageComponent, MockComponent(ErrorComponent), MockComponent(ServerErrorComponent)], + declarations: [ErrorPageComponent, MockComponent(ErrorComponent)], providers: [{ provide: AppFacade, useFactory: () => instance(mock(AppFacade)) }], }).compileComponents(); }); diff --git a/src/app/pages/forgot-password/request-reminder/request-reminder.component.spec.ts b/src/app/pages/forgot-password/request-reminder/request-reminder.component.spec.ts index 31d54ab035..5e1655bd02 100644 --- a/src/app/pages/forgot-password/request-reminder/request-reminder.component.spec.ts +++ b/src/app/pages/forgot-password/request-reminder/request-reminder.component.spec.ts @@ -6,7 +6,6 @@ import { instance, mock } from 'ts-mockito'; import { ServerHtmlDirective } from 'ish-core/directives/server-html.directive'; import { AccountFacade } from 'ish-core/facades/account.facade'; import { ErrorMessageComponent } from 'ish-shared/components/common/error-message/error-message.component'; -import { LoadingComponent } from 'ish-shared/components/common/loading/loading.component'; import { RequestReminderFormComponent } from '../request-reminder-form/request-reminder-form.component'; @@ -21,7 +20,6 @@ describe('Request Reminder Component', () => { await TestBed.configureTestingModule({ declarations: [ MockComponent(ErrorMessageComponent), - MockComponent(LoadingComponent), MockComponent(RequestReminderFormComponent), MockDirective(ServerHtmlDirective), RequestReminderComponent, diff --git a/src/app/pages/forgot-password/update-password/update-password.component.spec.ts b/src/app/pages/forgot-password/update-password/update-password.component.spec.ts index e82dd7e4db..5bd0b163b9 100644 --- a/src/app/pages/forgot-password/update-password/update-password.component.spec.ts +++ b/src/app/pages/forgot-password/update-password/update-password.component.spec.ts @@ -7,7 +7,6 @@ import { instance, mock, when } from 'ts-mockito'; import { AccountFacade } from 'ish-core/facades/account.facade'; import { ErrorMessageComponent } from 'ish-shared/components/common/error-message/error-message.component'; -import { LoadingComponent } from 'ish-shared/components/common/loading/loading.component'; import { UpdatePasswordFormComponent } from '../update-password-form/update-password-form.component'; @@ -25,7 +24,6 @@ describe('Update Password Component', () => { await TestBed.configureTestingModule({ declarations: [ MockComponent(ErrorMessageComponent), - MockComponent(LoadingComponent), MockComponent(UpdatePasswordFormComponent), UpdatePasswordComponent, ], diff --git a/src/app/pages/loading/loading-page.component.spec.ts b/src/app/pages/loading/loading-page.component.spec.ts index 23143c8b47..af717096cd 100644 --- a/src/app/pages/loading/loading-page.component.spec.ts +++ b/src/app/pages/loading/loading-page.component.spec.ts @@ -1,7 +1,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { MockComponent } from 'ng-mocks'; -import { LoadingComponent } from 'ish-shared/components/common/loading/loading.component'; +import { findAllCustomElements } from 'ish-core/utils/dev/html-query-utils'; import { LoadingPageComponent } from './loading-page.component'; @@ -11,9 +10,7 @@ describe('Loading Page Component', () => { let element: HTMLElement; beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [LoadingPageComponent, MockComponent(LoadingComponent)], - }).compileComponents(); + await TestBed.configureTestingModule({}).compileComponents(); }); beforeEach(() => { @@ -27,4 +24,14 @@ describe('Loading Page Component', () => { expect(element).toBeTruthy(); expect(() => fixture.detectChanges()).not.toThrow(); }); + + it('should render loading component', () => { + fixture.detectChanges(); + + expect(findAllCustomElements(element)).toMatchInlineSnapshot(` + Array [ + "ish-loading", + ] + `); + }); }); diff --git a/src/app/pages/login/login-page.component.spec.ts b/src/app/pages/login/login-page.component.spec.ts index 48fc00ed62..3e07eb1915 100644 --- a/src/app/pages/login/login-page.component.spec.ts +++ b/src/app/pages/login/login-page.component.spec.ts @@ -8,7 +8,6 @@ import { instance, mock, when } from 'ts-mockito'; import { AccountFacade } from 'ish-core/facades/account.facade'; import { AppFacade } from 'ish-core/facades/app.facade'; import { findAllCustomElements } from 'ish-core/utils/dev/html-query-utils'; -import { LoadingComponent } from 'ish-shared/components/common/loading/loading.component'; import { IdentityProviderLoginComponent } from 'ish-shared/components/login/identity-provider-login/identity-provider-login.component'; import { LoginPageComponent } from './login-page.component'; @@ -25,11 +24,7 @@ describe('Login Page Component', () => { appFacade = mock(AppFacade); await TestBed.configureTestingModule({ imports: [RouterTestingModule, TranslateModule.forRoot()], - declarations: [ - LoginPageComponent, - MockComponent(IdentityProviderLoginComponent), - MockComponent(LoadingComponent), - ], + declarations: [LoginPageComponent, MockComponent(IdentityProviderLoginComponent)], providers: [ { provide: AccountFacade, useFactory: () => instance(mock(AccountFacade)) }, { provide: AppFacade, useFactory: () => instance(appFacade) }, diff --git a/src/app/pages/product/product-bundle-parts/product-bundle-parts.component.spec.ts b/src/app/pages/product/product-bundle-parts/product-bundle-parts.component.spec.ts index c0ea5bd43e..4829c4721e 100644 --- a/src/app/pages/product/product-bundle-parts/product-bundle-parts.component.spec.ts +++ b/src/app/pages/product/product-bundle-parts/product-bundle-parts.component.spec.ts @@ -8,7 +8,6 @@ import { ProductContextDirective } from 'ish-core/directives/product-context.dir import { ProductContextFacade } from 'ish-core/facades/product-context.facade'; import { findAllCustomElements } from 'ish-core/utils/dev/html-query-utils'; import { ProductAddToBasketComponent } from 'ish-shared/components/product/product-add-to-basket/product-add-to-basket.component'; -import { ProductItemComponent } from 'ish-shared/components/product/product-item/product-item.component'; import { ProductBundlePartsComponent } from './product-bundle-parts.component'; @@ -31,7 +30,6 @@ describe('Product Bundle Parts Component', () => { imports: [TranslateModule.forRoot()], declarations: [ MockComponent(ProductAddToBasketComponent), - MockComponent(ProductItemComponent), MockDirective(ProductContextDirective), ProductBundlePartsComponent, ], diff --git a/src/app/pages/product/product-detail-actions/product-detail-actions.component.spec.ts b/src/app/pages/product/product-detail-actions/product-detail-actions.component.spec.ts index 8d87328c1c..f7c5d40ea2 100644 --- a/src/app/pages/product/product-detail-actions/product-detail-actions.component.spec.ts +++ b/src/app/pages/product/product-detail-actions/product-detail-actions.component.spec.ts @@ -11,8 +11,6 @@ import { ProductPriceDetails } from 'ish-core/models/product-prices/product-pric import { createProductView } from 'ish-core/models/product-view/product-view.model'; import { Product } from 'ish-core/models/product/product.model'; -import { LazyProductAddToWishlistComponent } from '../../../extensions/wishlists/exports/lazy-product-add-to-wishlist/lazy-product-add-to-wishlist.component'; - import { ProductDetailActionsComponent } from './product-detail-actions.component'; describe('Product Detail Actions Component', () => { @@ -26,11 +24,7 @@ describe('Product Detail Actions Component', () => { context = mock(ProductContextFacade); await TestBed.configureTestingModule({ imports: [FeatureToggleModule.forTesting('compare'), TranslateModule.forRoot()], - declarations: [ - MockComponent(FaIconComponent), - MockComponent(LazyProductAddToWishlistComponent), - ProductDetailActionsComponent, - ], + declarations: [MockComponent(FaIconComponent), ProductDetailActionsComponent], providers: [{ provide: ProductContextFacade, useFactory: () => instance(context) }], }).compileComponents(); }); diff --git a/src/app/pages/product/product-detail-info/product-detail-info.component.spec.ts b/src/app/pages/product/product-detail-info/product-detail-info.component.spec.ts index a3d3de7163..9a33550742 100644 --- a/src/app/pages/product/product-detail-info/product-detail-info.component.spec.ts +++ b/src/app/pages/product/product-detail-info/product-detail-info.component.spec.ts @@ -1,13 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { NgbNavModule } from '@ng-bootstrap/ng-bootstrap'; -import { TranslateModule } from '@ngx-translate/core'; -import { MockComponent } from 'ng-mocks'; import { instance, mock } from 'ts-mockito'; import { ProductContextFacade } from 'ish-core/facades/product-context.facade'; -import { ProductAttachmentsComponent } from 'ish-shared/components/product/product-attachments/product-attachments.component'; -import { ProductAttributesComponent } from 'ish-shared/components/product/product-attributes/product-attributes.component'; -import { ProductShipmentComponent } from 'ish-shared/components/product/product-shipment/product-shipment.component'; import { ProductDetailInfoComponent } from './product-detail-info.component'; @@ -18,13 +12,7 @@ describe('Product Detail Info Component', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [NgbNavModule, TranslateModule.forRoot()], - declarations: [ - MockComponent(ProductAttachmentsComponent), - MockComponent(ProductAttributesComponent), - MockComponent(ProductShipmentComponent), - ProductDetailInfoComponent, - ], + declarations: [ProductDetailInfoComponent], providers: [{ provide: ProductContextFacade, useFactory: () => instance(mock(ProductContextFacade)) }], }).compileComponents(); }); diff --git a/src/app/pages/product/product-detail/product-detail.component.spec.ts b/src/app/pages/product/product-detail/product-detail.component.spec.ts index 2b733bc156..457773cbc3 100644 --- a/src/app/pages/product/product-detail/product-detail.component.spec.ts +++ b/src/app/pages/product/product-detail/product-detail.component.spec.ts @@ -1,9 +1,10 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { MockComponent } from 'ng-mocks'; -import { EMPTY } from 'rxjs'; +import { of } from 'rxjs'; import { instance, mock, when } from 'ts-mockito'; import { ProductContextFacade } from 'ish-core/facades/product-context.facade'; +import { findAllCustomElements } from 'ish-core/utils/dev/html-query-utils'; import { ContentViewcontextComponent } from 'ish-shared/cms/components/content-viewcontext/content-viewcontext.component'; import { ProductAddToBasketComponent } from 'ish-shared/components/product/product-add-to-basket/product-add-to-basket.component'; import { ProductIdComponent } from 'ish-shared/components/product/product-id/product-id.component'; @@ -34,7 +35,7 @@ describe('Product Detail Component', () => { beforeEach(async () => { const context = mock(ProductContextFacade); - when(context.select('product')).thenReturn(EMPTY); + when(context.select('product')).thenReturn(of({ sku: 'SKU' })); await TestBed.configureTestingModule({ declarations: [ @@ -74,4 +75,31 @@ describe('Product Detail Component', () => { expect(element).toBeTruthy(); expect(() => fixture.detectChanges()).not.toThrow(); }); + + it('should render standard elements', () => { + fixture.detectChanges(); + expect(findAllCustomElements(element)).toMatchInlineSnapshot(` + Array [ + "ish-product-detail-actions", + "ish-product-images", + "ish-product-rating", + "ish-product-name", + "ish-product-brand", + "ish-product-id", + "ish-product-promotion", + "ish-product-price", + "ish-product-inventory", + "ish-product-shipment", + "ish-product-detail-variations", + "ish-lazy-tacton-configure-product", + "ish-product-quantity-label", + "ish-product-quantity", + "ish-product-add-to-basket", + "ish-lazy-product-add-to-order-template", + "ish-lazy-product-add-to-quote", + "ish-content-viewcontext", + "ish-product-detail-info", + ] + `); + }); }); diff --git a/src/app/pages/product/product-links-carousel/product-links-carousel.component.spec.ts b/src/app/pages/product/product-links-carousel/product-links-carousel.component.spec.ts index 4994145a0c..6a198ea164 100644 --- a/src/app/pages/product/product-links-carousel/product-links-carousel.component.spec.ts +++ b/src/app/pages/product/product-links-carousel/product-links-carousel.component.spec.ts @@ -1,5 +1,5 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { MockComponent, MockDirective } from 'ng-mocks'; +import { MockDirective } from 'ng-mocks'; import { of } from 'rxjs'; import { SwiperComponent, SwiperSlideDirective } from 'swiper/angular'; import { anything, instance, mock, when } from 'ts-mockito'; @@ -8,7 +8,6 @@ import { ProductContextDirective } from 'ish-core/directives/product-context.dir import { ShoppingFacade } from 'ish-core/facades/shopping.facade'; import { ProductLinks } from 'ish-core/models/product-links/product-links.model'; import { ProductView } from 'ish-core/models/product-view/product-view.model'; -import { ProductItemComponent } from 'ish-shared/components/product/product-item/product-item.component'; import { ProductLinksCarouselComponent } from './product-links-carousel.component'; @@ -23,7 +22,6 @@ describe('Product Links Carousel Component', () => { await TestBed.configureTestingModule({ declarations: [ - MockComponent(ProductItemComponent), MockDirective(ProductContextDirective), ProductLinksCarouselComponent, SwiperComponent, diff --git a/src/app/pages/product/product-links-list/product-links-list.component.spec.ts b/src/app/pages/product/product-links-list/product-links-list.component.spec.ts index 4d84fa2e84..0c5c3e0f81 100644 --- a/src/app/pages/product/product-links-list/product-links-list.component.spec.ts +++ b/src/app/pages/product/product-links-list/product-links-list.component.spec.ts @@ -1,5 +1,5 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { MockComponent, MockDirective } from 'ng-mocks'; +import { MockDirective } from 'ng-mocks'; import { of } from 'rxjs'; import { anything, instance, mock, when } from 'ts-mockito'; @@ -7,7 +7,6 @@ import { ProductContextDirective } from 'ish-core/directives/product-context.dir import { ShoppingFacade } from 'ish-core/facades/shopping.facade'; import { ProductLinks } from 'ish-core/models/product-links/product-links.model'; import { ProductView } from 'ish-core/models/product-view/product-view.model'; -import { ProductItemComponent } from 'ish-shared/components/product/product-item/product-item.component'; import { ProductLinksListComponent } from './product-links-list.component'; @@ -21,11 +20,7 @@ describe('Product Links List Component', () => { shoppingFacade = mock(ShoppingFacade); await TestBed.configureTestingModule({ - declarations: [ - MockComponent(ProductItemComponent), - MockDirective(ProductContextDirective), - ProductLinksListComponent, - ], + declarations: [MockDirective(ProductContextDirective), ProductLinksListComponent], providers: [{ provide: ShoppingFacade, useFactory: () => instance(shoppingFacade) }], }).compileComponents(); }); diff --git a/src/app/pages/product/product-links/product-links.component.spec.ts b/src/app/pages/product/product-links/product-links.component.spec.ts index d1c437e16f..1ba494e2f3 100644 --- a/src/app/pages/product/product-links/product-links.component.spec.ts +++ b/src/app/pages/product/product-links/product-links.component.spec.ts @@ -1,13 +1,8 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { TranslateModule } from '@ngx-translate/core'; -import { MockComponent } from 'ng-mocks'; import { instance, mock } from 'ts-mockito'; import { ProductContextFacade } from 'ish-core/facades/product-context.facade'; -import { ProductLinksCarouselComponent } from '../product-links-carousel/product-links-carousel.component'; -import { ProductLinksListComponent } from '../product-links-list/product-links-list.component'; - import { ProductLinksComponent } from './product-links.component'; describe('Product Links Component', () => { @@ -17,12 +12,7 @@ describe('Product Links Component', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [TranslateModule.forRoot()], - declarations: [ - MockComponent(ProductLinksCarouselComponent), - MockComponent(ProductLinksListComponent), - ProductLinksComponent, - ], + declarations: [ProductLinksComponent], providers: [{ provide: ProductContextFacade, useFactory: () => instance(mock(ProductContextFacade)) }], }).compileComponents(); }); diff --git a/src/app/pages/product/retail-set-parts/retail-set-parts.component.spec.ts b/src/app/pages/product/retail-set-parts/retail-set-parts.component.spec.ts index cf61c14b2e..ff08c17d31 100644 --- a/src/app/pages/product/retail-set-parts/retail-set-parts.component.spec.ts +++ b/src/app/pages/product/retail-set-parts/retail-set-parts.component.spec.ts @@ -8,7 +8,6 @@ import { ProductContextDirective } from 'ish-core/directives/product-context.dir import { ProductContextFacade } from 'ish-core/facades/product-context.facade'; import { findAllCustomElements } from 'ish-core/utils/dev/html-query-utils'; import { ProductAddToBasketComponent } from 'ish-shared/components/product/product-add-to-basket/product-add-to-basket.component'; -import { ProductItemComponent } from 'ish-shared/components/product/product-item/product-item.component'; import { RetailSetPartsComponent } from './retail-set-parts.component'; @@ -32,7 +31,6 @@ describe('Retail Set Parts Component', () => { imports: [TranslateModule.forRoot()], declarations: [ MockComponent(ProductAddToBasketComponent), - MockComponent(ProductItemComponent), MockDirective(ProductContextDirective), RetailSetPartsComponent, ], diff --git a/src/app/pages/registration/registration-page.component.spec.ts b/src/app/pages/registration/registration-page.component.spec.ts index 60537ebaca..0c6839b98e 100644 --- a/src/app/pages/registration/registration-page.component.spec.ts +++ b/src/app/pages/registration/registration-page.component.spec.ts @@ -8,7 +8,6 @@ import { anything, instance, mock, verify, when } from 'ts-mockito'; import { AccountFacade } from 'ish-core/facades/account.facade'; import { ErrorMessageComponent } from 'ish-shared/components/common/error-message/error-message.component'; -import { LoadingComponent } from 'ish-shared/components/common/loading/loading.component'; import { FormlyTestingModule } from 'ish-shared/formly/dev/testing/formly-testing.module'; import { RegistrationPageComponent } from './registration-page.component'; @@ -27,7 +26,7 @@ describe('Registration Page Component', () => { configService = mock(RegistrationFormConfigurationService); activatedRoute = mock(ActivatedRoute); await TestBed.configureTestingModule({ - declarations: [MockComponent(ErrorMessageComponent), MockComponent(LoadingComponent), RegistrationPageComponent], + declarations: [MockComponent(ErrorMessageComponent), RegistrationPageComponent], imports: [FormlyTestingModule, TranslateModule.forRoot()], providers: [ { provide: AccountFacade, useFactory: () => instance(accountFacade) }, diff --git a/src/app/shell/footer/footer-top/footer-top.component.spec.ts b/src/app/shell/footer/footer-top/footer-top.component.spec.ts index 66f7e7093d..0ea97adefd 100644 --- a/src/app/shell/footer/footer-top/footer-top.component.spec.ts +++ b/src/app/shell/footer/footer-top/footer-top.component.spec.ts @@ -1,6 +1,5 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FaIconComponent } from '@fortawesome/angular-fontawesome'; -import { TranslateModule } from '@ngx-translate/core'; import { MockComponent } from 'ng-mocks'; import { FeatureToggleModule } from 'ish-core/feature-toggle.module'; @@ -15,7 +14,7 @@ describe('Footer Top Component', () => { beforeEach(async () => { await TestBed.configureTestingModule({ declarations: [FooterTopComponent, MockComponent(FaIconComponent)], - imports: [FeatureToggleModule.forTesting('storeLocator'), TranslateModule.forRoot()], + imports: [FeatureToggleModule.forTesting('storeLocator')], }).compileComponents(); }); diff --git a/src/app/shell/footer/footer/footer.component.spec.ts b/src/app/shell/footer/footer/footer.component.spec.ts index 6f5ef61c5d..2d006b7cb0 100644 --- a/src/app/shell/footer/footer/footer.component.spec.ts +++ b/src/app/shell/footer/footer/footer.component.spec.ts @@ -1,9 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { BrowserTransferStateModule } from '@angular/platform-browser'; -import { TranslateModule } from '@ngx-translate/core'; -import { MockComponent, MockDirective } from 'ng-mocks'; +import { MockComponent } from 'ng-mocks'; -import { ServerHtmlDirective } from 'ish-core/directives/server-html.directive'; import { RoleToggleModule } from 'ish-core/role-toggle.module'; import { FooterTopComponent } from 'ish-shell/footer/footer-top/footer-top.component'; @@ -16,8 +14,8 @@ describe('Footer Component', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [BrowserTransferStateModule, RoleToggleModule.forTesting(), TranslateModule.forRoot()], - declarations: [FooterComponent, MockComponent(FooterTopComponent), MockDirective(ServerHtmlDirective)], + imports: [BrowserTransferStateModule, RoleToggleModule.forTesting()], + declarations: [FooterComponent, MockComponent(FooterTopComponent)], }).compileComponents(); }); diff --git a/src/app/shell/header/header-checkout/header-checkout.component.spec.ts b/src/app/shell/header/header-checkout/header-checkout.component.spec.ts index 475f47c52f..2424617ad9 100644 --- a/src/app/shell/header/header-checkout/header-checkout.component.spec.ts +++ b/src/app/shell/header/header-checkout/header-checkout.component.spec.ts @@ -1,8 +1,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { MockComponent } from 'ng-mocks'; import { findAllCustomElements } from 'ish-core/utils/dev/html-query-utils'; -import { LoginStatusComponent } from 'ish-shell/header/login-status/login-status.component'; import { HeaderCheckoutComponent } from './header-checkout.component'; @@ -12,9 +10,7 @@ describe('Header Checkout Component', () => { let element: HTMLElement; beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [HeaderCheckoutComponent, MockComponent(LoginStatusComponent)], - }).compileComponents(); + await TestBed.configureTestingModule({}).compileComponents(); }); beforeEach(() => { diff --git a/src/app/shell/header/header-default/header-default.component.spec.ts b/src/app/shell/header/header-default/header-default.component.spec.ts index 4a56cf5f4b..116a0750e7 100644 --- a/src/app/shell/header/header-default/header-default.component.spec.ts +++ b/src/app/shell/header/header-default/header-default.component.spec.ts @@ -15,7 +15,6 @@ import { UserInformationMobileComponent } from 'ish-shell/header/user-informatio import { LazySearchBoxComponent } from 'ish-shell/shared/lazy-search-box/lazy-search-box.component'; import { LazyQuickorderLinkComponent } from '../../../extensions/quickorder/exports/lazy-quickorder-link/lazy-quickorder-link.component'; -import { LazyWishlistsLinkComponent } from '../../../extensions/wishlists/exports/lazy-wishlists-link/lazy-wishlists-link.component'; import { HeaderDefaultComponent } from './header-default.component'; @@ -34,7 +33,6 @@ describe('Header Default Component', () => { MockComponent(LanguageSwitchComponent), MockComponent(LazyQuickorderLinkComponent), MockComponent(LazySearchBoxComponent), - MockComponent(LazyWishlistsLinkComponent), MockComponent(LoginStatusComponent), MockComponent(MiniBasketComponent), MockComponent(NgbCollapse), diff --git a/src/app/shell/header/header/header.component.spec.ts b/src/app/shell/header/header/header.component.spec.ts index 90b216154b..831f820b63 100644 --- a/src/app/shell/header/header/header.component.spec.ts +++ b/src/app/shell/header/header/header.component.spec.ts @@ -6,7 +6,6 @@ import { instance, mock, when } from 'ts-mockito'; import { AppFacade } from 'ish-core/facades/app.facade'; import { findAllCustomElements } from 'ish-core/utils/dev/html-query-utils'; -import { HeaderCheckoutComponent } from 'ish-shell/header/header-checkout/header-checkout.component'; import { HeaderDefaultComponent } from 'ish-shell/header/header-default/header-default.component'; import { HeaderSimpleComponent } from 'ish-shell/header/header-simple/header-simple.component'; @@ -24,12 +23,7 @@ describe('Header Component', () => { await TestBed.configureTestingModule({ imports: [RouterTestingModule], - declarations: [ - HeaderComponent, - MockComponent(HeaderCheckoutComponent), - MockComponent(HeaderDefaultComponent), - MockComponent(HeaderSimpleComponent), - ], + declarations: [HeaderComponent, MockComponent(HeaderDefaultComponent), MockComponent(HeaderSimpleComponent)], providers: [{ provide: AppFacade, useFactory: () => instance(appFacade) }], }).compileComponents(); });