Files
threshold-ui/addons/core/tests/integration/helpers/doc-url-test.js
T
hashicorp-copywrite[bot]andCameron Perera 3d610427d0 [COMPLIANCE] Add Copyright and License Headers (#1617)
* [COMPLIANCE] Add Copyright and License Headers

* chore: 🤖 update Copyright headers to satisfy our lint rules

---------

Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
Co-authored-by: Cameron Perera <cameron.perera@hashicorp.com>
2023-03-01 09:39:41 -06:00

35 lines
1.2 KiB
JavaScript

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