-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(): support for async configuration in load
- Loading branch information
1 parent
ee9dabd
commit ff13342
Showing
4 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { INestApplication } from '@nestjs/common'; | ||
import { Test } from '@nestjs/testing'; | ||
import { AppModule } from '../src/app.module'; | ||
|
||
describe('Async Files', () => { | ||
let app: INestApplication; | ||
|
||
beforeEach(async () => { | ||
const module = await Test.createTestingModule({ | ||
imports: [AppModule.withLoadedAsyncConfigurations()], | ||
}).compile(); | ||
|
||
app = module.createNestApplication(); | ||
await app.init(); | ||
}); | ||
|
||
it(`should return loaded configuration`, () => { | ||
const host = app.get(AppModule).getDatabaseHost(); | ||
expect(host).toEqual('host'); | ||
}); | ||
|
||
it(`should return loaded configuration (injected through constructor)`, () => { | ||
const config = app.get(AppModule).getDatabaseConfig(); | ||
expect(config.host).toEqual('host'); | ||
expect(config.port).toEqual(4000); | ||
}); | ||
|
||
afterEach(async () => { | ||
await app.close(); | ||
}); | ||
}); |
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