Skip to content

Commit

Permalink
Try this
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Aug 26, 2024
1 parent 081016d commit 4ea1e26
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
11 changes: 8 additions & 3 deletions addon/src/settled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,19 +190,24 @@ if (loader.registry['ember-testing/test/waiters']) {
function checkWaiters() {
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
type Waiter = [any, Function];
const EmberTest = Ember.Test as any as { waiters: Array<Waiter> };
const EmberTest = Ember.Test as any as {
waiters: Array<Waiter>;
checkWaiters: () => boolean;
};

if (_internalCheckWaiters) {
return _internalCheckWaiters();
} else if (EmberTest.waiters) {
}

if (EmberTest.waiters) {
if (
EmberTest.waiters.some(([context, callback]) => !callback.call(context))
) {
return true;
}
}

return false;
return EmberTest.checkWaiters();
}

export interface SettledState {
Expand Down
3 changes: 0 additions & 3 deletions test-app/ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ module.exports = function (defaults) {
'{{inner-comp}}': { safeToIgnore: true },
'{{template-only}}': { safeToIgnore: true },
},
helpers: {
'{{jax}}': { safeToIgnore: true },
},
},
],
});
Expand Down
11 changes: 8 additions & 3 deletions test-app/tests/unit/setup-rendering-context-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ module('setupRenderingContext', function (hooks) {
'component:js-only': Component.extend({
classNames: ['js-only'],
}),
'helper:jax': helper(([name]) => `${name}-jax`),
'component:outer-comp': setComponentTemplate(
hbs`outer{{inner-comp}}outer`,
class extends Component {}
Expand Down Expand Up @@ -287,15 +286,21 @@ module('setupRenderingContext', function (hooks) {
});

test('can invoke helper', async function (assert) {
await render(hbs`{{jax "max"}}`);
this.setProperties({
jax: helper(([name]) => `${name}-jax`),
});
await render(hbs`{{this.jax "max"}}`);

assert.equal(this.element.textContent, 'max-jax');
});

test('can pass arguments to helper from context', async function (assert) {
this.setProperties({
jax: helper(([name]) => `${name}-jax`),
});
this.set('name', 'james');

await render(hbs`{{jax this.name}}`);
await render(hbs`{{this.jax this.name}}`);

assert.equal(this.element.textContent, 'james-jax');
});
Expand Down

0 comments on commit 4ea1e26

Please sign in to comment.