website refactor
This commit is contained in:
@@ -41,16 +41,16 @@ export function createContainer(): Container {
|
||||
/**
|
||||
* Creates a container for testing with mock overrides
|
||||
*/
|
||||
export function createTestContainer(overrides: Map<symbol, any> = new Map()): Container {
|
||||
export async function createTestContainer(overrides: Map<symbol, any> = new Map()): Promise<Container> {
|
||||
const container = createContainer();
|
||||
|
||||
// Apply mock overrides using rebind
|
||||
Array.from(overrides.entries()).forEach(([token, mockInstance]) => {
|
||||
container.rebind(token).then(bind => bind.toConstantValue(mockInstance));
|
||||
const promises = Array.from(overrides.entries()).map(([token, mockInstance]) => {
|
||||
return container.rebind(token).then(bind => bind.toConstantValue(mockInstance));
|
||||
});
|
||||
|
||||
// Return container immediately, mocks will be available after promises resolve
|
||||
// For synchronous testing, users can bind directly before loading modules
|
||||
await Promise.all(promises);
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user