How to use the ember-qunit.test function in ember-qunit

To help you get started, we’ve selected a few ember-qunit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github emberjs / ember.js / node-tests / fixtures / helper-test / integration.js View on Github external
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';

moduleForComponent('foo/bar-baz', 'helper:foo/bar-baz', {
  integration: true
});

// Replace this with your real tests.
test('it renders', function(assert) {
  this.set('inputValue', '1234');

  this.render(hbs`{{foo/bar-baz inputValue}}`);

  assert.equal(this.$().text().trim(), '1234');
});
github sukima / ember-cli-select-picker / tests / common / select-picker.js View on Github external
'contentList should not be filtered when searchFilter is cleared'
    );

    Ember.run(function() {
      component.set('searchFilter', 'itm');
    });

    // When search is set to normal (not advanced), searching for 'itm' should
    // give 0 results
    assert.equal(
      component.get('contentList.length'), 0,
      'contentList should be filtered to no results for "itm"'
    );
  });

  test('Advanced Search (multiple)', function(assert) {
    assert.expect(2);

    var component = this.subject({
      multiple: true,
      liveSearch: 'advanced',
      content: contentArray,
      selection: Ember.A(),
      optionValuePath: 'content.id',
      optionLabelPath: 'content.name'
    });

    assert.equal(
      component.get('contentList.length'), contentArray.length,
      'contentList should not be filtered initially'
    );
github DefinitelyTyped / DefinitelyTyped / types / ember-qunit / ember-qunit-tests.ts View on Github external
// render the component
    this.render(hbs`
        {{ x-foo value=value action="result" }}
    `);
    this.render('{{ x-foo value=value action="result" }}');
    this.render([
        '{{ x-foo value=value action="result" }}'
    ]);

    assert.equal(this.$('div>.value').text(), 'cat', 'The component shows the correct value');

    this.$('button').click();
});

test('it renders', function(assert) {
    assert.expect(1);

    // creates the component instance
    const subject = this.subject();

    const subject2 = this.subject({
        item: 42
    });

    const { inputFormat } = this.setProperties({
        inputFormat: 'M/D/YY',
        outputFormat: 'MMMM D, YYYY',
        date: '5/3/10'
    });

    const { inputFormat: if2, outputFormat } = this.getProperties('inputFormat', 'outputFormat');
github ember-codemods / ember-test-helpers-codemod / transforms / native-dom / __testfixtures__ / integration.input.js View on Github external
blur,
  triggerEvent,
  keyEvent,
  scrollTo,
  selectFiles,
  waitFor,
  waitUntil,
} from 'ember-native-dom-helpers';
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';

moduleForComponent('foo-bar', 'Integration | Component | foo bar', {
  integration: true
});

test('it renders', async function(assert) {
  this.render(hbs`{{foo-bar}}`);

  await click('.foo', {});
  assert.equal(find('.foo').id, 'foo');
  await fillIn('.foo input', 'bar');
  await blur('.foo input');
  assert.equal(find('.foo').textContent.trim(), 'foo');
});

test('it renders again', function(assert) {
  this.render(hbs`{{foo-bar}}`);

  let selector = '.foo input';
  assert.equal(findAll(selector).length, 1);
  assert.equal(find(selector).value, 'foo');
  assert.ok(find('.foo').classList.contains('selected'));
github fossasia / open-event-frontend / tests / helpers / component-helper.js View on Github external
beforeEach() {
      this.register('service:routing', routingStub);
      this.inject.service('routing', { as: 'routing' });
      this.register('service:l10n', L10n);
      this.inject.service('l10n', { as: 'l10n' });
      this.application = startApp();
      l10nTestHelper(this);
    },

    afterEach() {
      destroyApp(this.application);
    }
  });

  if (testCase) {
    test('it renders', testCase);
  }
}
github jpadilla / ember-simple-auth-token / tests / unit / configuration.js View on Github external
}
});

test('serverTokenEndpoint', assert => {
  assert.equal(Configuration.serverTokenEndpoint, '/api/token-auth/', 'defaults to "/api/token-auth/"');
});

test('identificationField', assert => {
  assert.equal(Configuration.identificationField, 'username', 'defaults to "username"');
});

test('tokenPropertyName', assert => {
  assert.equal(Configuration.tokenPropertyName, 'token', 'defaults to "token"');
});

test('authorizationPrefix', assert => {
  assert.equal(Configuration.authorizationPrefix, 'Bearer ', 'defaults to "Bearer "');
});

test('authorizationHeaderName', assert => {
  assert.equal(Configuration.authorizationHeaderName, 'Authorization', 'defaults to "Authorization"');
});

test('serverTokenRefreshEndpoint', assert => {
  assert.equal(Configuration.serverTokenRefreshEndpoint, '/api/token-refresh/', 'defaults to "/api/token-refresh/"');
});

test('refreshAccessTokens', assert => {
  assert.equal(Configuration.refreshAccessTokens, true, 'defaults to true');
});

test('refreshLeeway', assert => {
github danielspaniel / ember-data-factory-guy / tests / unit / shared-factory-guy-behaviour.js View on Github external
assert.equal(cat.get('friend'), 'Friend 1');
  });

  test("with model that has primaryKey defined in serializer ( FactoryGuy sets id value )", function(assert) {
    let cat = make('cat');

    assert.equal(cat.get('id'), 1);
  });

  test("with model that has primaryKey defined in serializer ( user sets id value )", function(assert) {
    let cat = make('cat', {catId: 'meow1'});

    assert.equal(cat.get('id'), 'meow1');
  });

  test("with model that has primaryKey defined in serializer and is attribute ( value set in fixture )", function(assert) {
    let dog = make('dog');

    assert.equal(dog.get('id'), 'Dog1', 'primary key comes from dogNumber');
    assert.equal(dog.get('dogNumber'), 'Dog1', 'attribute has the primary key value as well');
  });

  test("with fixture options", function(assert) {
    let profile = make('profile', {description: 'dude'});
    assert.ok(profile.get('description') === 'dude');
  });

  test("with attributes in traits", function(assert) {
    let profile = make('profile', 'goofy_description');
    assert.ok(profile.get('description') === 'goofy');
  });
github ember-codemods / ember-test-helpers-codemod / transforms / integration / __testfixtures__ / jq-extensions.input.js View on Github external
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
import ANY_SELECTOR_AS_IMPORTED_CONST from './constants';

const JQEXTENSION_SELECTOR_AS_LOCAL_CONST = '.foo:first';
const NORMAL_SELECTOR = '.foo';
const NORMAL_PSEUDO_SELECTOR = '.foo:eq(0)';

moduleForComponent('foo-bar', 'Integration | Component | foo bar', {
  integration: true
});

test('it renders', function(assert) {
  this.render(hbs`{{foo-bar}}`);

  assert.ok(this.$('.foo:even').length);
  assert.ok(this.$('.foo:odd').length);
  assert.ok(this.$('.foo:contains(foo)').length);
  assert.ok(this.$('.foo:has(p)').length);
  assert.ok(this.$('.foo:animated').length);
  assert.ok(this.$('.foo:checkbox').length);
  assert.ok(this.$('.foo:file').length);
  assert.ok(this.$('.foo:first').length);
  assert.ok(this.$('.foo:gt(2)').length);
  assert.ok(this.$('.foo:header').length);
  assert.ok(this.$('.foo:hidden').length);
  assert.ok(this.$('.foo:image').length);
  assert.ok(this.$('.foo:input').length);
  assert.ok(this.$('.foo:last').length);
github ember-codemods / ember-test-helpers-codemod / transforms / integration / __testfixtures__ / click.input.js View on Github external
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';

moduleForComponent('foo-bar', 'Integration | Component | foo bar', {
  integration: true
});

test('it renders', function(assert) {
  this.render(hbs`{{foo-bar}}`);

  this.$('.foo').click();
  this.$('.baz a:eq(0)').click();
  this.$('.foo .bar:eq(3)').click();
  assert.ok(true);
});
github CenterForOpenScience / ember-osf / tests / unit / mixins / analytics.js View on Github external
trackEvent(...args) {
        this.set('props', [...args]);
    }
});

moduleFor('mixin:analytics', {
    subject(){
        this.register('service:metrics', service);
        this.inject.service('metrics');
        const analyticsObject = Ember.Controller.extend(AnalyticsMixin);
        this.registry.register('test:subject', analyticsObject);
        return getOwner(this).lookup('test:subject');
    }
});

test("Google Analytics mixin", function(assert) {

    const subject = this.subject();
    assert.ok(AnalyticsMixin.detect(subject));

    Ember.run(() => {
        subject.send('click', 'test category', 'test label');
        assert.ok(subject.get('metrics.props'));
        subject.send('track', 'test category', 'test label');
        assert.ok(subject.get('metrics.props'));
    });
});