How to use the ember-test-helpers/test-module.extend function in ember-test-helpers

To help you get started, we’ve selected a few ember-test-helpers 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 adopted-ember-addons / ember-collection / tests / helpers / module-for-view.js View on Github external
import { deprecate } from '@ember/application/deprecations';
import { tryInvoke } from '@ember/utils';
import { run } from '@ember/runloop';
import { merge } from '@ember/polyfills';
import Ember from 'ember';
import TestModule from 'ember-test-helpers/test-module';
import { getResolver } from 'ember-test-helpers/test-resolver';
import { createModule } from 'ember-qunit/qunit-module';

var TestModuleForView = TestModule.extend({
  init: function(viewName, description, callbacks) {
    this.viewName = viewName;
    this._super.call(this, 'component:' + viewName, description, callbacks);
    this.setupSteps.push(this.setupView);
  },
  initNeeds: function() {
    this.needs = [];
    // toplevel refers to class extended from Ember.View
    if (this.subjectName !== 'component:toplevel') {
      this.needs.push(this.subjectName);
    }
    if (this.callbacks.needs) {
      this.needs = this.needs.concat(this.callbacks.needs);
      delete this.callbacks.needs;
    }
  },