Skip to content

Commit

Permalink
Propagate referrer rootName to lookup namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
mixonic committed Nov 24, 2017
1 parent 4317bd7 commit 4dffbd6
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ export default class Resolver implements IResolver {

// Look in the definitive collection for the associated type
s.collection = this._definitiveCollection(r.type);
if (!s.namespace) {
s.namespace = r.rootName;
}
assert(`'${r.type}' does not have a definitive collection`, s.collection);
}
}
Expand All @@ -89,11 +92,13 @@ export default class Resolver implements IResolver {
// Then look for an addon with a matching `rootName`
let addonDef;
if (s.namespace) {
// Seems bad that addonDef is basically ignored?
addonDef = this.config.addons && this.config.addons[s.namespace];
s.rootName = s.namespace;
s.namespace = undefined;

} else {
// Seems bad that addonDef is basically ignored?
addonDef = this.config.addons && this.config.addons[s.name];
s.rootName = s.name;
s.name = 'main';
Expand Down
33 changes: 33 additions & 0 deletions test/resolution-order-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,3 +404,36 @@ test('Identifies `component:my-input/stylized` as an export from an addon', func
let resolver = new Resolver(config, registry);
assert.strictEqual(resolver.identify('component:my-input/stylized'), 'component:/my-input/components/stylized');
});

test('Identifies `service:i18n` with referrer `service:/other-namespace-addon/` as an export from an addon', function(assert) {
let config: ResolverConfiguration = {
app: {
name: 'example-app'
},
addons: {
'other-namespace-addon': {
name: 'other-namespace-name',
rootName: 'other-namespace-rootName'
}
},
types: {
service: {
definitiveCollection: 'services'
},
},
collections: {
services: {
types: ['service'],
defaultType: 'service'
}
}
};
let registry = new BasicRegistry({
'service:/other-namespace-addon/services/i18n': 'a'
});
let resolver = new Resolver(config, registry);
assert.strictEqual(
resolver.identify('service:i18n', 'service:/other-namespace-addon/'),
'service:/other-namespace-addon/services/i18n'
);
});
8 changes: 8 additions & 0 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"rules": {
"quotemark": [
true,
"single"
]
}
}

0 comments on commit 4dffbd6

Please sign in to comment.