open-nomad/ui/tests/integration/components/page-layout-test.js

69 lines
2 KiB
JavaScript
Raw Normal View History

2019-03-13 00:04:16 +00:00
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { find, click, render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
import { startMirage } from 'nomad-ui/initializers/ember-cli-mirage';
import { componentA11yAudit } from 'nomad-ui/tests/helpers/a11y-audit';
2021-12-28 14:45:20 +00:00
module('Integration | Component | page layout', function (hooks) {
2019-03-13 00:04:16 +00:00
setupRenderingTest(hooks);
2021-12-28 14:45:20 +00:00
hooks.beforeEach(function () {
this.server = startMirage();
2019-03-13 00:04:16 +00:00
});
2021-12-28 14:45:20 +00:00
hooks.afterEach(function () {
this.server.shutdown();
2019-03-13 00:04:16 +00:00
});
2021-12-28 14:45:20 +00:00
test('the global-header hamburger menu opens the gutter menu', async function (assert) {
await render(hbs`<PageLayout />`);
2019-03-13 00:04:16 +00:00
assert.notOk(
find('[data-test-gutter-menu]').classList.contains('is-open'),
'Gutter menu is not open'
);
await click('[data-test-header-gutter-toggle]');
2021-12-28 16:08:12 +00:00
assert.ok(
find('[data-test-gutter-menu]').classList.contains('is-open'),
'Gutter menu is open'
);
await componentA11yAudit(this.element, assert);
});
2021-12-28 14:45:20 +00:00
test('the gutter-menu hamburger menu closes the gutter menu', async function (assert) {
await render(hbs`<PageLayout />`);
await click('[data-test-header-gutter-toggle]');
2021-12-28 16:08:12 +00:00
assert.ok(
find('[data-test-gutter-menu]').classList.contains('is-open'),
'Gutter menu is open'
);
await click('[data-test-gutter-gutter-toggle]');
assert.notOk(
find('[data-test-gutter-menu]').classList.contains('is-open'),
'Gutter menu is not open'
);
2019-03-13 00:04:16 +00:00
});
2021-12-28 14:45:20 +00:00
test('the gutter-menu backdrop closes the gutter menu', async function (assert) {
await render(hbs`<PageLayout />`);
await click('[data-test-header-gutter-toggle]');
2021-12-28 16:08:12 +00:00
assert.ok(
find('[data-test-gutter-menu]').classList.contains('is-open'),
'Gutter menu is open'
);
await click('[data-test-gutter-backdrop]');
assert.notOk(
find('[data-test-gutter-menu]').classList.contains('is-open'),
'Gutter menu is not open'
);
2019-03-13 00:04:16 +00:00
});
});