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 29b03e5
Showing
6 changed files
with
44 additions
and
3 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
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,16 @@ | ||
import { expect } from 'chai'; | ||
import { Test } from '@nestjs/testing'; | ||
import { CircularModule } from '../src/circular-structure-dynamic-module/circular.module'; | ||
import { InputService } from '../src/circular-structure-dynamic-module/input.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); | ||
|
||
expect(inputService).to.be.instanceof(InputService); | ||
}); | ||
}); |
16 changes: 16 additions & 0 deletions
16
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,16 @@ | ||
import { DynamicModule } from '@nestjs/common'; | ||
import { InputService } from './input.service'; | ||
|
||
export class CircularModule { | ||
static forRoot(): DynamicModule { | ||
const a = { | ||
module: CircularModule, | ||
providers: [ | ||
InputService, | ||
], | ||
b: null, | ||
}; | ||
a.b = a; | ||
return a; | ||
} | ||
} |
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 { | ||
} |
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
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