2023-03-14 13:18:55 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*/
|
|
|
|
|
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 | Component | state', function (hooks) {
|
2020-03-31 17:03:15 +00:00
|
|
|
setupRenderingTest(hooks);
|
|
|
|
|
2022-09-15 08:43:17 +00:00
|
|
|
test('it renders', async function (assert) {
|
2020-03-31 17:03:15 +00:00
|
|
|
// Set any properties with this.set('myProperty', 'value');
|
|
|
|
// Handle any actions with this.set('myAction', function(val) { ... });
|
|
|
|
|
|
|
|
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 @state={{state}} @matches="idle">
|
|
|
|
Currently Idle
|
|
|
|
</State>
|
|
|
|
`);
|
|
|
|
|
|
|
|
assert.equal(this.element.textContent.trim(), 'Currently Idle');
|
|
|
|
await render(hbs`
|
|
|
|
<State @state={{state}} @matches="loading">
|
|
|
|
Currently Idle
|
|
|
|
</State>
|
|
|
|
`);
|
|
|
|
|
|
|
|
assert.equal(this.element.textContent.trim(), '');
|
|
|
|
});
|
|
|
|
});
|