2018-11-14 00:55:07 +00:00
|
|
|
import { module, test } from 'qunit';
|
|
|
|
import { setupRenderingTest } from 'ember-qunit';
|
|
|
|
import { render } from '@ember/test-helpers';
|
|
|
|
import hbs from 'htmlbars-inline-precompile';
|
|
|
|
import { addMinutes } from 'date-fns';
|
|
|
|
|
2021-12-17 03:44:29 +00:00
|
|
|
module('Integration | Component | token-expire-warning', function (hooks) {
|
2018-11-14 00:55:07 +00:00
|
|
|
setupRenderingTest(hooks);
|
|
|
|
|
2021-12-17 03:44:29 +00:00
|
|
|
test('it renders a warning when the token is expired', async function (assert) {
|
2018-11-14 00:55:07 +00:00
|
|
|
const expirationDate = Date.now();
|
|
|
|
this.set('expirationDate', expirationDate);
|
|
|
|
|
|
|
|
await render(hbs`<TokenExpireWarning @expirationDate={{expirationDate}}/>`);
|
|
|
|
|
|
|
|
assert.dom().includesText('Your auth token expired on');
|
|
|
|
});
|
|
|
|
|
2021-12-17 03:44:29 +00:00
|
|
|
test('it does not render a warning when the token is not expired', async function (assert) {
|
2018-11-14 00:55:07 +00:00
|
|
|
const expirationDate = addMinutes(Date.now(), 30);
|
|
|
|
this.set('expirationDate', expirationDate);
|
|
|
|
|
|
|
|
await render(hbs`
|
|
|
|
<TokenExpireWarning @expirationDate={{expirationDate}}>
|
|
|
|
<p>Do not worry, your token has not expired.</p>
|
|
|
|
</TokenExpireWarning>
|
|
|
|
`);
|
|
|
|
|
|
|
|
assert.dom().doesNotIncludeText('Your auth token expired on');
|
|
|
|
assert.dom().includesText('Do not worry');
|
|
|
|
});
|
|
|
|
});
|