forked from nestjs/nest
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix(core): Allow circular structures for dynamic module nestjs#678
- Loading branch information
1 parent
65bb7e7
commit bcab737
Showing
7 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
integration/injector/e2e/circular-structure-dynamic-modules.spec.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,20 @@ | ||
import { expect } from 'chai'; | ||
import { Test, TestingModuleBuilder } from '@nestjs/testing'; | ||
import { INestApplication } from '@nestjs/common'; | ||
import { CircularModule } from '../src/circular-structure-dynamic-module/circular.module'; | ||
import { InputService } from '../src/circular-structure-dynamic-module/input.service'; | ||
import { Input2Service } from '../src/circular-structure-dynamic-module/input2.service'; | ||
|
||
describe('Circular structure for dynamic modules', () => { | ||
it('should resolve circular structure with dynamic modules', async () => { | ||
const builder = Test.createTestingModule({ | ||
imports: [CircularModule.forRoot()], | ||
}); | ||
const testingModule = await builder.compile(); | ||
const inputService = testingModule.get<InputService>(InputService); | ||
const input2Service = testingModule.get<Input2Service>(Input2Service); | ||
|
||
expect(inputService).to.be.instanceof(InputService); | ||
expect(input2Service).to.be.instanceof(Input2Service); | ||
}); | ||
}); |
17 changes: 17 additions & 0 deletions
17
integration/injector/src/circular-structure-dynamic-module/circular.module.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,17 @@ | ||
import { Module, DynamicModule } from '@nestjs/common'; | ||
import { Circular2Module } from './circular2.module'; | ||
import { InputService } from './input.service'; | ||
|
||
export class CircularModule { | ||
static forRoot(): DynamicModule { | ||
return { | ||
module: CircularModule, | ||
imports: [ | ||
Circular2Module, | ||
], | ||
providers: [ | ||
InputService, | ||
], | ||
}; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
integration/injector/src/circular-structure-dynamic-module/circular2.module.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,7 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { CircularModule } from './circular.module'; | ||
|
||
@Module({ | ||
imports: [CircularModule], | ||
}) | ||
export class Circular2Module {} |
5 changes: 5 additions & 0 deletions
5
integration/injector/src/circular-structure-dynamic-module/input.service.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,5 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
|
||
@Injectable() | ||
export class InputService { | ||
} |
5 changes: 5 additions & 0 deletions
5
integration/injector/src/circular-structure-dynamic-module/input2.service.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,5 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
|
||
@Injectable() | ||
export class Input2Service { | ||
} |
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
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