Skip to content

Commit

Permalink
test: Add test case for constructors issue #509
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Roberts committed Dec 5, 2024
1 parent 035013a commit bd89a0f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
25 changes: 25 additions & 0 deletions e2e/jest/nestjs/suites-jest-sociable-empty-constructor-assets.ts
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 e2e/jest/nestjs/suites-jest-sociable-empty-constructor.e2e.test.ts
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);
});
});

0 comments on commit bd89a0f

Please sign in to comment.