Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix resolver order #433

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion test/unit/metal/container-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,24 @@ test('availableForType() returns all registered instances of a type', async (t)
t.deepEqual(container.availableForType('foo'), ['a', 'b', 'c', 'd']);
});

test('the resolver order should not be changed by lookup methods', async (t) => {
const container: Container = t.context.subject();

const loaderMock = (name : string) => ({
retrieve: () => name,
loadRelative: () => name,
factories: new Map(),
}) as any;

container.loadBundleScope(loaderMock('l1'));
container.loadBundleScope(loaderMock('l2'));

t.deepEqual(container.lookup('foo:l1', { raw: true }), 'l1');
container.availableForType('foo');
t.deepEqual(container.lookup('foo:l1', { raw: true }), 'l1');
t.deepEqual(container.lookup('foo:l1', { raw: true }), 'l1');
});

test('falls back to `fallbacks` specifiers if original specifier is not found', async (t) => {
let container: Container = t.context.subject();
container.setOption('foo', 'fallbacks', [ 'foo:application' ]);
Expand All @@ -105,4 +123,4 @@ test('the container adds a resolver for each loader bundle scope, in breadth-fir

let resolvers = <Resolver[]>(<any>container).resolvers;
t.deepEqual(resolvers.map((r) => r.name), [ 'top', 'quux', 'foo', 'bar' ]);
});
});