Skip to content

Commit

Permalink
feat(linked-item): yield active state of item component
Browse files Browse the repository at this point in the history
  • Loading branch information
anehx committed Jan 24, 2022
1 parent df8e06c commit b28d06a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion addon/components/-private/linked-list-item.hbs
Expand Up @@ -5,5 +5,5 @@
}}
...attributes
>
<a href={{@href}} {{on "click" this.navigate}}>{{yield}}</a>
<a href={{@href}} {{on "click" this.navigate}}>{{yield this.active}}</a>
</li>
18 changes: 18 additions & 0 deletions tests/integration/components/uk-subnav/item-test.js
Expand Up @@ -55,4 +55,22 @@ module("Integration | Component | uk subnav/item", function (hooks) {

assert.verifySteps(["navigate"]);
});

test("yields the active state", async function (assert) {
assert.expect(2);

this.owner.lookup("service:router").isActive = () => false;
await render(
hbs`<UkSubnav::Item @href="/" as |active|>{{unless active "not "}}active</UkSubnav::Item>`
);

assert.dom("a").hasText("not active");

this.owner.lookup("service:router").isActive = () => true;
await render(
hbs`<UkSubnav::Item @href="/" as |active|>{{unless active "not "}}active</UkSubav::Item>`
);

assert.dom("a").hasText("active");
});
});
18 changes: 18 additions & 0 deletions tests/integration/components/uk-tab/item-test.js
Expand Up @@ -52,4 +52,22 @@ module("Integration | Component | uk tab/item", function (hooks) {

assert.verifySteps(["navigate"]);
});

test("yields the active state", async function (assert) {
assert.expect(2);

this.owner.lookup("service:router").isActive = () => false;
await render(
hbs`<UkTab::Item @href="/" as |active|>{{unless active "not "}}active</UkTab::Item>`
);

assert.dom("a").hasText("not active");

this.owner.lookup("service:router").isActive = () => true;
await render(
hbs`<UkTab::Item @href="/" as |active|>{{unless active "not "}}active</UkTab::Item>`
);

assert.dom("a").hasText("active");
});
});

0 comments on commit b28d06a

Please sign in to comment.