Skip to content

Commit

Permalink
V0.5.8, fixing all ut errors
Browse files Browse the repository at this point in the history
  • Loading branch information
alvachien committed Mar 21, 2021
1 parent 0a089f7 commit c35d6d5
Show file tree
Hide file tree
Showing 17 changed files with 44 additions and 36 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "acgallery",
"version": "0.5.6",
"version": "0.5.8",
"license": "MIT",
"scripts": {
"ng": "ng",
Expand Down
11 changes: 3 additions & 8 deletions src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { TestBed, } from '@angular/core/testing';
import { HttpClient } from '@angular/common/http';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { BehaviorSubject, of } from 'rxjs';
import { Router, ActivatedRoute, UrlSegment } from '@angular/router';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NO_ERRORS_SCHEMA } from '@angular/core';

import { AppComponent } from './app.component';
import { RouterLinkStubDirective } from '../testing';
import { TestingDependsModule, getTranslocoModule } from 'src/testing/';

describe('AppComponent', () => {
beforeEach(async() => {
Expand All @@ -20,9 +16,8 @@ describe('AppComponent', () => {

await TestBed.configureTestingModule({
imports: [
HttpClientTestingModule,
RouterTestingModule,
BrowserAnimationsModule,
TestingDependsModule,
getTranslocoModule(),
],
declarations: [
AppComponent,
Expand Down
2 changes: 1 addition & 1 deletion src/app/models/photo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ describe('Photo', () => {
it('generateJson', () => {
objInstance.photoId = 'Test 1';
let odata = objInstance.generateJson();
expect(odata.PhotoID).toEqual(objInstance.photoId);
expect(odata.PhotoId).toEqual(objInstance.photoId);
});
});
3 changes: 2 additions & 1 deletion src/app/pages/about/about.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { TestingDependsModule } from 'src/testing/';
import { TestingDependsModule, getTranslocoModule } from 'src/testing/';
import { AboutComponent } from './about.component';

describe('AboutComponent', () => {
Expand All @@ -11,6 +11,7 @@ describe('AboutComponent', () => {
await TestBed.configureTestingModule({
imports: [
TestingDependsModule,
getTranslocoModule(),
],
declarations: [ AboutComponent ]
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { TestingDependsModule } from 'src/testing/';
import { TestingDependsModule, getTranslocoModule } from 'src/testing/';
import { AlbumDetailComponent } from './album-detail.component';

describe('AlbumDetailComponent', () => {
Expand All @@ -11,6 +11,7 @@ describe('AlbumDetailComponent', () => {
await TestBed.configureTestingModule({
imports: [
TestingDependsModule,
getTranslocoModule(),
],
declarations: [ AlbumDetailComponent ]
})
Expand Down
3 changes: 2 additions & 1 deletion src/app/pages/album/album-list/album-list.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { TestingDependsModule } from 'src/testing/';
import { TestingDependsModule, getTranslocoModule } from 'src/testing/';
import { AlbumListComponent } from './album-list.component';
import { OdataService } from 'src/app/services';

Expand All @@ -12,6 +12,7 @@ describe('AlbumListComponent', () => {
await TestBed.configureTestingModule({
imports: [
TestingDependsModule,
getTranslocoModule(),
],
declarations: [
AlbumListComponent,
Expand Down
3 changes: 2 additions & 1 deletion src/app/pages/credits/credits.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { TestingDependsModule } from 'src/testing/';
import { TestingDependsModule, getTranslocoModule } from 'src/testing/';
import { CreditsComponent } from './credits.component';

describe('CreditsComponent', () => {
Expand All @@ -11,6 +11,7 @@ describe('CreditsComponent', () => {
await TestBed.configureTestingModule({
imports: [
TestingDependsModule,
getTranslocoModule(),
],
declarations: [
CreditsComponent,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { TestingDependsModule } from 'src/testing/';
import { TestingDependsModule, getTranslocoModule } from 'src/testing/';
import { PhotoDetailComponent } from './photo-detail.component';

describe('PhotoDetailComponent', () => {
Expand All @@ -11,6 +11,7 @@ describe('PhotoDetailComponent', () => {
await TestBed.configureTestingModule({
imports: [
TestingDependsModule,
getTranslocoModule(),
],
declarations: [ PhotoDetailComponent ]
})
Expand Down
3 changes: 2 additions & 1 deletion src/app/pages/photo/photo-list/photo-list.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { TestingDependsModule } from 'src/testing/';
import { TestingDependsModule, getTranslocoModule } from 'src/testing/';
import { PhotoListComponent } from './photo-list.component';

describe('PhotoListComponent', () => {
Expand All @@ -11,6 +11,7 @@ describe('PhotoListComponent', () => {
await TestBed.configureTestingModule({
imports: [
TestingDependsModule,
getTranslocoModule(),
],
declarations: [
PhotoListComponent,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { TestingDependsModule, getTranslocoModule } from 'src/testing/';
import { PhotoUploadComponent } from './photo-upload.component';

describe('PhotoUploadComponent', () => {
Expand All @@ -8,6 +9,10 @@ describe('PhotoUploadComponent', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [
TestingDependsModule,
getTranslocoModule(),
],
declarations: [ PhotoUploadComponent ]
})
.compileComponents();
Expand Down
8 changes: 7 additions & 1 deletion src/app/services/auth.guard.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { TestBed } from '@angular/core/testing';

import { TestingDependsModule, getTranslocoModule } from 'src/testing/';
import { AuthGuard } from './auth.guard';

describe('AuthGuard', () => {
let guard: AuthGuard;

beforeEach(() => {
TestBed.configureTestingModule({});
TestBed.configureTestingModule({
imports: [
TestingDependsModule,
getTranslocoModule(),
]
});
guard = TestBed.inject(AuthGuard);
});

Expand Down
2 changes: 1 addition & 1 deletion src/environments/environment.azure.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const environment = {
production: true,
currentVersion: '0.5.6',
currentVersion: '0.5.8',
currentReleaseDate: '2019.7.10',
loggingLevel: 1, // Crash
basehref: '/',
Expand Down
2 changes: 1 addition & 1 deletion src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const environment = {
production: true,
currentVersion: '0.5.6',
currentVersion: '0.5.8',
currentReleaseDate: '2019.7.10',
loggingLevel: 1, // Crash
basehref: '/',
Expand Down
2 changes: 1 addition & 1 deletion src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

export const environment = {
production: false,
currentVersion: '0.5.6',
currentVersion: '0.5.8',
currentReleaseDate: '2021.7.9',
loggingLevel: 4, // Debug
basehref: '/',
Expand Down
1 change: 1 addition & 0 deletions src/testing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from './route-link-stub-directive';

export * from './fake-data-helper';
export * from './testing-depends.module';
export * from './transloco-testing.module';
10 changes: 2 additions & 8 deletions src/testing/testing-depends.module.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
import { NgModule } from '@angular/core';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { FormsModule } from '@angular/forms';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { RouterTestingModule } from '@angular/router/testing';

import { UIModulesModule } from 'src/app/ui-modules.module';
import { getTranslocoModule } from './transloco-testing.module';
import { TranslocoModule, TranslocoTestingModule } from '@ngneat/transloco';

@NgModule({
imports: [
TranslocoTestingModule.forRoot({
}),
],
exports: [
HttpClientTestingModule,
FormsModule,
ReactiveFormsModule,
NoopAnimationsModule,
RouterTestingModule,

TranslocoTestingModule,

UIModulesModule,
]
})
Expand Down
17 changes: 9 additions & 8 deletions src/testing/transloco-testing.module.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { TranslocoTestingModule, TranslocoConfig } from '@ngneat/transloco';
import { TranslocoTestingModule, TranslocoConfig, TranslocoTestingOptions } from '@ngneat/transloco';
import * as en from '../assets/i18n/en.json';
import * as zh from '../assets/i18n/zh.json';
export function getTranslocoModule(config: Partial<TranslocoConfig> = {}) {
return TranslocoTestingModule.withLangs(
{ en, zh },
{
export function getTranslocoModule(options: TranslocoTestingOptions = {}) {
return TranslocoTestingModule.forRoot({
langs: { en, zh },
translocoConfig: {
availableLangs: ['en', 'zh'],
defaultLang: 'en',
...config
}
);
},
preloadLangs: true,
...options
});
}

0 comments on commit c35d6d5

Please sign in to comment.