2020-03-31 17:03:15 +00:00
|
|
|
import { module, test } from 'qunit';
|
|
|
|
import { setupRenderingTest } from 'ember-qunit';
|
|
|
|
import { render } from '@ember/test-helpers';
|
|
|
|
import { hbs } from 'ember-cli-htmlbars';
|
|
|
|
|
2022-09-15 08:43:17 +00:00
|
|
|
module('Integration | Helper | state-matches', function (hooks) {
|
2020-03-31 17:03:15 +00:00
|
|
|
setupRenderingTest(hooks);
|
|
|
|
|
|
|
|
// Replace this with your real tests.
|
2022-09-15 08:43:17 +00:00
|
|
|
test('it returns true/false when the state or state in an array matches', async function (assert) {
|
2020-03-31 17:03:15 +00:00
|
|
|
this.set('state', {
|
2022-09-15 08:43:17 +00:00
|
|
|
matches: function (id) {
|
2020-03-31 17:03:15 +00:00
|
|
|
return id === 'idle';
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
await render(hbs`{{state-matches state 'idle'}}`);
|
|
|
|
assert.equal(this.element.textContent.trim(), 'true');
|
|
|
|
|
|
|
|
await render(hbs`{{state-matches state 'loading'}}`);
|
|
|
|
assert.equal(this.element.textContent.trim(), 'false');
|
|
|
|
|
|
|
|
await render(hbs`{{state-matches state (array 'idle' 'loading')}}`);
|
|
|
|
assert.equal(this.element.textContent.trim(), 'true');
|
|
|
|
|
|
|
|
await render(hbs`{{state-matches state (array 'loading' 'idle')}}`);
|
|
|
|
assert.equal(this.element.textContent.trim(), 'true');
|
|
|
|
|
|
|
|
await render(hbs`{{state-matches state (array 'loading' 'deleting')}}`);
|
|
|
|
assert.equal(this.element.textContent.trim(), 'false');
|
|
|
|
});
|
|
|
|
});
|