Files
threshold-ui/addons/core/tests/integration/helpers/doc-url-test.js
T

34 lines
1.2 KiB
JavaScript
Raw Normal View History

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
2020-10-05 16:49:35 -04:00
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
2020-11-16 15:08:59 -05:00
module('Integration | Helper | doc-url', function (hooks) {
2020-10-05 16:49:35 -04:00
setupRenderingTest(hooks);
2020-11-16 15:08:59 -05:00
test('it renders a URL generated from the documentation config', async function (assert) {
2020-10-05 16:49:35 -04:00
assert.expect(3);
2021-11-05 13:20:45 -04:00
const config = this.owner.resolveRegistration('config:environment');
2020-10-05 16:49:35 -04:00
const baseURL = config.documentation.baseURL;
const path = config.documentation.topics.account;
await render(hbs`{{doc-url 'account'}}`);
2020-10-05 16:49:35 -04:00
assert.ok(baseURL);
assert.ok(path);
assert.strictEqual(this.element.textContent.trim(), `${baseURL}${path}`);
2020-10-05 16:49:35 -04:00
});
2020-11-16 15:08:59 -05:00
test('it throws an error if the specified documentation path cannot be found', async function (assert) {
2020-10-05 16:49:35 -04:00
assert.expect(2);
2021-11-05 13:20:45 -04:00
const Helper = this.owner.lookup('helper:doc-url');
const helper = new Helper(this.owner);
2020-11-16 15:08:59 -05:00
assert.ok(helper.compute(['account']), 'Specified document exists.');
2020-10-05 16:49:35 -04:00
assert.throws(() => {
helper.compute(['no.such.doc']);
}, 'Specified documentation was not found, so the helper threw an error.');
});
});