How to use the ember-qunit.moduleFor 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 Flexberry / ember-flexberry-designer / tests / unit / routes / fd-listform-constructor.js View on Github external
import { moduleFor, test } from 'ember-qunit';

moduleFor('route:fd-listform-constructor', 'Unit | Route | fd-listform-constructor', {
  // Specify the other units that are required for this test.
  // needs: ['controller:foo']
});

test('it exists', function(assert) {
  let route = this.subject();
  assert.ok(route);
});
github CenterForOpenScience / ember-osf / tests / unit / mixins / analytics.js View on Github external
import Ember from 'ember';
import AnalyticsMixin from 'ember-osf/mixins/analytics';
import { moduleFor, test } from 'ember-qunit';
const { getOwner } = Ember;

const service = Ember.Service.extend({
    props: null,
    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');
github CenterForOpenScience / ember-osf-web / tests / unit / mixins / analytics.js View on Github external
import Ember from 'ember';
import AnalyticsMixin from 'ember-osf-web/mixins/analytics';
import { moduleFor, test } from 'ember-qunit';

const { getOwner } = Ember;

const service = Ember.Service.extend({
    props: null,
    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'));
github fossasia / open-event-frontend / tests / helpers / unit-helper.js View on Github external
export default function(what, name, needs = [], testCase = null) {
  const defaultNeeds = ['service:metrics', 'ember-metrics@metrics-adapter:google-analytics', 'service:session', 'service:notify', 'service:router-scroll'];
  moduleFor(what, name, {
    needs: defaultNeeds.concat(needs)
  });

  if (testCase) {
    test('it exists', testCase);
  }
}
github aptible / dashboard.aptible.com / tests / unit / adapters / app-adapter.js View on Github external
import {
  test,
  moduleFor
} from 'ember-qunit';
import Ember from "ember";
import { stubRequest } from 'ember-cli-fake-server';
import modelDeps from '../../support/common-model-dependencies';

var store;

moduleFor('adapter:app', 'AppAdapter', {
  needs: modelDeps.concat([
    'store:application',
    'serializer:application'
  ]),
  setup: function(){
    store = this.container.lookup('store:application');
  }
});

test('findQuery uses correct URL', function(assert) {
  var done = assert.async();
  assert.expect(1);

  stubRequest('get', '/accounts/my-stack-1/databases', function() {
    assert.ok(true, 'uses correct URL');
    done();
github DefinitelyTyped / DefinitelyTyped / types / ember-qunit / ember-qunit-tests.ts View on Github external
import { test, skip, moduleFor, moduleForModel, moduleForComponent, setResolver } from 'ember-qunit';

moduleForComponent('x-foo', {
    integration: true
});

moduleForComponent('x-foo', {
    unit: true,
    needs: ['helper:pluralize-string']
});

moduleForModel('user', {
    needs: ['model:child']
});

moduleFor('controller:home');

moduleFor('component:x-foo', 'Some description');

moduleFor('component:x-foo', 'TestModule callbacks', {
    beforeSetup() {
    },

    beforeEach(assert) {
        this.registry.register('helper:i18n', {});
        this.register('service:i18n', {});
        this.inject.service('i18n');
        this.inject.service('i18n', { as: 'i18n' });
        this.factory('object:user').create();
        assert.ok(true);
    },
github softlayer / sl-ember-store / test-support / helpers / module-for-sl-ember-model.js View on Github external
export default function moduleForSlEmberModel(name, description, callbacks) {

    moduleFor('model:' + name, description, callbacks, function(container, context, defaultSubject) {

        container.register('store:main', SlEmberModelStore );

        context.__setup_properties__.store = function(){
            return container.lookup('store:main');
        };

        if (context.__setup_properties__.subject === defaultSubject) {
            context.__setup_properties__.subject = function(options) {
                return Ember.run(function() {
                    return container.lookup('store:main').createRecord(name, options);
                });
            };
        }
    });
}
github ember-intl / ember-intl / tests / unit / utils / macros.js View on Github external
import Ember from 'ember';
import { moduleFor, test } from 'ember-qunit';
import { translationMacro as t } from 'ember-intl';

moduleFor('service:intl', 'Unit | Macrol', {
  integration: true,
  beforeEach() {
    const intl = this.subject();
    intl.setLocale('en');

    this.object = Ember.Object
      .extend({
        intl: intl,
        numberClicks: 9,
        tMacroProperty1: t('no.interpolations'),
        tMacroProperty2: t('with.interpolations', { clicks: 'numberClicks' })
      })
      .create();
  }
});
github DefinitelyTyped / DefinitelyTyped / types / ember-qunit / v3 / ember-qunit-tests.ts View on Github external
moduleForComponent('x-foo', {
    integration: true
});

moduleForComponent('x-foo', {
    unit: true,
    needs: ['helper:pluralize-string']
});

moduleForModel('user', {
    needs: ['model:child']
});

moduleFor('controller:home');

moduleFor('component:x-foo', 'Some description');

moduleFor('component:x-foo', 'TestModule callbacks', {
    beforeSetup() {
    },

    beforeEach(assert) {
        this.registry.register('helper:i18n', {});
        this.register('service:i18n', {});
        this.inject.service('i18n');
        this.inject.service('i18n', { as: 'i18n' });
        this.factory('object:user').create();
        assert.ok(true);
    },

    afterEach(assert) {
        assert.ok(true);
github DefinitelyTyped / DefinitelyTyped / types / ember-qunit / ember-qunit-tests.ts View on Github external
});

moduleForComponent('x-foo', {
    unit: true,
    needs: ['helper:pluralize-string']
});

moduleForModel('user', {
    needs: ['model:child']
});

moduleFor('controller:home');

moduleFor('component:x-foo', 'Some description');

moduleFor('component:x-foo', 'TestModule callbacks', {
    beforeSetup() {
    },

    beforeEach(assert) {
        this.registry.register('helper:i18n', {});
        this.register('service:i18n', {});
        this.inject.service('i18n');
        this.inject.service('i18n', { as: 'i18n' });
        this.factory('object:user').create();
        assert.ok(true);
    },

    afterEach(assert) {
        assert.ok(true);
    },