Skip to content

Commit

Permalink
add link-to case
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelcobain committed Jan 9, 2024
1 parent e923497 commit cbce839
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion addon/href-to.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default class {
let id = this.target.id;
if (id) {
let componentInstance = this.applicationInstance.lookup('-view-registry:main')[id];
isLinkComponent = componentInstance && componentInstance.constructor.superclass.toString() === '@ember/routing/link-component';
isLinkComponent = componentInstance && [componentInstance.constructor.toString(), componentInstance.constructor.superclass.toString()].includes('@ember/routing/link-component');
}

return !isLinkComponent;
Expand Down
11 changes: 11 additions & 0 deletions tests/integration/href-to-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module('Integration | HrefTo', function(hooks) {
this.owner.lookup('router:main').setupRouter();
})


test(`#isNotLinkComponent should be true if the event target is not an instance of Em.LinkComponent`, async function(assert) {
await render(hbs`{{not-a-link class='not-a-link'}}`);

Expand All @@ -25,6 +26,16 @@ module('Integration | HrefTo', function(hooks) {
assert.ok(hrefTo.isNotLinkComponent());
});

test(`#isNotLinkComponent should be false if the event target is a {{link-to}}`, async function(assert) {
await render(hbs`{{link-to 'about' 'about' class='a-link'}}`);

let event = leftClickEvent();
event.target = find('.a-link');

let hrefTo = new HrefTo(this.owner, event);
assert.notOk(hrefTo.isNotLinkComponent());
});

test(`#isNotLinkComponent should be false if the event target is an instance of Em.LinkComponent`, async function(assert) {
await render(hbs`{{a-link 'about' 'about' class='a-link'}}`);

Expand Down

0 comments on commit cbce839

Please sign in to comment.