-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add test case for constructors issue #509
- Loading branch information
Craig Roberts
committed
Dec 5, 2024
1 parent
035013a
commit bd89a0f
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
e2e/jest/nestjs/suites-jest-sociable-empty-constructor-assets.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Injectable } from "@nestjs/common"; | ||
|
||
export class TestDependService { | ||
public call(bool: boolean) { | ||
console.log('TestDependService', bool); | ||
} | ||
} | ||
|
||
export class TestSociableService { | ||
public return(): boolean { | ||
return true; | ||
} | ||
} | ||
|
||
@Injectable() | ||
export class TestService { | ||
constructor( | ||
private readonly testDependService: TestDependService, | ||
private readonly testSociableService: TestSociableService, | ||
) {} | ||
|
||
public test(): void { | ||
this.testDependService.call(this.testSociableService.return()); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
e2e/jest/nestjs/suites-jest-sociable-empty-constructor.e2e.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { TestBed } from "@suites/unit"; | ||
import { TestService, TestSociableService, TestDependService } from "./suites-jest-sociable-empty-constructor-assets"; | ||
|
||
describe('Test', () => { | ||
it('should expose sociable service', async () => { | ||
const { unit, unitRef } = await TestBed.sociable(TestService).expose(TestSociableService).compile(); | ||
|
||
const testDependService = unitRef.get(TestDependService); | ||
|
||
unit.test(); | ||
expect(testDependService.call).toHaveBeenCalledWith(true); | ||
}); | ||
}); |