feat: 🎸 add doc-url helper and doc-link component

This commit is contained in:
Randall Morey committed 2020-10-05 16:49:35 -04:00
1 parent d13e711626
commit c4e52cb2e7
4 files changed
+69

No files matched your search

@@ -0,0 +1,14 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, find } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
module('Integration | Component | doc-link', function(hooks) {
setupRenderingTest(hooks);
test('it renders', async function(assert) {
assert.expect(1);
await render(hbs`<DocLink @doc="topics.account" @iconSize="large" />`);
assert.ok(find('.doc-link .rose-icon.large'));
});
});
@@ -0,0 +1,29 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import config from 'ember-get-config';
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 baseURL = config.documentation.baseURL;
const path = config.documentation.topics.account;
await render(hbs`{{doc-url 'topics.account'}}`);
assert.ok(baseURL);
assert.ok(path);
assert.equal(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');
assert.ok(helper.compute(['topics.account']), 'Specified document exists.')
assert.throws(() => {
helper.compute(['no.such.doc']);
}, 'Specified documentation was not found, so the helper threw an error.');
});
});