Skip to content

Commit

Permalink
chore: run cleanup-testbed
Browse files Browse the repository at this point in the history
  • Loading branch information
dhhyi committed Mar 10, 2022
1 parent 838d9d5 commit a975bd8
Show file tree
Hide file tree
Showing 53 changed files with 103 additions and 302 deletions.
11 changes: 1 addition & 10 deletions src/app/core/guards/auth.guard.spec.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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();
});
Expand Down
11 changes: 3 additions & 8 deletions src/app/core/guards/authorization-toggle.guard.spec.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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' },
},
Expand Down
11 changes: 3 additions & 8 deletions src/app/core/guards/feature-toggle.guard.spec.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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' },
},
Expand Down
13 changes: 4 additions & 9 deletions src/app/core/identity-provider/auth0.identity-provider.spec.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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 = {
Expand Down Expand Up @@ -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: [
Expand Down
10 changes: 1 addition & 9 deletions src/app/core/routing/category/category.route.spec.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 1 addition & 9 deletions src/app/core/routing/product/product.route.spec.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 1 addition & 6 deletions src/app/core/services/api/api.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down
9 changes: 2 additions & 7 deletions src/app/core/store/customer/customer-store.spec.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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()));

Expand Down Expand Up @@ -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,
Expand Down
19 changes: 7 additions & 12 deletions src/app/core/store/shopping/shopping-store.spec.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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,
Expand All @@ -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);
Expand Down Expand Up @@ -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 },
Expand Down
2 changes: 0 additions & 2 deletions src/app/core/utils/meta-reducers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -22,7 +21,6 @@ describe('Meta Reducers', () => {
CoreStoreModule.forTesting(['configuration'], true, [
resetSubStatesOnActionsMeta<CoreState>(['configuration'], [logoutUser]),
]),
CustomerStoreModule.forTesting('user'),
],
providers: [provideStoreSnapshots()],
});
Expand Down
Loading

1 comment on commit a975bd8

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Azure Demo Servers are available:

Please sign in to comment.