Skip to content

Commit bac300e

Browse files
committed
test: atomic deepObject test on service rather than integration with app component
1 parent d553d5d commit bac300e

5 files changed

Lines changed: 26 additions & 31 deletions

File tree

samples/client/petstore/typescript-angular-v19/builds/deep-object/.openapi-generator/FILES

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.gitignore
2-
.openapi-generator-ignore
32
README.md
43
api.base.service.ts
54
api.module.ts
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.13.0-SNAPSHOT
1+
7.14.0-SNAPSHOT
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { TestBed } from '@angular/core/testing'
2+
import { provideHttpClient } from '@angular/common/http'
3+
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing'
4+
import { DefaultService } from '@swagger/typescript-angular-deepobject'
5+
6+
describe('DeepObject Query Param testing', () => {
7+
beforeEach(async () => {
8+
await TestBed.configureTestingModule({
9+
providers: [
10+
provideHttpClient(),
11+
provideHttpClientTesting(),
12+
DefaultService,
13+
],
14+
}).compileComponents();
15+
});
16+
17+
it('should generate the deepObject query with the correct parameters', async () => {
18+
const httpTesting = TestBed.inject(HttpTestingController);
19+
const carService = TestBed.inject(DefaultService)
20+
carService.getCars({ make: 'bmw', model: '319' }).subscribe()
21+
const req = httpTesting.expectOne('http://localhost/car?filter%5Bmake%5D=bmw&filter%5Bmodel%5D=319')
22+
expect(req.request.method).toEqual('GET')
23+
});
24+
});

samples/client/petstore/typescript-angular-v19/src/app/app.component.spec.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,29 +40,4 @@ describe('AppComponent', () => {
4040
fixture.detectChanges();
4141
expect(fixture.componentInstance.pets![0]).toEqual(pet)
4242
});
43-
});
44-
45-
46-
47-
48-
describe('DeepObject Query Param testing', () => {
49-
beforeEach(async () => {
50-
await TestBed.configureTestingModule({
51-
imports: [AppComponent],
52-
providers: [
53-
provideHttpClient(),
54-
provideHttpClientTesting(),
55-
],
56-
}).compileComponents();
57-
});
58-
59-
it('should generate the deepObject query with the correct parameters', async () => {
60-
const httpTesting = TestBed.inject(HttpTestingController);
61-
62-
const fixture = TestBed.createComponent(AppComponent);
63-
const app = fixture.componentInstance;
64-
await fixture.whenRenderingDone();
65-
httpTesting.expectOne('http://localhost/car?filter%5Bmake%5D=bmw&filter%5Bmodel%5D=319');
66-
expect(app).toBeTruthy();
67-
});
6843
});
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {Component} from '@angular/core';
22
import {type Pet, PetService} from '@swagger/typescript-angular-petstore'
33
import {JsonPipe} from '@angular/common';
4-
import { Car, DefaultService } from '@swagger/typescript-angular-deepobject';
54

65
@Component({
76
selector: 'app-root',
@@ -12,10 +11,8 @@ import { Car, DefaultService } from '@swagger/typescript-angular-deepobject';
1211
export class AppComponent {
1312
title = 'typescript-angular-v19-unit-tests';
1413
pets: Pet[] | undefined;
15-
cars: Car[] = [];
1614

17-
constructor(petService: PetService, defaultService: DefaultService) {
15+
constructor(petService: PetService) {
1816
petService.findPetsByStatus(['available']).subscribe(pets => this.pets = pets);
19-
defaultService.getCars({ make: 'bmw', model: '319' }).subscribe(result => this.cars = result);
2017
}
2118
}

0 commit comments

Comments
 (0)