This commit is contained in:
Bastian Wagner
2024-11-28 11:45:36 +01:00
parent d398b37007
commit 22dc6033c9
25 changed files with 5018 additions and 550 deletions

View File

@@ -86,28 +86,6 @@
}, },
"extract-i18n": { "extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n" "builder": "@angular-devkit/build-angular:extract-i18n"
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"polyfills": [
"zone.js",
"zone.js/testing"
],
"tsConfig": "tsconfig.spec.json",
"inlineStyleLanguage": "scss",
"assets": [
{
"glob": "**/*",
"input": "public"
}
],
"styles": [
"@angular/material/prebuilt-themes/azure-blue.css",
"src/styles.scss"
],
"scripts": []
}
} }
} }
} }

8
client/jest.config.ts Normal file
View File

@@ -0,0 +1,8 @@
import type { Config } from 'jest';
const jestConfig: Config = {
preset: 'jest-preset-angular',
setupFilesAfterEnv: ['<rootDir>/setup-jest.ts'],
};
export default jestConfig;

5074
client/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -6,7 +6,8 @@
"start": "ng serve", "start": "ng serve",
"build": "ng build", "build": "ng build",
"watch": "ng build --watch --configuration development", "watch": "ng build --watch --configuration development",
"test": "ng test" "test": "jest",
"test:watch": "jest --watch --onlyChanged"
}, },
"private": true, "private": true,
"dependencies": { "dependencies": {
@@ -35,13 +36,10 @@
"@angular/cli": "^18.0.2", "@angular/cli": "^18.0.2",
"@angular/compiler-cli": "^18.0.0", "@angular/compiler-cli": "^18.0.0",
"@faker-js/faker": "^9.0.3", "@faker-js/faker": "^9.0.3",
"@types/jasmine": "~5.1.0", "@types/jest": "^29.5.14",
"jasmine-core": "~5.1.0", "jest": "^29.7.0",
"karma": "~6.4.0", "jest-preset-angular": "^14.4.0",
"karma-chrome-launcher": "~3.2.0", "ts-node": "^10.9.2",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"typescript": "~5.4.2" "typescript": "~5.4.2"
} }
} }

3
client/setup-jest.ts Normal file
View File

@@ -0,0 +1,3 @@
import { setupZoneTestEnv } from 'jest-preset-angular/setup-env/zone';
setupZoneTestEnv();

View File

@@ -1,16 +1 @@
<router-outlet></router-outlet> <router-outlet></router-outlet>
<!-- <div class="example-sidenav-content">
<button type="button" mat-button (click)="drawer.toggle()">
Toggle sidenav
</button>
</div> -->
<!-- <div class="content" style="width: 100%; height: 100%;"> -->
<!-- The AG Grid component, with Dimensions, CSS Theme, Row Data, and Column Definition -->
<!-- </div> -->

View File

@@ -1,10 +1,15 @@
import { TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
import { provideHttpClient } from '@angular/common/http';
describe('AppComponent', () => { describe('AppComponent', () => {
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
imports: [AppComponent], imports: [AppComponent],
providers: [
provideHttpClient(),
provideHttpClient(),
]
}).compileComponents(); }).compileComponents();
}); });
@@ -14,16 +19,4 @@ describe('AppComponent', () => {
expect(app).toBeTruthy(); expect(app).toBeTruthy();
}); });
it(`should have the 'client' title`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app.title).toEqual('client');
});
it('should render title', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement as HTMLElement;
expect(compiled.querySelector('h1')?.textContent).toContain('Hello, client');
});
}); });

View File

@@ -1,5 +1,4 @@
import { HttpClient } from '@angular/common/http'; import { Component, LOCALE_ID } from '@angular/core';
import { Component, inject, LOCALE_ID } from '@angular/core';
import { MAT_DATE_LOCALE } from '@angular/material/core'; import { MAT_DATE_LOCALE } from '@angular/material/core';
import { RouterOutlet } from '@angular/router'; import { RouterOutlet } from '@angular/router';
@@ -15,14 +14,5 @@ import { RouterOutlet } from '@angular/router';
styleUrl: './app.component.scss' styleUrl: './app.component.scss'
}) })
export class AppComponent { export class AppComponent {
title = 'client';
private http: HttpClient = inject(HttpClient);
constructor() {
} }
ngOnInit(): void {
}
}

View File

@@ -1,23 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { LayoutComponent } from './layout.component';
describe('LayoutComponent', () => {
let component: LayoutComponent;
let fixture: ComponentFixture<LayoutComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [LayoutComponent]
})
.compileComponents();
fixture = TestBed.createComponent(LayoutComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,23 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AllUsersComponent } from './all-users.component';
describe('AllUsersComponent', () => {
let component: AllUsersComponent;
let fixture: ComponentFixture<AllUsersComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [AllUsersComponent]
})
.compileComponents();
fixture = TestBed.createComponent(AllUsersComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,23 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { LoginComponent } from './login.component';
describe('LoginComponent', () => {
let component: LoginComponent;
let fixture: ComponentFixture<LoginComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [LoginComponent]
})
.compileComponents();
fixture = TestBed.createComponent(LoginComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,23 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { DeleteCylinderComponent } from './delete-cylinder.component';
describe('DeleteCylinderComponent', () => {
let component: DeleteCylinderComponent;
let fixture: ComponentFixture<DeleteCylinderComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [DeleteCylinderComponent]
})
.compileComponents();
fixture = TestBed.createComponent(DeleteCylinderComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,23 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CylinderComponent } from './cylinder.component';
describe('CylinderComponent', () => {
let component: CylinderComponent;
let fixture: ComponentFixture<CylinderComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [CylinderComponent]
})
.compileComponents();
fixture = TestBed.createComponent(CylinderComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,23 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { DashboardComponent } from './dashboard.component';
describe('DashboardComponent', () => {
let component: DashboardComponent;
let fixture: ComponentFixture<DashboardComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [DashboardComponent]
})
.compileComponents();
fixture = TestBed.createComponent(DashboardComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,23 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ArchiveComponent } from './archive.component';
describe('ArchiveComponent', () => {
let component: ArchiveComponent;
let fixture: ComponentFixture<ArchiveComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [ArchiveComponent]
})
.compileComponents();
fixture = TestBed.createComponent(ArchiveComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,23 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { DeleteKeyComponent } from './delete-key.component';
describe('DeleteKeyComponent', () => {
let component: DeleteKeyComponent;
let fixture: ComponentFixture<DeleteKeyComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [DeleteKeyComponent]
})
.compileComponents();
fixture = TestBed.createComponent(DeleteKeyComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,23 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { HandoverDialogComponent } from './handover-dialog.component';
describe('HandoverDialogComponent', () => {
let component: HandoverDialogComponent;
let fixture: ComponentFixture<HandoverDialogComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [HandoverDialogComponent]
})
.compileComponents();
fixture = TestBed.createComponent(HandoverDialogComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,23 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CreateKeyComponent } from './create.component';
describe('CreateComponent', () => {
let component: CreateKeyComponent;
let fixture: ComponentFixture<CreateKeyComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [CreateKeyComponent]
})
.compileComponents();
fixture = TestBed.createComponent(CreateKeyComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,23 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { KeysComponent } from './keys.component';
describe('KeysComponent', () => {
let component: KeysComponent;
let fixture: ComponentFixture<KeysComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [KeysComponent]
})
.compileComponents();
fixture = TestBed.createComponent(KeysComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,23 +1,54 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { SystemComponent } from './system.component'; import { SystemComponent } from './system.component';
import { ApiService } from '../../shared/api.service';
import { GridReadyEvent } from 'ag-grid-community';
import { of } from 'rxjs';
describe('SystemComponent', () => { describe('SystemcomponentComponent', () => {
let component: SystemComponent; let component: SystemComponent;
let fixture: ComponentFixture<SystemComponent>; let mockApiService: MockApiService;
beforeEach(async () => { beforeEach(async () => {
mockApiService = new MockApiService();
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
imports: [SystemComponent] imports: [SystemComponent],
}) providers: [
.compileComponents(); { provide: ApiService, useValue: mockApiService }
]
fixture = TestBed.createComponent(SystemComponent); }).compileComponents();
const fixture = TestBed.createComponent(SystemComponent);
component = fixture.componentInstance; component = fixture.componentInstance;
fixture.detectChanges(); fixture.detectChanges();
}); });
it('should create', () => { it('should create the SystemComponent', () => {
expect(component).toBeTruthy(); expect(component).toBeTruthy();
}); });
it('should initialize gridApi and gridColumnApi on gridReady and fill data', () => {
// Mock des GridReadyEvent
let mockData = [{ id: 1, name: 'Test' }];
mockApiService.getSystems.mockReturnValue(of(mockData));
const mockGridReadyEvent: GridReadyEvent = {
api: { setGridOption: jest.fn() },
columnApi: { someColumnApiMethod: jest.fn() },
type: 'gridReady',
} as any;
// Methode aufrufen
component.onGridReady(mockGridReadyEvent);
// Assertions
expect(component.gridApi).toBe(mockGridReadyEvent.api);
expect(mockApiService.getSystems).toHaveBeenCalled();
expect(component.gridApi.setGridOption).toHaveBeenCalled();
}); });
});
class MockApiService {
getSystems = jest.fn();
}

View File

@@ -1,23 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AgBaseComponentComponent } from './ag-base-component.component';
describe('AgBaseComponentComponent', () => {
let component: AgBaseComponentComponent;
let fixture: ComponentFixture<AgBaseComponentComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [AgBaseComponentComponent]
})
.compileComponents();
fixture = TestBed.createComponent(AgBaseComponentComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,23 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AgDeleteCylinderComponent } from './ag-delete-cylinder.component';
describe('AgDeleteCylinderComponent', () => {
let component: AgDeleteCylinderComponent;
let fixture: ComponentFixture<AgDeleteCylinderComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [AgDeleteCylinderComponent]
})
.compileComponents();
fixture = TestBed.createComponent(AgDeleteCylinderComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,23 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AgDeleteKeyComponent } from './ag-delete-key.component';
describe('AgDeleteKeyComponent', () => {
let component: AgDeleteKeyComponent;
let fixture: ComponentFixture<AgDeleteKeyComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [AgDeleteKeyComponent]
})
.compileComponents();
fixture = TestBed.createComponent(AgDeleteKeyComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,23 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AgLoadingComponent } from './ag-loading.component';
describe('AgLoadingComponent', () => {
let component: AgLoadingComponent;
let fixture: ComponentFixture<AgLoadingComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [AgLoadingComponent]
})
.compileComponents();
fixture = TestBed.createComponent(AgLoadingComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -3,9 +3,8 @@
"extends": "./tsconfig.json", "extends": "./tsconfig.json",
"compilerOptions": { "compilerOptions": {
"outDir": "./out-tsc/spec", "outDir": "./out-tsc/spec",
"types": [ "module": "CommonJS",
"jasmine" "types": ["jest"]
]
}, },
"include": [ "include": [
"src/**/*.spec.ts", "src/**/*.spec.ts",