Merge pull request #636 from aspnetboilerplate/fix/6378

fixes angular unit test problems
This commit is contained in:
İsmail ÇAĞDAŞ 2022-02-28 14:28:02 +03:00 коммит произвёл GitHub
Родитель 4a65539ea4 1d65e9e4ae
Коммит 1a0f170bed
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 113 добавлений и 21 удалений

Просмотреть файл

@ -121,6 +121,7 @@
"main": "src/test.ts",
"karmaConfig": "./karma.conf.js",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"assets": [
"src/assets",
"src/favicon.ico",

Просмотреть файл

@ -13,6 +13,17 @@
"target": "es6",
"typeRoots": [
"../node_modules/@types"
]
}
],
"baseUrl": ".",
"paths": {
"@abp/*": [ "../node_modules/abp-ng2-module/dist/src/*" ],
"@app/*": [ "./app/*" ],
"@shared/*": [ "./shared/*" ],
"@node_modules/*": [ "../node_modules/*" ]
}
},
"files": [
"../src/polyfills.ts",
"../src/test.ts"
],
}

Просмотреть файл

@ -1,34 +1,97 @@
/* tslint:disable:no-unused-variable */
import { TestBed, async } from "@angular/core/testing";
import { AppComponent } from "./app.component";
import { LayoutStoreService } from "../shared/layout/layout-store.service";
import { AppSessionService } from "../shared/session/app-session.service";
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
import { CommonModule } from "@angular/common";
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
import { HttpClientJsonpModule } from "@angular/common/http";
import { HttpClientModule } from "@angular/common/http";
import { ModalModule } from "ngx-bootstrap/modal";
import { BsDropdownModule } from "ngx-bootstrap/dropdown";
import { CollapseModule } from "ngx-bootstrap/collapse";
import { TabsModule } from "ngx-bootstrap/tabs";
import { NgxPaginationModule } from "ngx-pagination";
import { RouterTestingModule } from "@angular/router/testing";
import { ServiceProxyModule } from "../shared/service-proxies/service-proxy.module";
import { SharedModule } from "../shared/shared.module";
import { HomeComponent } from "../app/home/home.component";
import { AboutComponent } from "../app/about/about.component";
describe('AppComponent', () => {
// layout
import { HeaderComponent } from "./layout/header.component";
import { HeaderLeftNavbarComponent } from "./layout/header-left-navbar.component";
import { HeaderLanguageMenuComponent } from "./layout/header-language-menu.component";
import { HeaderUserMenuComponent } from "./layout/header-user-menu.component";
import { FooterComponent } from "./layout/footer.component";
import { SidebarComponent } from "./layout/sidebar.component";
import { SidebarLogoComponent } from "./layout/sidebar-logo.component";
import { SidebarUserPanelComponent } from "./layout/sidebar-user-panel.component";
import { SidebarMenuComponent } from "./layout/sidebar-menu.component";
describe("AppComponent", () => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
AppComponent,
HomeComponent,
AboutComponent,
// layout
HeaderComponent,
HeaderLeftNavbarComponent,
HeaderLanguageMenuComponent,
HeaderUserMenuComponent,
FooterComponent,
SidebarComponent,
SidebarLogoComponent,
SidebarUserPanelComponent,
SidebarMenuComponent,
],
imports: [
BrowserAnimationsModule,
CommonModule,
FormsModule,
ReactiveFormsModule,
HttpClientModule,
HttpClientJsonpModule,
ModalModule.forChild(),
BsDropdownModule.forRoot(),
CollapseModule.forRoot(),
TabsModule.forRoot(),
RouterTestingModule,
ServiceProxyModule,
SharedModule.forRoot(),
NgxPaginationModule,
],
providers: [
LayoutStoreService,
{
provide: AppSessionService,
useValue: {
application: {
version: "",
releaseDate: {
format: function () {
return "";
},
},
},
getShownLoginName: function(){
return 'admin';
}
},
},
],
});
TestBed.compileComponents();
});
it('should create the app', async(() => {
it("should create the app", async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));
it(`should have as title 'app works!'`, async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('app works!');
}));
it('should render title in a h1 tag', async(() => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('app works!');
}));
});

Просмотреть файл

@ -0,0 +1,17 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/spec",
"types": [
"jasmine"
]
},
"files": [
"test.ts",
"polyfills.ts"
],
"include": [
"**/*.spec.ts",
"**/*.d.ts"
]
}