Skip to content

Commit

Permalink
add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ikenox committed Oct 17, 2023
1 parent fceb6a1 commit 3167881
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,32 @@ test('cache', ({ expect }) => {
expect(container1.num).not.toBe(container2.num);
});

test("container instantiation processses doen't evaluate a passed another container dependency instances", ({
expect,
}) => {
describe('lazy evaluation', () => {
const container = scope()
.provide({
dep: () => {
depA: () => {
throw new Error('this code should never be called');
},
depB: () => 123,
})
.instanciate({});

expect(() => {
scope().static(container).instanciate({});
}).not.toThrowError();
test('dependencies are not evaluated when merged by `static` method', ({
expect,
}) => {
expect(() => {
scope().static(container).instanciate({});
}).not.toThrowError();
});

test('unspecified variable is not evaluated on object destruction', ({
expect,
}) => {
expect(() => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { depB } = container;
}).not.toThrowError();
});
});

describe('type-level tests', () => {
Expand Down

0 comments on commit 3167881

Please sign in to comment.