module('Integration | Component | target', function(hooks) { setupRenderingTest(hooks); test('ember-tooltip target test', async function(assert) { assert.expect(4); await render(hbs` <div id="some-target"></div> {{ember-tooltip targetId='some-target'}} `); const expectedTarget = find('#some-target'); const target = findTooltipTarget(); assert.ok(expectedTarget.classList.contains('ember-tooltip-target'), '#some-target should be the tooltip target'); assert.equal(expectedTarget, target, 'The element with ID equal to targetID should be the tooltip target'); await triggerEvent(target, 'mouseenter'); const tooltip = findTooltip(); const targetDescribedby = target.getAttribute('aria-describedby'); assert.ok(!!targetDescribedby, 'The target should have an aria-describedby attribute after the tooltip renders'); assert.equal(targetDescribedby, tooltip.getAttribute('id'), `The tooltip ID should match the target's aria-describedby attribute`); }); });
module('Integration | Component | datasets/upstream owners', function(hooks) { setupRenderingTest(hooks); test('it renders', async function(assert) { await render(hbs`{{datasets/upstream-owners}}`); assert.ok(document.querySelector('.upstream-owners-banner'), 'renders upstream-dataset as expected'); }); test('rendering nativeName', async function(assert) { const titleElementQuery = '.upstream-owners-banner__title strong'; const nativeName = 'Upstream Dataset'; this.set('nativeName', nativeName); await render(hbs`{{datasets/upstream-owners nativeName=nativeName}}`); assert.ok( document .querySelector(titleElementQuery) .textContent.trim() .includes(nativeName), 'it renders upstream ownership properties' ); }); test('link to upstream dataset', async function(assert) { this.set('upstreamUrn', hdfsUrn); await render(hbs`{{datasets/upstream-owners upstreamUrn=upstreamUrn}}`); assert.ok(document.querySelector('.upstream-owners-banner a'), 'it creates a link to the upstream dataset'); }); });
module('Integration | Component | avatars/avatar image', function(hooks) { setupRenderingTest(hooks); test('avatar-image render', async function(assert) { let avatarImage; await render(hbs`{{avatars/avatar-image}}`); avatarImage = find(expectedAvatarElementClassName); assert.ok(avatarImage, 'it renders with expected className'); assert.equal(avatarImage.tagName.toLowerCase(), 'img', 'it renders with expected element'); this.set('avatar', avatar); await render(hbs`{{avatars/avatar-image avatar=avatar}}`); avatarImage = find(expectedAvatarElementClassName); assert.equal(avatarImage.getAttribute('alt'), avatar.name, 'alt attribute is bound to avatar name'); assert.equal(avatarImage.getAttribute('src'), avatar.imageUrl, 'src attribute is bound to avatar imageUrl'); }); test('image fallback', async function(assert) { const { imageUrlFallback } = avatar; this.set('avatar', { ...avatar, imageUrl: '' }); await render(hbs`{{avatars/avatar-image avatar=avatar}}`); assert.equal( find(expectedAvatarElementClassName).getAttribute('src'), imageUrlFallback, 'src attribute is set to fallback url avatar' ); }); });
module('Integration | Option | popperContainer', function(hooks) { setupRenderingTest(hooks); test('by default, the tooltip is rendered adjacent to its target', async function(assert) { await render(hbs` <div id='tooltip-target'> {{ember-tooltip text='tooltip-text'}} </div> `); const expectedContainer = this.element; const target = findTooltipTarget(); await triggerEvent(target, 'mouseenter'); const tooltip = findTooltip(); assert.equal(tooltip.parentElement, expectedContainer, 'The tooltip should be a sibling of its target'); }); test('the popperContainer attribute allows the tooltip parent to be set', async function(assert) { await render(hbs` <div id='tooltip-container'></div> <div id='tooltip-target'> {{ember-tooltip text='tooltip-text' popperContainer='#tooltip-container'}} </div> `); const expectedContainer = find('#tooltip-container'); const target = findTooltipTarget(); await triggerEvent(target, 'mouseenter'); const tooltip = findTooltip(); assert.equal(tooltip.parentElement, expectedContainer, 'The element identified by the popperContainer attribute should be the tooltip parent'); }); });
module('Integration | Helper | {{slice}}', function(hooks) { setupRenderingTest(hooks); test('It slices an array with positional params', async function(assert) { this.set('array', emberArray([2, 4, 6])); await render(hbs` {{slice 1 3 array}} `); assert.equal(find('*').textContent.trim(), '4,6', 'sliced values'); }); test('It recomputes the slice if an item in the array changes', async function(assert) { let array = emberArray([2, 4, 6]); this.set('array', array); await render(hbs` {{slice 1 3 array}} `); assert.equal(find('*').textContent.trim(), '4,6', 'sliced values'); run(() => array.replace(2, 1, [5])); assert.equal(find('*').textContent.trim(), '4,5', 'sliced values'); }); });
module('Integration | Component | bs-nav', function(hooks) { setupRenderingTest(hooks); test('it has correct markup', async function(assert) { // Template block usage: await render(hbs` {{#bs-nav}} template block text {{/bs-nav}} `); assert.dom('*').hasText('template block text', 'Shows block content'); assert.dom('ul').exists({ count: 1 }, 'it is an unordered list'); assert.dom('ul').hasClass('nav', 'has nav class'); }); testBS3('it supports bootstrap options', async function(assert) { // Template block usage: await render(hbs` {{bs-nav justified=true stacked=true type="pills"}} `); assert.dom('ul').hasClass('nav-pills', 'has pills class'); assert.dom('ul').hasClass('nav-justified', 'has justified class'); assert.dom('ul').hasClass('nav-stacked', 'has stacked class'); }); testBS4('it supports bootstrap options', async function(assert) { // Template block usage: await render(hbs` {{bs-nav justified=true stacked=true fill=true type="pills"}} `); assert.dom('ul').hasClass('nav-pills', 'has pills class'); assert.dom('ul').hasClass('nav-justified', 'has justified class'); assert.dom('ul').hasClass('nav-fill', 'has fill class'); assert.dom('ul').hasClass('flex-column', 'has stacked class'); }); test('it exposes contextual components', async function(assert) { await render(hbs` {{#bs-nav as |nav|}} {{#nav.item}} {{#nav.link-to "application"}}Dummy{{/nav.link-to}} {{/nav.item}} {{#nav.dropdown as |dd|}} {{#dd.toggle}}Dropdown <span class="caret"></span>{{/dd.toggle}} {{#dd.menu as |ddm|}} {{#ddm.item}}{{#ddm.link-to "index"}}Home{{/ddm.link-to}}{{/ddm.item}} {{/dd.menu}} {{/nav.dropdown}} {{/bs-nav}} `); assert.dom('.nav').exists({ count: 1 }, 'it has the nav'); assert.dom('.nav > li').exists({ count: 2 }, 'it has the nav item'); assert.dom('.nav > li > a[href]').exists({ count: 1 }, 'it has the nav link'); assert.dom('.nav > li.dropdown').exists({ count: 1 }, 'it has a dropdown as a nav item'); }); });
module('Integration | Helper | round-number', function(hooks) { setupRenderingTest(hooks); test('it rounds a number to a whole number if precision is 0', async function(assert) { let value = 123.123123; let precision = 0; this.setProperties({ value, precision, }); await render(hbs`{{round-number value=value precision=precision}}`); assert.dom('*').hasText('123'); }); test('it rounds to the specified precision', async function(assert) { let value = 123.456; let precision = 1; this.setProperties({ value, precision, }); await render(hbs`{{round-number value=value precision=precision}}`); assert.dom('*').hasText('123.5'); }); });
module('Integration | Util | select-text-in', function(hooks) { setupRenderingTest(hooks); test('it works for textarea element', async function(assert) { let targetElement = document.createElement('textarea'); targetElement.value = 'select me'; document.body.appendChild(targetElement); assert.equal(selectTextIn(targetElement), 'select me'); assert.equal(window.getSelection(), 'select me'); }); test('it works for input element', async function(assert) { let targetElement = document.createElement('input'); targetElement.value = 'select me'; document.body.appendChild(targetElement); assert.equal(selectTextIn(targetElement), 'select me'); assert.equal(window.getSelection(), 'select me'); }); test('it works for div element', async function(assert) { let targetElement = document.createElement('div'); targetElement.textContent = 'select me'; document.body.appendChild(targetElement); assert.equal(selectTextIn(targetElement), 'select me'); assert.equal(window.getSelection(), 'select me'); }); });
module('Integration | Component | build-minutes', function (hooks) { setupRenderingTest(hooks); hooks.beforeEach(function () { const user = this.server.create('user'); this.setProperties({ ownerData: user, private: true, interval: INSIGHTS_INTERVALS.WEEK, }); }); test('it renders', async function (assert) { this.server.createList('insight-metric', 5); await render(hbs`{{build-minutes interval=interval owner=ownerData private=private}}`); await settled(); assert.dom('.insights-glance').doesNotHaveClass('insights-glance--loading'); assert.dom('.insights-glance__title').hasText('Total Job Minutes'); assert.dom('.insights-glance__stat').hasText('5 mins'); assert.dom('.insights-glance__chart .chart-component').exists(); }); test('loading state renders', async function (assert) { render(hbs`{{build-minutes interval=interval owner=ownerData private=private}}`); await waitFor('.insights-glance--loading'); assert.dom('.insights-glance').hasClass('insights-glance--loading'); assert.dom('.insights-glance__title').hasText('Total Job Minutes'); assert.dom('.insights-glance__stat').hasText(''); assert.dom('.insights-glance__chart .chart-component').doesNotExist(); assert.dom('.insights-glance__chart-placeholder').exists(); }); });
module('Integration | Component | models table/themes/semanticui/data group by select', function(hooks) { setupRenderingTest(hooks); test('it renders', function(assert) { assert.ok(true); }); });
module('Integration | Component | travis-status', function (hooks) { setupRenderingTest(hooks); hooks.beforeEach(function () { config.statusPageStatusUrl = 'https://pnpcptp8xh9k.statuspage.io/api/v2/status.json'; }); hooks.afterEach(function () { config.statusPageStatusUrl = undefined; }); test('shows normal status when nothing wrong', async function (assert) { await render(hbs`{{travis-status}}`); return settled().then(() => { assert.dom('.status-circle').hasClass('none', 'status class is set on .status-circle'); }); }); test('shows unknown status when statuspage returns error', async function (assert) { this.server.get(config.statusPageStatusUrl, () => { return new Response(500, {}, {}); }); await render(hbs`{{travis-status}}`); return settled().then(() => { assert.dom('.status-circle').hasClass('unknown', 'unknown status class is set on error'); }); }); });
module('Test Helpers | setBreakpoint', function(hooks) { setupRenderingTest(hooks); hooks.beforeEach(function() { this.owner.register('breakpoints:main', { mobile: '(max-width: 767px)', tablet: '(min-width: 768px) and (max-width: 991px)', desktop: '(min-width: 992px) and (max-width: 1200px)' }, { instantiate: false }); this.owner.register('component:dummy-component', Component.extend({ media: service() })); }); test('The default breakpoint in test is "desktop"', async function(assert) { let subject = this.owner.factoryFor('component:dummy-component').create(); assert.equal(subject.get('media.isDesktop'), true); assert.equal(subject.get('media.isTablet'), false); assert.equal(subject.get('media.isMobile'), false); assert.equal(subject.get('media.classNames'), 'media-desktop'); }); test('if `setBreakpoint` is called with an unknown breakpoint name, it throws an error', function (assert) { assert.throws(function() { setBreakpoint('watch'); }, 'Breakpoint "watch" is not defined in your breakpoints file'); }); test('`setBreakpoint` can change the media information', function(assert) { setBreakpoint('tablet'); let subject = this.owner.factoryFor('component:dummy-component').create(); assert.equal(subject.get('media.isDesktop'), false); assert.equal(subject.get('media.isTablet'), true); assert.equal(subject.get('media.isMobile'), false); assert.equal(subject.get('media.classNames'), 'media-tablet'); assert.deepEqual(subject.get('media.matches'), ['tablet']); }); test('`setBreakpoint` can be "awaited" to ensure the template has updated', async function(assert) { setBreakpoint("tablet"); await this.render(hbs` <div id="dom-target"> {{#if (media "isMobile")}} Mobile {{else if (media "isTablet")}} Tablet {{else}} Desktop {{/if}} </div> `); assert.dom('#dom-target').hasText('Tablet'); await setBreakpoint('mobile'); assert.dom('#dom-target').hasText('Mobile'); await setBreakpoint('desktop'); assert.dom('#dom-target').hasText('Desktop'); }); });
module('Integration | Component | bs-dropdown/toggle', function(hooks) { setupRenderingTest(hooks); setupNoDeprecations(hooks); hooks.beforeEach(function() { this.actions = {}; this.send = (actionName, ...args) => this.actions[actionName].apply(this, args); }); test('toggle has correct default markup', async function(assert) { await render(hbs`{{#bs-dropdown/toggle}}Test{{/bs-dropdown/toggle}}`); assert.dom('a').exists('toggle is an anchor tag by default'); assert.dom('a').hasAttribute('href', '#', 'has href attribute'); assert.dom('.dropdown-toggle').exists('has dropdown-toggle class'); assert.dom('a').hasAttribute('role', 'button', 'has role=button'); }); test('toggle as button does not have href', async function(assert) { await render(hbs`{{#bs-dropdown/toggle tagName="button"}}Test{{/bs-dropdown/toggle}}`); assert.dom('button').exists('toggle is a button'); assert.dom('button').doesNotHaveAttribute('href', 'does not have href attribute'); }); test('clicking toggle sends onClick action', async function(assert) { let action = this.spy(); this.actions.click = action; await render(hbs`{{#bs-dropdown/toggle onClick=(action "click")}}Test{{/bs-dropdown/toggle}}`); await click('a'); assert.ok(action.calledOnce, 'onClick action has been called.'); }); });
function(hooks) { setupRenderingTest(hooks); skip('it renders', async function() { await render(hbs`{{community-bar/local-navigation-level-2}}`); }); },
module('Integration | Component | bs form/element/errors', function(hooks) { setupRenderingTest(hooks); setupNoDeprecations(hooks); test('is empty by default', async function(assert) { this.set('messages', ['foo', 'bar']); await render(hbs`{{bs-form/element/errors show=false messages=messages}}`); assert.dom(`.${formFeedbackClass()}`).doesNotExist(); }); test('shows first message', async function(assert) { this.set('messages', A(['foo', 'bar'])); await render(hbs`{{bs-form/element/errors show=true messages=messages}}`); assert.dom(`.${formFeedbackClass()}`).exists({ count: 1 }); assert.dom(`.${formFeedbackClass()}`).hasText('foo'); }); test('shows multiple errors', async function(assert) { this.set('messages', A(['foo', 'bar'])); await render(hbs`{{bs-form/element/errors messages=messages show=true showMultipleErrors=true}}`); assert.dom(`.${formFeedbackClass()}`).exists({ count: 2 }); assert.dom(`.${formFeedbackClass()}:first-child`).hasText('foo'); assert.dom(`.${formFeedbackClass()}:last-child`).hasText('bar'); }); });
module('Integration | Option | updateFor', function(hooks) { setupRenderingTest(hooks); test('updateFor test', async function(assert) { assert.expect(2); this.set('asyncContent', null); await render(hbs` {{#ember-tooltip updateFor=asyncContent isShown=true}} {{#if asyncContent}} {{asyncContent}} {{else}} ... {{/if}} {{/ember-tooltip}} `); assertTooltipContent(assert, { contentString: '...', }); /* After 200ms, change the async content */ this.set('asyncContent', 'Some model'); await settled(); assertTooltipContent(assert, { contentString: 'Some model', }); }); });
module('Integration | Component | ttl picker', function(hooks) { setupRenderingTest(hooks); hooks.beforeEach(function() { this.changeSpy = sinon.spy(); this.set('onChange', this.changeSpy); }); test('it renders error on non-number input', async function(assert) { await render(hbs`<TtlPicker @onChange={{onChange}} />`); let callCount = this.changeSpy.callCount; await fillIn('[data-test-ttl-value]', 'foo'); assert.equal(this.changeSpy.callCount, callCount, "it did't call onChange again"); assert.dom('[data-test-ttl-error]').includesText('Error', 'renders the error box'); await fillIn('[data-test-ttl-value]', '33'); assert.dom('[data-test-ttl-error]').doesNotIncludeText('Error', 'removes the error box'); }); test('it shows 30s for invalid duration initialValue input', async function(assert) { await render(hbs`<TtlPicker @onChange={{onChange}} @initialValue={{'invalid'}} />`); assert.dom('[data-test-ttl-value]').hasValue('30', 'sets 30 as the default'); }); });
module('Integration | Component | pending single user update', function(hooks) { setupRenderingTest(hooks); test('it renders', async function(assert) { // Set any properties with this.set('myProperty', 'value'); // Handle any actions with this.on('myAction', function(val) { ... });" let updates = [ { type: 'emailMismatch', value: 'directory-email', } ]; let user = EmberObject.create({ pendingUserUpdates: PromiseArray.create({ promise: resolve(updates) }), email: 'user-email' }); updates[0].user = user; this.set('user', user); await render(hbs`{{pending-single-user-update user=user}}`); return settled().then(() => { assert.equal(this.element.textContent.trim().search(/The email address in the directory \(directory-email\) does not match the email in ilios \(user-email\)/), 0); }); }); });
module('Integration | Component | api version check', function(hooks) { setupRenderingTest(hooks); test('shows no warning when versions match', async function(assert) { const iliosConfigMock = Service.extend({ apiVersion: resolve(apiVersion) }); const warningOverlay = '.api-version-check-warning'; this.owner.register('service:iliosConfig', iliosConfigMock); await render(hbs`{{api-version-check}}`); await waitFor('[data-test-load-finished]'); await settled(); assert.equal(document.querySelectorAll(warningOverlay).length, 0); }); test('shows warning on mismatch', async function(assert) { const iliosConfigMock = Service.extend({ apiVersion: resolve('bad') }); const warningOverlay = '.api-version-check-warning'; this.owner.register('service:iliosConfig', iliosConfigMock); await render(hbs`{{api-version-check}}`); await waitFor('[data-test-load-finished]'); await settled(); assert.equal(document.querySelectorAll(warningOverlay).length, 1); }); });
module('Integration | Component | pending updates summary', function(hooks) { setupRenderingTest(hooks); setupMirage(hooks); hooks.beforeEach(function() { currentUserMock = Service.extend({}); this.owner.register('service:currentUser', currentUserMock); }); test('it renders', async function (assert) { const school = this.server.create('school'); this.server.create('school'); const user = this.server.create('user', { school }); const userModel = await run(() => this.owner.lookup('service:store').find('user', user.id)); for (let i = 0; i < 5; i++) { const user = this.server.create('user', { school }); this.server.create('pending-user-update', { user }); } currentUserMock.reopen({ model: resolve(userModel) }); const schools = await run(() => this.owner.lookup('service:store').findAll('school')); this.set('schools', schools); await render(hbs`{{pending-updates-summary schools=schools}}`); assert.ok(this.element.textContent.includes('Updates from the Campus Directory')); assert.ok(this.element.textContent.includes('There are 5 users needing attention')); assert.dom(this.element.querySelector('[data-test-pending-updates-summary]')).hasClass('alert'); }); });
module('Integration | Component | filter bar', function(hooks) { setupRenderingTest(hooks); test('it renders well', async function(assert) { const headers = config.map((category) => category.header); this.setProperties({ entities: {}, config, onFilterSelection: () => {} }); await render(hbs` {{filter-bar entities=entities onFilter=(action onFilterSelection) config=config }} `); const filterBarText = this.$().text().trim(); headers.forEach((header) => { assert.ok(filterBarText.includes(header), `filter bar should display ${header}`); }); }); });
module('Integration | Component | bs-navbar/toggle', function(hooks) { setupRenderingTest(hooks); setupNoDeprecations(hooks); testBS3('it renders inline usage', async function(assert) { await render(hbs`{{bs-navbar/toggle}}`); assert.dom('*').hasText('Toggle navigation'); }); testBS4('it renders inline usage', async function(assert) { await render(hbs`{{bs-navbar/toggle}}`); assert.dom('.navbar-toggler > span').hasClass('navbar-toggler-icon'); }); test('it renders block usage', async function(assert) { await render(hbs` {{#bs-navbar/toggle}} template block text {{/bs-navbar/toggle}} `); assert.dom('*').hasText('template block text'); }); test('it has correct markup', async function(assert) { await render(hbs`{{bs-navbar/toggle}}`); assert.dom('button').exists({ count: 1 }, 'there is exactly one button element'); assert.dom('button').hasClass(versionDependent('navbar-toggle','navbar-toggler'), 'the toggle has the appropriate toggle class'); assert.dom('button').hasClass('collapsed', 'the toggle has the collapsed class'); assert.dom('button').doesNotHaveClass('btn', 'the toggle is a simple button without .btn'); }); });
module('Integration | Component | sidebar-filter', function(hooks) { setupRenderingTest(hooks); hooks.beforeEach(function() { this.set('filter', { name: 'Directory', key: 'fileDir', items: [ { name: 'icons', count: 1 }, { name: 'images', count: 2 } ] }); }); test('it renders a filter with 2 items properly', async function(assert) { let router = this.owner.lookup('router:main'); router.setupRouter(); await render(hbs`{{sidebar-filter filter=filter}}`); assert.dom('[data-test-sidebar-filter]').exists({ count: 1 }); assert.dom('[data-test-sidebar-filter-title]').hasText('by Directory'); assert.dom('a[data-test-sidebar-filter-item]').exists({ count: 2 }); let [firstItem, secondItem] = this.element.querySelectorAll('[data-test-sidebar-filter-item]'); assert.dom(firstItem).hasAttribute('href', '#/?filterBy=fileDir%3Aicons'); assert.dom('[data-test-sidebar-filter-name]', firstItem).hasText('icons'); assert.dom('[data-test-sidebar-filter-count]', firstItem).hasText('1'); assert.dom(secondItem).hasAttribute('href', '#/?filterBy=fileDir%3Aimages'); assert.dom('[data-test-sidebar-filter-name]', secondItem).hasText('images'); assert.dom('[data-test-sidebar-filter-count]', secondItem).hasText('2'); }); });
module('Integration | Component | toggle button', function(hooks) { setupRenderingTest(hooks); test('toggle functionality', async function(assert) { this.set('toggleTarget', {}); await render(hbs`{{toggle-button toggleTarget=toggleTarget toggleAttr="toggled"}}`); assert.equal(find('button').textContent.trim(), 'More options', 'renders default closedLabel'); await click('button'); assert.equal(this.get('toggleTarget.toggled'), true, 'it toggles the attr on the target'); assert.equal(find('button').textContent.trim(), 'Hide options', 'renders default openLabel'); await click('button'); assert.equal(this.get('toggleTarget.toggled'), false, 'it toggles the attr on the target'); this.set('closedLabel', 'Open the options!'); this.set('openLabel', 'Close the options!'); await render( hbs`{{toggle-button toggleTarget=toggleTarget toggleAttr="toggled" closedLabel=closedLabel openLabel=openLabel}}` ); assert.equal(find('button').textContent.trim(), 'Open the options!', 'renders passed closedLabel'); await click('button'); assert.equal(find('button').textContent.trim(), 'Close the options!', 'renders passed openLabel'); }); });
module('Integration | Component | notifications/banner alerts', function(hooks) { setupRenderingTest(hooks); hooks.beforeEach(function() { this.owner.register('service:banners', bannersStub); this.banners = this.owner.lookup('service:banners'); }); const bannerAlertClass = '.banner-alert'; test('it renders', async function(assert) { await render(hbs`{{notifications/banner-alerts}}`); assert.ok(this.$(), 'Renders without errors'); }); test('it renders the correct information', async function(assert) { await render(hbs`{{notifications/banner-alerts}}`); assert.equal(findAll(bannerAlertClass).length, 2, 'Renders the correct amount of banners'); assert.equal( this.$(`${bannerAlertClass}__content:eq(0)`) .text() .trim(), banners[0].content, 'Renders the correct text' ); assert.equal(this.$(`.fa-${banners[0].iconName}`).length, 1, 'Renders the correct types of banners'); }); });
function(hooks) { setupRenderingTest(hooks); skip('it renders', async function() { await render(hbs`{{global-navigation/content-recommendations}}`); }); },
module('Integration | Helper | {{map-by}}', function(hooks) { setupRenderingTest(hooks); test('It maps by value', async function(assert) { this.set('array', emberArray([ { name: 'a' }, { name: 'b' }, { name: 'c' } ])); await render(hbs` {{~#each (map-by 'name' array) as |name|~}} {{~name~}} {{~/each~}} `); assert.equal(find('*').textContent.trim(), 'abc', 'name property is mapped'); }); test('It watches for changes', async function(assert) { let array = emberArray([ { name: 'a' }, { name: 'b' }, { name: 'c' } ]); this.set('array', array); await render(hbs` {{~#each (map-by 'name' array) as |name|~}} {{~name~}} {{~/each~}} `); run(() => array.pushObject({ name: 'd' })); assert.equal(find('*').textContent.trim(), 'abcd', 'd is added'); }); test('It watches for changes to byPath', async function(assert) { let array = emberArray([ { name: 'a', x: 1 }, { name: 'b', x: 2 }, { name: 'c', x: 3 } ]); this.set('array', array); this.set('property', 'name'); await render(hbs` {{~#each (map-by property array) as |name|~}} {{~name~}} {{~/each~}} `); this.set('property', 'x'); assert.equal(find('*').textContent.trim(), '123', '123 is displayed'); }); });
module('Integration | Component | mount filter config list', function(hooks) { setupRenderingTest(hooks); test('it renders', async function(assert) { this.set('config', { mode: 'whitelist', paths: [] }); this.set('mounts', [{ path: 'userpass/', type: 'userpass', accessor: 'userpass' }]); await render(hbs`{{mount-filter-config-list config=config mounts=mounts}}`); assert.equal(findAll('#filter-userpass').length, 1); }); test('it sets config.paths', async function(assert) { this.set('config', { mode: 'whitelist', paths: [] }); this.set('mounts', [{ path: 'userpass/', type: 'userpass', accessor: 'userpass' }]); await render(hbs`{{mount-filter-config-list config=config mounts=mounts}}`); await click('#filter-userpass'); assert.ok(this.get('config.paths').includes('userpass/'), 'adds to paths'); await click('#filter-userpass'); assert.equal(this.get('config.paths').length, 0, 'removes from paths'); }); test('it sets config.mode', async function(assert) { this.set('config', { mode: 'whitelist', paths: [] }); await render(hbs`{{mount-filter-config-list config=config}}`); await fillIn('#filter-mode', 'blacklist'); await blur('#filter-mode'); assert.equal(this.get('config.mode'), 'blacklist'); }); });
module('Integration | Component | datasets/compliance/export-policy', function(hooks) { setupRenderingTest(hooks); test('it renders', async function(assert) { await render(hbs`{{datasets/compliance/export-policy}}`); assert.ok(this.element, 'Renders independently with no errors'); this.setProperties({ exportPolicy: { containsUserGeneratedContent: false, containsUserActionGeneratedContent: false, containsUserDerivedContent: false }, isEditing: false }); await render(hbs`{{datasets/compliance/export-policy exportPolicy=exportPolicy isEditing=isEditing}}`); assert.ok(this.element, 'Also renders without errors when passed expected properties'); assert.ok(find(header).textContent.includes('Data Export Metadata Annotations'), 'Title includes correct text'); assert.ok(find(table), 'Renders a table'); }); test('it functions as expected', async function(assert) { this.setProperties({ exportPolicy: { containsUserGeneratedContent: false, containsUserActionGeneratedContent: false, containsUserDerivedContent: false }, isEditing: false, toggleEditing: editingMode => this.set('isEditing', editingMode), onSaveExportPolicy: exportPolicy => { assert.equal(exportPolicy.containsUserGeneratedContent, true, 'Sends the correct export policy object'); } }); await render(hbs`{{datasets/compliance/export-policy exportPolicy=exportPolicy isEditing=isEditing toggleEditing=toggleEditing onSaveExportPolicy=onSaveExportPolicy}}`); assert.expect(7); assert.ok(this.element, 'Still renders without errors'); assert.equal(this.get('isEditing'), false, 'Base case for is editing test'); assert.notOk(find(actionBar), 'Action bar does not exist without editing mode'); await click(editButton); assert.equal(this.get('isEditing'), true, 'Edit button works'); assert.ok(find(actionBar), 'Action bar now exists with editing mode'); assert.ok(find(`${UGCRadioButton}`), 'Edit radio butotn for UGC exists'); await click(`${UGCRadioButton}`); await click(saveButton); }); });
module('Integration | Component | paper-card', function(hooks) { setupRenderingTest(hooks); test('blockless media renders image', async function(assert) { assert.expect(5); await render(hbs` {{#paper-card as |card|}} {{#card.title as |title|}} {{#title.text as |text|}} {{#text.headline}}Card with block{{/text.headline}} {{#text.subhead}}Extra large{{/text.subhead}} {{/title.text}} {{/card.title}} {{#card.content class="layout-row layout-align-space-between"}} {{card.media src="/image.png" alt="imagealt" title="imagetitle" size="xl"}} {{#card.actions class="layout-column"}} {{#paper-button iconButton=true}}{{paper-icon "favorite"}}{{/paper-button}} {{#paper-button iconButton=true}}{{paper-icon "settings"}}{{/paper-button}} {{#paper-button iconButton=true}}{{paper-icon "share"}}{{/paper-button}} {{/card.actions}} {{/card.content}} {{/paper-card}} `); assert.dom('img').exists({ count: 1 }); assert.dom('img').hasAttribute('src', /image.png$/); assert.dom('img').hasAttribute('alt', 'imagealt'); assert.dom('img').hasAttribute('title', 'imagetitle'); assert.dom('img').hasClass('md-media-xl'); }); test('block media renders div with correct class', async function(assert) { assert.expect(1); await render(hbs` {{#paper-card as |card|}} {{#card.title as |title|}} {{#title.text as |text|}} {{#text.headline}}Card with block{{/text.headline}} {{#text.subhead}}Extra large{{/text.subhead}} {{/title.text}} {{/card.title}} {{#card.content class="layout-row layout-align-space-between"}} {{#card.media size="xl"}} <div id="çup"></div> {{/card.media}} {{#card.actions class="layout-column"}} {{#paper-button iconButton=true}}{{paper-icon "favorite"}}{{/paper-button}} {{#paper-button iconButton=true}}{{paper-icon "settings"}}{{/paper-button}} {{#paper-button iconButton=true}}{{paper-icon "share"}}{{/paper-button}} {{/card.actions}} {{/card.content}} {{/paper-card}} `); assert.dom('div.md-media-xl').exists({ count: 1 }); }); });