test('it set `noSwiping` via attribute and `options`', async function(assert) {
    let expected = false;

    this.set('noSwiping', expected);
    await render(
      hbs`{{swiper-container noSwiping=noSwiping registerAs=componentInstanceAttr}}`
    );

    assert.strictEqual(
      this.get('componentInstanceAttr._swiper.params.noSwiping'),
      expected,
      'Swiper instance `noSwiping` configured by `noSwiping` attribute'
    );

    this.set('options', { noSwiping: expected });
    await render(
      hbs`{{swiper-container options=options registerAs=componentInstanceOpts}}`
    );

    assert.strictEqual(
      this.get('componentInstanceOpts._swiper.params.noSwiping'),
      expected,
      'Swiper instance `noSwiping` configured by `options.noSwiping`'
    );
  });
Ejemplo n.º 2
0
  test('Compliance Purge Policy', async function(assert) {
    assert.expect(3);

    const downstreamClass = '.downstream-purge-policy';
    const defaultMissingText = 'This dataset does not have a current compliance purge policy';
    const { server } = this;
    const { platform, uri } = server.create('datasetView');

    this.set('urn', uri);
    this.set('platform', platform);
    await render(hbs`{{datasets/containers/upstream-dataset urn=urn platform=platform}}`);

    await waitUntil(() => find(downstreamClass));

    assert.equal(
      find(downstreamClass).textContent.trim(),
      defaultMissingText,
      'Shows the missing text string when there is no purge policy set'
    );

    assert.ok(find(downstreamPolicyEditButton), 'policy is editable');

    server.create('platform');
    server.create('retention');

    await render(hbs`{{datasets/containers/upstream-dataset urn=urn platform=platform}}`);

    await waitUntil(() => find(purgePolicyClass) && find(purgePolicyClass).textContent.trim() !== defaultMissingText);

    assert.ok(find.bind(find, purgePolicyClass), 'purge policy radio is rendered');
  });
Ejemplo n.º 3
0
  test('it works', async function(assert) {
    let { l10n } = this;
    await l10n.setLocale('en');

    await render(hbs`{{pn 'user' 'users' 1 'menu'}}`);
    assert
      .dom(this.element)
      .hasText(
        'subscription',
        'Contextual translations are working correctly for singular.'
      );

    await render(hbs`{{pn 'user' 'users' 3 'menu'}}`);
    assert
      .dom(this.element)
      .hasText(
        'subscriptions',
        'Contextual translations are working correctly for plural.'
      );

    await render(hbs`{{pn 'user' 'users' 3}}`);
    assert
      .dom(this.element)
      .hasText(
        'users',
        'Omitting context falls back to message without context.'
      );
  });
  test('add line numbers if enabled', async function(assert) {
    const john = { firstName: 'John', lastName: 'Doe', age: 20 };
    const jane = { firstName: 'Jane', lastName: 'Doe', age: 21 };
    const jeff = { firstName: 'Jeff', lastName: 'Doe', age: 22 };
    this.set('content', [john, jane, jeff]);
    this.set('data-table', {});
    this.set('data-table.parsedFields', ['firstName', 'lastName', 'age']);
    this.set('data-table.selection', []);

    await render(hbs`{{data-table-content-body content=content data-table=data-table enableLineNumbers=true}}`);

    assert.equal(this.$('tr:first td').length, 4, 'displays 4 columns');
    assert.equal(this.$('tr:first td:first').text().trim(), '1', 'displays offset 1 on the first row');
    assert.equal(this.$('tr:nth-child(2) td:first').text().trim(), '2', 'displays offset 2 on the second row');
    assert.equal(this.$('tr:nth-child(3) td:first').text().trim(), '3', 'displays offset 3 on the third row');

    this.set('data-table.page', 2);
    this.set('data-table.size', 5);
    await render(hbs`{{data-table-content-body content=content data-table=data-table enableLineNumbers=true}}`);

    assert.equal(this.$('tr:first td').length, 4, 'displays 4 columns on page 3');
    assert.equal(this.$('tr:first td:first').text().trim(), '11', 'displays offset 11 on the first row on page 3');
    assert.equal(this.$('tr:nth-child(2) td:first').text().trim(), '12', 'displays offset 12 on the second row on page 3');
    assert.equal(this.$('tr:nth-child(3) td:first').text().trim(), '13', 'displays offset 13 on the third row of page 3');
  });
	test( "Parent element and event listeners", async function( assert ) {
		// custom parent
		await render( hbs`
			<div class="parent" style="height: 100px; overflow-y: auto">
				<div class="child" style="height: 1000px">
					{{infinite-scroll _parent=parent _listener=listener}}
				</div>
			</div>
		` );
		const parent = this.element.querySelector( ".parent" );
		const listener = this.get( "listener" );

		assert.strictEqual(
			this.get( "parent" ),
			parent,
			"Finds the correct parent element with a scroll bar"
		);
		assert.ok(
			hasListener( parent, "scroll", listener ),
			"Parent has a scroll listener"
		);
		assert.ok(
			hasListener( window, "resize", listener ),
			"Window has a resize listener"
		);

		await clearRender();
		assert.notOk(
			hasListener( parent, "scroll", listener ),
			"Unregisters scroll listener"
		);
		assert.notOk(
			hasListener( window, "resize", listener ),
			"Unregisters resize listener"
		);

		// main.content parent
		await render( hbs`
			<main class="content">
				{{infinite-scroll _parent=parent}}
			</main>
		` );
		assert.strictEqual(
			this.get( "parent" ),
			this.element.querySelector( "main" ),
			"Uses main.content as fallback parent if it is available"
		);

		// document.body parent
		await render( hbs`
			{{infinite-scroll _parent=parent}}
		` );
		assert.strictEqual(
			this.get( "parent" ),
			document.body,
			"Uses the document body as ultimate fallback parent"
		);
	});
  test('it renders', async function(assert) {
    await render(hbs`{{swiper-container}}`);
    assert.equal(find('*').textContent.trim(), '');

    await render(hbs`
      {{#swiper-container}}
        template block text
      {{/swiper-container}}
    `);
    assert.equal(find('*').textContent.trim(), 'template block text');
  });
  test('navigation buttons are present if requested', async function(assert) {
    await render(hbs`{{swiper-container id="swp-container" navigation=false}}`);
    assert.notOk(find('#swp-container').querySelector('.swiper-button-next'));
    assert.notOk(find('#swp-container').querySelector('.swiper-button-prev'));

    await render(hbs`{{swiper-container id="swp-container" navigation=true}}`);
    assert.ok(find('#swp-container').querySelector('.swiper-button-next'));
    assert.ok(find('#swp-container').querySelector('.swiper-button-prev'));

    this.set('opts', { navigation: true });
    await render(hbs`{{swiper-container id="swp-container" options=opts}}`);
    assert.ok(find('#swp-container').querySelector('.swiper-button-next'));
    assert.ok(find('#swp-container').querySelector('.swiper-button-prev'));
  });
  test('it renders', async function(assert) {
    assert.expect(9);
    this.server.create('aamc-method', {
      id: 'AM001',
      description: "lorem ipsum"
    });
    this.server.create('aamc-method', {
      id: 'IM001',
      description: "lorem ipsum"
    });
    this.server.create('assessment-option', {
      name: 'formative'
    });
    const summative = this.server.create('assessment-option', {
      name: 'summative'
    });
    this.set('assessmentOptionId', summative.id);
    this.set('nothing', () => {});
    await render(hbs`{{school-session-type-form
      canEditTitle=true
      canEditAamcMethod=true
      canEditCalendarColor=true
      canEditAssessment=true
      canEditAssessmentOption=true
      canEditActive=true
      title='one'
      calendarColor='#ffffff'
      assessment=true
      isActive=true
      selectedAssessmentOptionId=assessmentOptionId
      save=(action nothing)
      close=(action nothing)
    }}`);

    const title = '[data-test-title]';
    const titleInput = `${title} input`;
    const aamcMethod = '[data-test-aamc-method]';
    const aamcMethodSelect = `${aamcMethod} select`;
    const aamcMethodOptions = `${aamcMethodSelect} option`;
    const firstAamcMethodOption = `${aamcMethodOptions}:nth-of-type(1)`;
    const secondAamcMethodOption = `${aamcMethodOptions}:nth-of-type(2)`;
    const color = '[data-test-color]';
    const colorInput = `${color} input`;
    const assessment = '[data-test-assessment]';
    const assessmentInput = `${assessment} input`;
    const assessmentOption = '[data-test-assessment-option]';
    const assessmentOptionSelect = `${assessmentOption} select`;
    const isActive = '[data-test-active]';
    const isActiveInput = `${isActive} input`;

    assert.dom(titleInput).hasValue('one', 'title is correct');
    assert.dom(aamcMethodSelect).hasValue('', 'corrrect aamc method is selected');
    assert.dom(aamcMethodOptions).exists({ count: 2 }, 'right number of aamcMethod options');
    assert.dom(firstAamcMethodOption).hasValue('', 'first aamcMethod is blank');
    assert.dom(secondAamcMethodOption).hasValue('AM001', 'second aamcMethod is filtered correctly');
    assert.dom(colorInput).hasValue('#ffffff', 'color is correct');
    assert.dom(assessmentInput).isChecked('assessment is selected');
    assert.dom(isActiveInput).isChecked('active is selected');
    assert.dom(assessmentOptionSelect).hasValue('2', 'correct assessment option is selected');
  });
Ejemplo n.º 9
0
  test('it renders', async function(assert) {
    this.set('inputValue', '1234');

    await render(hbs`{{json inputValue}}`);

    assert.equal(this.element.textContent.trim(), '1234');
  });
Ejemplo n.º 10
0
  test('it exposes default swiper navigation controls to `navigation=true`', async function(assert) {
    await render(hbs`
      {{#swiper-container navigation=true}}
        {{swiper-slide}}
        {{swiper-slide}}
        {{swiper-slide}}
      {{/swiper-container}}
    `);

    assert.ok(find('.swiper-button-next'), 'rendered nav next button');
    assert.ok(find('.swiper-button-prev'), 'rendered nav prev button');

    let slides = Array.from(findAll('.swiper-slide'));

    await click('.swiper-button-next');

    assert.ok(
      slides[1].classList.contains('swiper-slide-active'),
      'next button click handled'
    );

    await click('.swiper-button-prev');

    assert.ok(
      slides[0].classList.contains('swiper-slide-active'),
      'previous button click handled'
    );
  });
Ejemplo n.º 11
0
    return settled().then(async () => {
      run(() => {
        parent = this.store.peekAll('job').findBy('plainId', 'parent');
      });

      this.setProperties(
        props(parent, {
          gotoJob: gotoJobSpy,
        })
      );

      await render(hbs`
        {{job-page/parts/children
          job=job
          sortProperty=sortProperty
          sortDescending=sortDescending
          currentPage=currentPage
          gotoJob=gotoJob}}
      `);

      return settled().then(() => {
        click('tr.job-row');
        assert.ok(
          gotoJobSpy.withArgs(parent.get('children.firstObject')).calledOnce,
          'Clicking the job row calls the gotoJob action'
        );
      });
    });
Ejemplo n.º 12
0
  let checkObjects = async function(context, assert, subjectNum, subjectVal, expectedObjects){
    assert.expect(expectedObjects.length + 2);
    const school = context.server.create('school', { title: 'first' });
    const mockUser = EmberObject.create({
      school: resolve(school)
    });

    const currentUserMock = Service.extend({
      model: resolve(mockUser)
    });
    context.owner.register('service:current-user', currentUserMock);
    context.set('close', ()=>{});
    await render(hbs`{{new-myreport close=(action close)}}`);

    const subject = `[data-test-subject] select`;
    const object = `[data-test-object] select`;
    await fillIn('[data-test-school] select', 'null');
    const subjectSelect = find(subject);
    assert.equal(subjectSelect.options[subjectNum].value, subjectVal);
    await fillIn(subjectSelect, subjectVal);

    const objectSelect = find(object);
    assert.equal(objectSelect.options[0].value, '');
    expectedObjects.forEach((val, i) => {
      assert.equal(objectSelect.options[i + 1].value, val, `${val} is object option`);
    });
  };
  test('save with date range and a zero duration', async function(assert) {
    assert.expect(2);
    const school = this.server.create('school');
    const program = this.server.create('program', { school });
    const report = this.server.create('curriculum-inventory-report', {
      year: '2016',
      program,
    });

    const reportModel = await run(() => this.owner.lookup('service:store').find('curriculum-inventory-report', report.id));
    this.set('report', reportModel);

    this.set('saveBlock', () => {
      return resolve();
    });
    await render(hbs`{{new-curriculum-inventory-sequence-block report=report save=(action saveBlock)}}`);
    await fillIn('.title input', 'Foo Bar');
    await fillIn('.description textarea', 'Lorem Ipsum');
    let startDateInput = find('.start-date input');
    let endDateInput = find('.end-date input');
    let interactor = openDatepicker(startDateInput);
    interactor.selectDate(moment('2016-11-12').toDate());
    interactor = openDatepicker(endDateInput);
    interactor.selectDate(moment('2016-12-30').toDate());
    await fillIn('.duration input', '0');
    await click('button.done');

    const blocks = await run(() => this.owner.lookup('service:store').findAll('curriculum-inventory-sequence-block'));
    assert.equal(blocks.length, 1);
    const newBlock = blocks.objectAt(0);
    assert.equal(newBlock.duration, 0, 'correcrt duration.');

  });
  test('selecting course reveals additional course info', async function(assert) {
    assert.expect(4);

    const school = this.server.create('school');
    const clerkshipType = this.server.create('course-clerkship-type');
    const course = this.server.create('course', {
      school,
      year: '2016',
      published: true,
      title: 'my fancy course',
      clerkshipType,
    });
    const program = this.server.create('program', { school });
    const report = this.server.create('curriculum-inventory-report', {
      year: '2016',
      program,
    });

    const reportModel = await run(() => this.owner.lookup('service:store').find('curriculum-inventory-report', report.id));

    this.set('report', reportModel);
    await render(hbs`{{new-curriculum-inventory-sequence-block report=report}}`);
    await fillIn('.course select', course.id);

    let details = find('.course .details').textContent.trim();
    assert.ok(details.includes('Level: ' + course.level));
    assert.ok(details.includes('Start Date: ' + moment(course.startDate).format('YYYY-MM-DD')));
    assert.ok(details.includes('End Date: ' + moment(course.endDate).format('YYYY-MM-DD')));
    assert.ok(details.includes('Clerkship (' + clerkshipType.title + ')'));
  });
  test('save fails on invalid duration', async function(assert) {
    assert.expect(2);
    const school = this.server.create('school');
    const program = this.server.create('program', { school });
    const report = this.server.create('curriculum-inventory-report', {
      year: '2016',
      program,
    });

    const reportModel = await run(() => this.owner.lookup('service:store').find('curriculum-inventory-report', report.id));
    this.set('report', reportModel);
    await render(hbs`{{new-curriculum-inventory-sequence-block report=report}}`);
    await fillIn('.title input', 'Foo Bar');
    await fillIn('.description textarea', 'Lorem Ipsum');
    let startDateInput = find('.start-date input');
    let endDateInput = find('.end-date input');
    let interactor = openDatepicker(startDateInput);
    interactor.selectDate(moment('2016-11-12').toDate());
    interactor = openDatepicker(endDateInput);
    interactor.selectDate(moment('2016-12-30').toDate());
    assert.dom('.validation-error-message').doesNotExist('Initially, no validation error is shown.');
    await fillIn('.duration input', 'WRONG');
    await click('button.done');
    assert.dom('.validation-error-message').exists({ count: 1 }, 'Validation error shows.');
  });
Ejemplo n.º 16
0
 test('it supports `effect` attribute', async function(assert) {
   await render(hbs`{{swiper-container id="swp-container" effect="fade"}}`);
   assert.ok(
     find('#swp-container.swiper-container-fade'),
     'Container has `fade` class'
   );
 });
 test('updates value if one radio button is clicked', async function(assert) {
   this.set('value', null);
   this.set('widgetAttrs', mockWidgetAttrs());
   await render(hbs `{{fm-widgets/radio-group value=value widgetAttrs=widgetAttrs}}`);
   this.$('input')[0].click();
   assert.equal(this.get('value'), 1);
 });
 test('checks the radio button which value property in content array matches value', async function(assert) {
   this.set('value', 2);
   this.set('widgetAttrs', mockWidgetAttrs());
   await render(hbs `{{fm-widgets/radio-group value=value widgetAttrs=widgetAttrs}}`);
   assert.notOk(this.$('input')[0].checked);
   assert.ok(this.$('input')[1].checked);
 });
Ejemplo n.º 19
0
  test('it provides the correct information', async function(assert) {
    const categoryData = [{ name: 'Compliance', value: 60 }, { name: 'Ownership', value: 40 }];
    const severityData = [
      { name: 'Minor', value: 50, customColorClass: 'severity-chart__bar--minor' },
      { name: 'Warning', value: 30, customColorClass: 'severity-chart__bar--warning' },
      { name: 'Critical', value: 25, customColorClass: 'severity-chart__bar--critical' }
    ];

    this.setProperties({
      categoryData,
      severityData
    });

    await render(hbs`{{datasets/health/metrics-charts
                      isActiveTab=true
                      categoryData=categoryData
                      severityData=severityData}}`);

    assert.ok(this.$(), 'Still renders without errors');
    assert.equal(findAll(chartClass).length, 2, 'Renders 2 charts');
    assert.equal(
      this.$(`${labelValueClass}:eq(0)`)
        .text()
        .trim(),
      '60%',
      'Renders correct value for labels'
    );
  });
Ejemplo n.º 20
0
    return settled().then(async () => {
      run(() => {
        parent = this.store.peekAll('job').findBy('plainId', 'parent');
      });

      this.setProperties(props(parent));

      await render(hbs`
        {{job-page/parts/children
          job=job
          sortProperty=sortProperty
          sortDescending=sortDescending
          currentPage=currentPage
          gotoJob=gotoJob}}
      `);

      return settled().then(() => {
        const childrenCount = parent.get('children.length');
        assert.ok(childrenCount > 10, 'Parent has more children than one page size');
        assert.equal(findAll('[data-test-job-name]').length, 10, 'Table length maxes out at 10');
        assert.ok(find('.pagination-next'), 'Next button is rendered');

        assert.ok(
          new RegExp(`1.10.+?${childrenCount}`).test(find('.pagination-numbers').textContent.trim())
        );
      });
    });
Ejemplo n.º 21
0
  test('row selection - click to modify selection', async function(assert) {
    this.set('table', new Table(Columns, this.server.createList('user', 5)));

    await render(
      hbs `{{lt-body table=table sharedOptions=sharedOptions canSelect=true multiSelect=true multiSelectRequiresKeyboard=false}}`
    );

    let firstRow = find('tr:first-child');
    let middleRow = find('tr:nth-child(4)');
    let lastRow = find('tr:last-child');

    assert.equal(findAll('tbody > tr').length, 5);

    await click(firstRow);
    assert.equal(findAll('tr.is-selected').length, 1, 'clicking a row selects it');

    await click(lastRow, { shiftKey: true });
    assert.equal(findAll('tr.is-selected').length, 5, 'shift-clicking another row selects it and all rows between');

    await click(middleRow);
    assert.equal(findAll('tr.is-selected').length, 4, 'clicking a selected row deselects it without affecting other selected rows');

    await click(middleRow);
    assert.equal(findAll('tr.is-selected').length, 5, 'clicking a deselected row selects it without affecting other selected rows');
  });
Ejemplo n.º 22
0
  test('row expansion', async function(assert) {
    this.set('table', new Table(Columns, this.server.createList('user', 2)));
    this.set('canExpand', false);

    await render(hbs `
      {{#lt-body table=table sharedOptions=sharedOptions canSelect=false canExpand=canExpand multiRowExpansion=false as |b|}}
        {{#b.expanded-row}} Hello {{/b.expanded-row}}
      {{/lt-body}}
    `);

    let row = find('tr');

    assert.notOk(hasClass(row, 'is-expandable'));
    await click(row);
    assert.equal(findAll('tr.lt-expanded-row').length, 0);
    assert.equal(findAll('tbody > tr').length, 2);
    assert.notOk(find('tr.lt-expanded-row'));

    this.set('canExpand', true);

    assert.ok(hasClass(row, 'is-expandable'));
    await click(row);
    assert.equal(findAll('tr.lt-expanded-row').length, 1);
    assert.equal(findAll('tbody > tr').length, 3);
    assert.equal(row.nextElementSibling.textContent.trim(), 'Hello');

    let allRows = findAll('tr');
    row = allRows[allRows.length - 1];
    assert.ok(hasClass(row, 'is-expandable'));
    await click(row);
    assert.equal(findAll('tr.lt-expanded-row').length, 1);
    assert.equal(findAll('tbody > tr').length, 3);
    assert.equal(row.nextElementSibling.textContent.trim(), 'Hello');
  });
  test('order-in-sequence options are visible for ordered parent sequence block', async function(assert) {
    assert.expect(24);
    const school = this.server.create('school');

    const program = this.server.create('program', { school });
    const report = this.server.create('curriculum-inventory-report', {
      year: '2016',
      program,
    });
    const parent = this.server.create('curriculum-inventory-sequence-block', {
      childSequenceOrder: 1,
      report
    });
    this.server.createList('curriculum-inventory-sequence-block', 10, {
      report,
      parent
    });

    const reportModel = await run(() => this.owner.lookup('service:store').find('curriculum-inventory-report', report.id));
    const parentModel = await run(() => this.owner.lookup('service:store').find('curriculum-inventory-sequence-block', parent.id));

    this.set('report', reportModel);
    this.set('parentBlock', parentModel);
    await render(hbs`{{new-curriculum-inventory-sequence-block report=report parent=parentBlock}}`);

    assert.dom(`.order-in-sequence label`).hasText('Order in Sequence:', 'Order in sequence label is correct');
    assert.dom(`.order-in-sequence option`).exists({ count: 11 }, 'Correct number of order in sequence options');
    for (let i = 1; i <= 11; i++) {
      assert.dom(`.order-in-sequence option:nth-of-type(${i})`).hasValue(i.toString(), 'Order in sequence option value is correct');
      assert.dom(`.order-in-sequence option:nth-of-type(${i})`).hasText(i.toString(), 'Order in sequence option label is correct');
    }
  });
Ejemplo n.º 24
0
  test('it supports manual swiper initialization when `init` event configured', async function(assert) {
    this.set('componentInstance', null);
    this.actions.onInit = () => assert.ok(true, 'invoked init handler');

    await render(hbs`
      {{swiper-container registerAs=componentInstance events=(hash init=(action "onInit"))}}`);
  });
  test('clear dates', async function(assert) {
    assert.expect(4);
    const newStartDate = moment('2016-01-12');
    const newEndDate = moment('2017-02-22');

    const school = this.server.create('school');
    const program = this.server.create('program', { school });
    const report = this.server.create('curriculum-inventory-report', {
      year: '2016',
      program,
    });

    const reportModel = await run(() => this.owner.lookup('service:store').find('curriculum-inventory-report', report.id));
    this.set('report', reportModel);

    await render(hbs`{{new-curriculum-inventory-sequence-block report=report}}`);
    let startDateInput = find('.start-date input');
    let endDateInput = find('.end-date input');
    let interactor = openDatepicker(startDateInput);
    interactor.selectDate(newStartDate.toDate());
    interactor = openDatepicker(endDateInput);
    interactor.selectDate(newEndDate.toDate());
    assert.equal(newStartDate.format('M/D/YYYY'), startDateInput.value, 'Start date is set');
    assert.equal(newEndDate.format('M/D/YYYY'), endDateInput.value, 'End date is set');
    await click('.clear-dates button');
    assert.equal(startDateInput.value, '', 'Start date input has been cleared.');
    assert.equal(endDateInput.value, '', 'End date input has been cleared.');
  });
Ejemplo n.º 26
0
  test('it triggers `autoplay` with custom `currentSlide`', async function(assert) {
    let run = false;

    this.actions.onAutoplay = () => {
      if (run) {
        return true;
      }

      let lastSlide = Array.from(findAll('.swiper-slide')).pop();

      assert.ok(
        lastSlide && lastSlide.classList.contains('swiper-slide-active'),
        'set slide at index 2 to active'
      );

      run = true;
    };

    await render(hbs`
      {{#swiper-container autoplay=(hash delay=10) currentSlide=1 events=(hash
        autoplay=(action "onAutoplay")) as |sc|}}
        {{swiper-slide}}
        {{swiper-slide}}
        {{swiper-slide}}
      {{/swiper-container}}
    `);
  });
  test('save with non-zero duration and no date range', async function(assert) {
    assert.expect(2);
    const school = this.server.create('school');
    const program = this.server.create('program', { school });
    const report = this.server.create('curriculum-inventory-report', {
      year: '2016',
      program,
    });
    const duration = 10;
    const reportModel = await run(() => this.owner.lookup('service:store').find('curriculum-inventory-report', report.id));
    this.set('report', reportModel);
    this.set('saveBlock', () => {
      return resolve();
    });
    await render(hbs`{{new-curriculum-inventory-sequence-block report=report save=(action saveBlock)}}`);
    await fillIn('.title input', 'Foo Bar');
    await fillIn('.description textarea', 'Lorem Ipsum');
    await fillIn('.duration input', duration);
    await click('button.done');

    const blocks = await run(() => this.owner.lookup('service:store').findAll('curriculum-inventory-sequence-block'));
    assert.equal(blocks.length, 1);
    const newBlock = blocks.objectAt(0);
    assert.equal(newBlock.duration, duration, 'correct duration.');
  });
Ejemplo n.º 28
0
const renderIt = async (context, path = 'jwt') => {
  let handler = (data, e) => {
    if (e && e.preventDefault) e.preventDefault();
  };
  let fake = fakeWindow.create();
  sinon.spy(fake, 'open');
  context.set('window', fake);
  context.set('handler', sinon.spy(handler));
  context.set('roleName', '');
  context.set('selectedAuthPath', path);

  await render(hbs`
    <AuthJwt
      @window={{window}}
      @roleName={{roleName}}
      @selectedAuthPath={{selectedAuthPath}}
      @onError={{action (mut error)}}
      @onLoading={{action (mut isLoading)}}
      @onToken={{action (mut token)}}
      @onNamespace={{action (mut namespace)}}
      @onSelectedAuth={{action (mut selectedAuth)}}
      @onSubmit={{action handler}}
      @onRoleName={{action (mut roleName)}}
    />
    `);
};
Ejemplo n.º 29
0
  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);
  });
Ejemplo n.º 30
0
  test('it removes all `slideChangeTransitionEnd` handlers when component element destroyed', async function(assert) {
    this.set('componentInstance', null);
    this.set('rendered', true);

    await render(
      hbs`{{#if rendered}}{{swiper-container registerAs=componentInstance}}{{/if}}`
    );

    let componentInstance = this.get('componentInstance');
    let swiperInstance = componentInstance._swiper;
    let originalDestroy = swiperInstance.destroy;
    let originalSwiperOff = swiperInstance.off;

    swiperInstance.off = (evt, ...args) => {
      if (evt === 'slideChangeTransitionEnd') {
        assert.ok(true, 'slideChangeTransitionEnd');
      }
      originalSwiperOff.apply(swiperInstance, [evt, ...args]);
    };

    swiperInstance.destroy = (...args) => {
      swiperInstance.off = originalSwiperOff;
      swiperInstance.destroy = originalDestroy;
      originalDestroy.apply(swiperInstance, ...args);
    };

    this.set('rendered', false); // trigger swipper destroy
  });