Skip to content

Commit

Permalink
♻️ Running Codemods
Browse files Browse the repository at this point in the history
  • Loading branch information
nadnoslen committed Apr 18, 2022
1 parent 280427c commit 14ed668
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion tests/dummy/app/templates/another-page.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<h1>Opened In The Same Tab!</h1>
<p>
See how the first link opened to this page in the same tab? Perfect.
{{#link-to "index"}}Now go back and try the other link from the same example.{{/link-to}}
<LinkTo @route="index">Now go back and try the other link from the same example.</LinkTo>
Notice that it will open in another tab because its origin isn't from ember-cli-marked-down.cybertooth.io.
</p>
</div>
Expand Down
4 changes: 2 additions & 2 deletions tests/dummy/app/templates/application.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
{{#link-to "index" class="navbar-brand"}}
<LinkTo @route="index" class="navbar-brand">
ember-cli-marked-down
{{/link-to}}
</LinkTo>
</div>

{{! Collect the nav links, forms, and other content for toggling }}
Expand Down
8 changes: 4 additions & 4 deletions tests/dummy/app/templates/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ If you did get an alert, please let us know!!!"

<div class="row">
<div class="col-sm-4 form-group">
{{#set-links-target}}
<SetLinksTarget>
{{marked-down
"This link will open in a new tab (`_blank`) [https://github.com/cybertoothca/
ember-cli-marked-down](https://github.com/cybertoothca/ember-cli-marked-down)"
}}
{{/set-links-target}}
</SetLinksTarget>
</div>
<div class="col-sm-8">
{{! @formatter:off }}
Expand Down Expand Up @@ -181,13 +181,13 @@ If you did get an alert, please let us know!!!"

<div class="row">
<div class="col-sm-4 form-group">
{{#set-links-target excludeSelfLinks?=true}}
<SetLinksTarget @excludeSelfLinks?={{true}}>
{{marked-down
"This link will open in the same tab its origin is the same as the current page you're on: [http://ember-cli-marked-down.cybertooth.io/another-page](http://ember-cli-marked-down.cybertooth.io/another-page)
This link continues to open in another tab: [https://github.com/cybertoothca/ember-cli-marked-down](https://github.com/cybertoothca/ember-cli-marked-down)"
}}
{{/set-links-target}}
</SetLinksTarget>
</div>
<div class="col-sm-8">
{{! @formatter:off }}
Expand Down
28 changes: 14 additions & 14 deletions tests/integration/components/set-links-target-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,38 @@ module('Integration | Component | set links target', function (hooks) {

test('when the yield does not include any links', async function (assert) {
await render(hbs`
{{#set-links-target}}
<SetLinksTarget>
{{marked-down "### Heading 3"}}
{{/set-links-target}}
</SetLinksTarget>
`);
assert.equal(find('.set-links-target').innerHTML.trim(), '<h3 id="heading3">Heading 3</h3>');
});

test('when the yield link(s) have target set to _top', async function (assert) {
await render(hbs`
{{#set-links-target targetValue="_top"}}
<SetLinksTarget @targetValue="_top">
{{marked-down "[Some Link](http://github.com)"}}
{{/set-links-target}}
</SetLinksTarget>
`);
assert.dom('a').hasAttribute('target', '_top');
assert.dom('a').hasNoAttribute('rel');
});

test('when the yields link(s) do not have a target value, _blank is added', async function (assert) {
await render(hbs`
{{#set-links-target}}
<SetLinksTarget>
{{marked-down "[Some Link](http://github.com)"}}
{{/set-links-target}}
</SetLinksTarget>
`);
assert.dom('a').hasAttribute('target', '_blank');
assert.dom('a').hasAttribute('rel', 'noopener noreferrer');
});

test('when excludeSelfLinks is false, the target is applied to local links', async function (assert) {
await render(hbs`
{{#set-links-target excludeSelfLinks?=false}}
<SetLinksTarget @excludeSelfLinks?={{false}}>
{{marked-down "[Some Link](http://localhost:7357/some/path)"}}
{{/set-links-target}}
</SetLinksTarget>
`);
assert.dom('a').hasAttribute('target', '_blank');
assert.dom('a').hasAttribute('rel', 'noopener noreferrer');
Expand All @@ -53,9 +53,9 @@ module('Integration | Component | set links target', function (hooks) {
test('when excludeSelfLinks defaults to true, the target is not applied to such links', async function (assert) {
this.set('origin', window.document.location.origin);
await render(hbs`
{{#set-links-target}}
<SetLinksTarget>
{{marked-down (concat "[Some Link](" origin "/some/path)")}}
{{/set-links-target}}
</SetLinksTarget>
`);
assert.dom('a').hasNoAttribute('target');
assert.dom('a').hasNoAttribute('rel');
Expand All @@ -64,9 +64,9 @@ module('Integration | Component | set links target', function (hooks) {
test('when excludeSelfLinks is explicitly set to true, the target is not applied to such links', async function (assert) {
this.set('origin', window.document.location.origin);
await render(hbs`
{{#set-links-target excludeSelfLinks?=true}}
<SetLinksTarget @excludeSelfLinks?={{true}}>
{{marked-down (concat "[Some Link](" origin "/some/path)")}}
{{/set-links-target}}
</SetLinksTarget>
`);
assert.dom('a').hasNoAttribute('target');
assert.dom('a').hasNoAttribute('rel');
Expand All @@ -75,9 +75,9 @@ module('Integration | Component | set links target', function (hooks) {
test('when the target is set for one of several links', async function (assert) {
this.set('origin', window.document.location.origin);
await render(hbs`
{{#set-links-target}}
<SetLinksTarget>
{{marked-down (concat "[Some Link That Opens In Same Tab](" origin "/some/path) [Another Link That Will Open In A New Tab](https://github.com/cybertoothca/ember-cli-marked-down)")}}
{{/set-links-target}}
</SetLinksTarget>
`);
assert.dom('a').hasNoAttribute('target');
assert.dom('a').hasNoAttribute('rel');
Expand Down

0 comments on commit 14ed668

Please sign in to comment.