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

Move ci.yml to correct folder #64

Merged
merged 4 commits into from
Feb 12, 2024
Merged
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
File renamed without changes.
2 changes: 1 addition & 1 deletion ember-set-helper/src/template-registry.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type set from './helpers/set';

export default interface Registry {
set: typeof set
set: typeof set;
}
1 change: 1 addition & 0 deletions test-app/.eslintignore
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
/coverage/
!.*
.*/
*.gts

# ember-try
/.node_modules.ember-try/
5 changes: 3 additions & 2 deletions test-app/app/models/user.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable ember/no-classic-classes */
import EmberObject from '@ember/object';

export default EmberObject.extend({
name: ''
})
name: '',
});
76 changes: 47 additions & 29 deletions test-app/tests/integration/helpers/set-test.js
Original file line number Diff line number Diff line change
@@ -4,10 +4,10 @@ import { render, find, click, fillIn } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
import User from 'test-app/models/user';

module('Integration | Helper | set', function(hooks) {
module('Integration | Helper | set', function (hooks) {
setupRenderingTest(hooks);

test('it works', async function(assert) {
test('it works', async function (assert) {
await render(hbs`
<span data-test-greeting>{{this.greeting}}</span>

@@ -16,14 +16,17 @@ module('Integration | Helper | set', function(hooks) {
</button>
`);

assert.equal(find('[data-test-greeting]').textContent.trim(), '');
assert.strictEqual(find('[data-test-greeting]').textContent.trim(), '');

await click('button');

assert.equal(find('[data-test-greeting]').textContent.trim(), 'Hello!');
assert.strictEqual(
find('[data-test-greeting]').textContent.trim(),
'Hello!',
);
});

test('it works on local paths', async function(assert) {
test('it works on local paths', async function (assert) {
this.person = {};

await render(hbs`
@@ -36,14 +39,14 @@ module('Integration | Helper | set', function(hooks) {
{{/let}}
`);

assert.equal(find('[data-test-greeting]').textContent.trim(), '');
assert.strictEqual(find('[data-test-greeting]').textContent.trim(), '');

await click('button');

assert.equal(find('[data-test-greeting]').textContent.trim(), 'Liz');
assert.strictEqual(find('[data-test-greeting]').textContent.trim(), 'Liz');
});

test('it works with a dynamic path', async function(assert) {
test('it works with a dynamic path', async function (assert) {
this.set('path', 'greeting1');

await render(hbs`
@@ -55,19 +58,25 @@ module('Integration | Helper | set', function(hooks) {
</button>
`);

assert.equal(find('[data-test-greeting1]').textContent.trim(), '');
assert.equal(find('[data-test-greeting2]').textContent.trim(), '');
assert.strictEqual(find('[data-test-greeting1]').textContent.trim(), '');
assert.strictEqual(find('[data-test-greeting2]').textContent.trim(), '');

await click('button');
assert.equal(find('[data-test-greeting1]').textContent.trim(), 'Hello!');
assert.strictEqual(
find('[data-test-greeting1]').textContent.trim(),
'Hello!',
);

this.set('path', 'greeting2');
await click('button');

assert.equal(find('[data-test-greeting2]').textContent.trim(), 'Hello!');
assert.strictEqual(
find('[data-test-greeting2]').textContent.trim(),
'Hello!',
);
});

test('it works with a dynamic path on a nested object', async function(assert) {
test('it works with a dynamic path on a nested object', async function (assert) {
this.set('path', 'greeting1');
this.set('obj', {});

@@ -80,20 +89,26 @@ module('Integration | Helper | set', function(hooks) {
</button>
`);

assert.equal(find('[data-test-greeting1]').textContent.trim(), '');
assert.equal(find('[data-test-greeting2]').textContent.trim(), '');
assert.strictEqual(find('[data-test-greeting1]').textContent.trim(), '');
assert.strictEqual(find('[data-test-greeting2]').textContent.trim(), '');

await click('button');

assert.equal(find('[data-test-greeting1]').textContent.trim(), 'Hello!');
assert.strictEqual(
find('[data-test-greeting1]').textContent.trim(),
'Hello!',
);

this.set('path', 'greeting2');
await click('button');

assert.equal(find('[data-test-greeting2]').textContent.trim(), 'Hello!');
assert.strictEqual(
find('[data-test-greeting2]').textContent.trim(),
'Hello!',
);
});

test('it works with a dynamic path on a component argument', async function(assert) {
test('it works with a dynamic path on a component argument', async function (assert) {
this.set('path', 'greeting1');
this.set('obj', {});

@@ -103,29 +118,29 @@ module('Integration | Helper | set', function(hooks) {

await click('button');

assert.equal(this.obj.greeting1, 42);
assert.strictEqual(this.obj.greeting1, 42);

this.set('path', 'greeting2');
await click('button');

assert.equal(this.obj.greeting2, 42);
assert.strictEqual(this.obj.greeting2, 42);
});

test('it works without a value', async function(assert) {
test('it works without a value', async function (assert) {
await render(hbs`
<span data-test-count>{{this.count}}</span>
<Counter @onUpdate={{set this "count"}} />
`);

assert.equal(find('[data-test-count]').textContent.trim(), '');
assert.strictEqual(find('[data-test-count]').textContent.trim(), '');

await click('button');
await click('button');

assert.equal(find('[data-test-count]').textContent.trim(), '2');
assert.strictEqual(find('[data-test-count]').textContent.trim(), '2');
});

test('it works without a value on an object', async function(assert) {
test('it works without a value on an object', async function (assert) {
this.set('user', User.create({ name: 'Alice' }));
await render(hbs`
<span data-test-name>{{this.user.name}}</span>
@@ -139,17 +154,20 @@ module('Integration | Helper | set', function(hooks) {
assert.dom('[data-test-name]').hasText('Bob');
});

test('can pick a value using {{pick}} from ember-composable-helpers', async function(assert) {
test('can pick a value using {{pick}} from ember-composable-helpers', async function (assert) {
await render(hbs`
<span data-test-greeting>{{this.greeting}}</span>

<input {{on "input" (pick "target.value" (set this "greeting"))}}>
<input aria-label={{this.greeting}} {{on "input" (pick "target.value" (set this "greeting"))}}>
`);

assert.equal(find('[data-test-greeting]').textContent.trim(), '');
assert.strictEqual(find('[data-test-greeting]').textContent.trim(), '');

await fillIn('input', 'Hello!');

assert.equal(find('[data-test-greeting]').textContent.trim(), 'Hello!');
assert.strictEqual(
find('[data-test-greeting]').textContent.trim(),
'Hello!',
);
});
});
});
Loading