Socket
Socket
Sign inDemoInstall

ember-test-helpers

Package Overview
Dependencies
Maintainers
4
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-test-helpers - npm Package Compare versions

Comparing version 0.5.34 to 0.6.0-beta.1

48

lib/ember-test-helpers/abstract-test-module.js

@@ -1,2 +0,1 @@

import { Klass } from 'klassy';
import { _setupAJAXHooks, _teardownAJAXHooks } from './wait';

@@ -12,4 +11,4 @@ import { getContext, setContext, unsetContext } from './test-context';

export default Klass.extend({
init(name, options) {
export default class {
constructor(name, options) {
this.context = undefined;

@@ -21,3 +20,3 @@ this.name = name;

this.initTeardownSteps();
},
}

@@ -29,3 +28,3 @@ setup(assert) {

});
},
}

@@ -39,3 +38,3 @@ teardown(assert) {

});
},
}

@@ -59,3 +58,3 @@ initSetupSteps() {

}
},
}

@@ -77,7 +76,7 @@ invokeSteps(steps, context, assert) {

return nextStep();
},
}
contextualizeCallbacks() {
},
}

@@ -101,3 +100,3 @@ initTeardownSteps() {

}
},
}

@@ -115,3 +114,3 @@ setupTestElements() {

}
},
}

@@ -127,9 +126,10 @@ setupContext(options) {

this.setToString();
setContext(context);
this.context = context;
},
}
setContext(context) {
this.context = context;
},
}

@@ -140,11 +140,23 @@ getContext() {

return this.context = getContext() || {};
},
}
setToString() {
this.context.toString = () => {
if(this.subjectName) {
return `test context for: ${this.subjectName}`;
}
if(this.name) {
return `test context for: ${this.name}`;
}
};
}
setupAJAXListeners() {
_setupAJAXHooks();
},
}
teardownAJAXListeners() {
_teardownAJAXHooks();
},
}

@@ -159,3 +171,3 @@ teardownTestElements() {

}
},
}

@@ -173,2 +185,2 @@ teardownContext() {

}
});
}

@@ -44,3 +44,3 @@ /* globals global, self, requirejs, require */

var namespace = Ember.Object.create({
Resolver: { create: function() { return resolver; } }
Resolver: { create() { return resolver; } }
});

@@ -47,0 +47,0 @@

@@ -5,6 +5,6 @@ import AbstractTestModule from './abstract-test-module';

export default AbstractTestModule.extend({
export default class extends AbstractTestModule {
setupContext() {
this._super({ application: this.createApplication() });
},
super.setupContext({ application: this.createApplication() });
}

@@ -16,4 +16,4 @@ teardownContext() {

this._super();
},
super.teardownContext();
}

@@ -32,2 +32,2 @@ createApplication() {

}
});
}

@@ -13,8 +13,8 @@ import TestModule from './test-module';

const isPreGlimmer = !hasEmberVersion(1,13);
const { getOwner } = Ember;
export default TestModule.extend({
isComponentTestModule: true,
init: function(componentName, description, callbacks) {
export default class extends TestModule {
constructor(componentName, description, callbacks) {
// Allow `description` to be omitted

@@ -28,7 +28,11 @@ if (!callbacks && typeof description === 'object') {

let integrationOption = callbacks.integration;
super('component:' + componentName, description, callbacks);
this.componentName = componentName;
if (callbacks.needs || callbacks.unit || callbacks.integration === false) {
if (callbacks.needs || callbacks.unit || integrationOption === false) {
this.isUnitTest = true;
} else if (callbacks.integration) {
} else if (integrationOption) {
this.isUnitTest = false;

@@ -47,8 +51,2 @@ } else {

if (description) {
this._super.call(this, 'component:' + componentName, description, callbacks);
} else {
this._super.call(this, 'component:' + componentName, callbacks);
}
if (!this.isUnitTest && !this.isLegacy) {

@@ -72,5 +70,10 @@ callbacks.integration = true;

}
},
}
_aliasViewRegistry: function() {
initIntegration(options) {
this.isLegacy = (options.integration === 'legacy');
this.isIntegration = (options.integration !== 'legacy');
}
_aliasViewRegistry() {
this._originalGlobalViewRegistry = Ember.View.views;

@@ -82,9 +85,9 @@ var viewRegistry = this.container.lookup('-view-registry:main');

}
},
}
_resetViewRegistry: function() {
_resetViewRegistry() {
Ember.View.views = this._originalGlobalViewRegistry;
},
}
setupComponentUnitTest: function() {
setupComponentUnitTest() {
var _this = this;

@@ -112,3 +115,3 @@ var resolver = this.resolver;

Ember.run(function(){
Ember.run(function() {
subject = context.subject();

@@ -131,3 +134,3 @@ subject.appendTo('#ember-testing');

false,
{ id: 'ember-test-helpers.test-module-for-component.append', until: '0.6.0' }
{id: 'ember-test-helpers.test-module-for-component.append', until: '0.6.0'}
);

@@ -143,14 +146,14 @@ return context.$();

};
},
}
setupComponentIntegrationTest: (function() {
if (!hasEmberVersion(1,13)) {
return preGlimmerSetupIntegrationForComponent;
setupComponentIntegrationTest() {
if (isPreGlimmer) {
return preGlimmerSetupIntegrationForComponent.apply(this, arguments);
} else {
return setupComponentIntegrationTest;
return setupComponentIntegrationTest.apply(this, arguments);
}
})(),
}
setupContext: function() {
this._super.call(this);
setupContext() {
super.setupContext();

@@ -166,5 +169,5 @@ // only setup the injection if we are running against a version

}
},
}
teardownComponent: function() {
teardownComponent() {
var component = this.component;

@@ -176,3 +179,3 @@ if (component) {

}
});
}

@@ -179,0 +182,0 @@ export function setupComponentIntegrationTest() {

@@ -16,7 +16,9 @@ import Ember from 'ember';

export default AbstractTestModule.extend({
init() {
this._super(...arguments);
const isPreGlimmer = !hasEmberVersion(1,13);
export default class extends AbstractTestModule {
constructor() {
super(...arguments);
this.resolver = this.callbacks.resolver || getResolver();
},
}

@@ -46,3 +48,3 @@ initSetupSteps() {

}
},
}

@@ -73,3 +75,3 @@ initTeardownSteps() {

}
},
}

@@ -89,3 +91,3 @@ setupContainer() {

}
},
}

@@ -100,3 +102,3 @@ setupContext() {

this._super({
super.setupContext({
container: this.container,

@@ -134,13 +136,13 @@ registry: this.registry,

}
},
}
setupComponentIntegrationTest: (function() {
if (!hasEmberVersion(1,13)) {
return preGlimmerSetupIntegrationForComponent;
setupComponentIntegrationTest() {
if (isPreGlimmer) {
return preGlimmerSetupIntegrationForComponent.apply(this, arguments);
} else {
return setupComponentIntegrationTest;
return setupComponentIntegrationTest.apply(this, arguments);
}
})(),
}
teardownComponent: function() {
teardownComponent() {
var component = this.component;

@@ -152,3 +154,3 @@ if (component) {

}
},
}

@@ -160,3 +162,3 @@ teardownContainer() {

});
},
}

@@ -179,3 +181,3 @@ // allow arbitrary named factories, like rspec let

}
},
}

@@ -197,5 +199,5 @@ _contextualizeCallback(context, key, callbackContext) {

};
},
}
_aliasViewRegistry: function() {
_aliasViewRegistry() {
this._originalGlobalViewRegistry = Ember.View.views;

@@ -207,7 +209,7 @@ var viewRegistry = this.container.lookup('-view-registry:main');

}
},
}
_resetViewRegistry: function() {
_resetViewRegistry() {
Ember.View.views = this._originalGlobalViewRegistry;
}
});
}

@@ -6,12 +6,12 @@ /* global DS, require, requirejs */ // added here to prevent an import from erroring when ED is not present

export default TestModule.extend({
init: function(modelName, description, callbacks) {
export default class extends TestModule {
constructor(modelName, description, callbacks) {
super('model:' + modelName, description, callbacks);
this.modelName = modelName;
this._super.call(this, 'model:' + modelName, description, callbacks);
this.setupSteps.push(this.setupModel);
},
}
setupModel: function() {
setupModel() {
var container = this.container;

@@ -42,4 +42,3 @@ var defaultSubject = this.defaultSubject;

var container = this.container;
var store = container.lookup('service:store') || container.lookup('store:main');
return store;
return container.lookup('service:store') || container.lookup('store:main');
};

@@ -58,2 +57,2 @@

}
});
}

@@ -7,4 +7,4 @@ import Ember from 'ember';

export default AbstractTestModule.extend({
init: function(subjectName, description, callbacks) {
export default class extends AbstractTestModule {
constructor(subjectName, description, callbacks) {
// Allow `description` to be omitted, in which case it should

@@ -17,6 +17,6 @@ // default to `subjectName`

super(description || subjectName, callbacks);
this.subjectName = subjectName;
this.description = description || subjectName;
this.name = description || subjectName;
this.callbacks = callbacks || {};
this.resolver = this.callbacks.resolver || getResolver();

@@ -29,12 +29,3 @@

if (this.callbacks.integration) {
if (this.isComponentTestModule) {
this.isLegacy = (callbacks.integration === 'legacy');
this.isIntegration = (callbacks.integration !== 'legacy');
} else {
if (callbacks.integration === 'legacy') {
throw new Error('`integration: \'legacy\'` is only valid for component tests.');
}
this.isIntegration = true;
}
this.initIntegration(callbacks);
delete callbacks.integration;

@@ -45,11 +36,16 @@ }

this.initNeeds();
this.initSetupSteps();
this.initTeardownSteps();
},
}
initSubject: function() {
initIntegration(options) {
if (options.integration === 'legacy') {
throw new Error('`integration: \'legacy\'` is only valid for component tests.');
}
this.isIntegration = true;
}
initSubject() {
this.callbacks.subject = this.callbacks.subject || this.defaultSubject;
},
}
initNeeds: function() {
initNeeds() {
this.needs = [this.subjectName];

@@ -60,5 +56,5 @@ if (this.callbacks.needs) {

}
},
}
initSetupSteps: function() {
initSetupSteps() {
this.setupSteps = [];

@@ -81,5 +77,5 @@ this.contextualizedSetupSteps = [];

}
},
}
initTeardownSteps: function() {
initTeardownSteps() {
this.teardownSteps = [];

@@ -103,5 +99,5 @@ this.contextualizedTeardownSteps = [];

}
},
}
setupContainer: function() {
setupContainer() {
if (this.isIntegration || this.isLegacy) {

@@ -112,5 +108,5 @@ this._setupIntegratedContainer();

}
},
}
setupContext: function() {
setupContext() {
var subjectName = this.subjectName;

@@ -123,7 +119,7 @@ var container = this.container;

this._super({
super.setupContext({
container: this.container,
registry: this.registry,
factory: factory,
register: function() {
register() {
var target = this.registry || this.container;

@@ -139,5 +135,5 @@ return target.register.apply(target, arguments);

this.setupInject();
},
}
setupInject: function() {
setupInject() {
var module = this;

@@ -158,5 +154,5 @@ var context = this.context;

}
},
}
teardownSubject: function() {
teardownSubject() {
var subject = this.cache.subject;

@@ -169,5 +165,5 @@

}
},
}
teardownContainer: function() {
teardownContainer() {
var container = this.container;

@@ -177,10 +173,10 @@ Ember.run(function() {

});
},
}
defaultSubject: function(options, factory) {
defaultSubject(options, factory) {
return factory.create(options);
},
}
// allow arbitrary named factories, like rspec let
contextualizeCallbacks: function() {
contextualizeCallbacks() {
var callbacks = this.callbacks;

@@ -201,5 +197,5 @@ var context = this.context;

}
},
}
_contextualizeCallback: function(context, key, callbackContext) {
_contextualizeCallback(context, key, callbackContext) {
var _this = this;

@@ -219,3 +215,3 @@ var callbacks = this.callbacks;

};
},
}

@@ -226,3 +222,3 @@ /*

*/
_buildDeprecatedContext: function(module, context) {
_buildDeprecatedContext(module, context) {
var deprecatedContext = Object.create(context);

@@ -237,3 +233,3 @@

return deprecatedContext;
},
}

@@ -243,6 +239,6 @@ /*

*/
_proxyDeprecation: function(obj, proxy, key) {
_proxyDeprecation(obj, proxy, key) {
if (typeof proxy[key] === 'undefined') {
Object.defineProperty(proxy, key, {
get: function() {
get() {
Ember.deprecate('Accessing the test module property "' + key + '" from a callback is deprecated.', false, { id: 'ember-test-helpers.test-module.callback-context', until: '0.6.0' });

@@ -253,5 +249,5 @@ return obj[key];

}
},
}
_setupContainer: function(isolated) {
_setupContainer(isolated) {
var resolver = this.resolver;

@@ -261,3 +257,3 @@

resolve: {
value: function() {}
value() {}
}

@@ -275,5 +271,5 @@ }));

}
},
}
_setupIsolatedContainer: function() {
_setupIsolatedContainer() {
var resolver = this.resolver;

@@ -293,8 +289,8 @@ this._setupContainer(true);

}
},
}
_setupIntegratedContainer: function() {
_setupIntegratedContainer() {
this._setupContainer();
}
});
}
{
"name": "ember-test-helpers",
"version": "0.5.34",
"version": "0.6.0-beta.1",
"description": "Helpers for testing Ember.js applications",

@@ -35,5 +35,3 @@ "main": "lib/ember-test-helpers.js",

},
"dependencies": {
"klassy": "^0.1.3"
}
"dependencies": {}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc