Skip to content

Commit

Permalink
test: Added a test for resolving a value by an optional token
Browse files Browse the repository at this point in the history
  • Loading branch information
mnasyrov committed Aug 7, 2023
1 parent e3e836e commit a855014
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/ditox/src/ditox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,16 @@ describe('Container', () => {
expect(container.resolve(NUMBER)).toBe(1);
});

it('should resolve a value from the parent container by OptionalToken', () => {
const OPTIONAL_TOKEN = optional(token(), 0);

const parent = createContainer();
parent.bindValue(OPTIONAL_TOKEN, 1);

const container = createContainer(parent);
expect(container.resolve(OPTIONAL_TOKEN)).toBe(1);
});

it('should throw ResolverError in case the parent container does not provide a value', () => {
const parent = createContainer();
const container = createContainer(parent);
Expand Down

0 comments on commit a855014

Please sign in to comment.