2015-05-14 02:12:54 +08:00
|
|
|
(function() {
|
|
|
|
|
|
|
|
var define, requireModule, require, requirejs;
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
|
|
|
|
var _isArray;
|
|
|
|
if (!Array.isArray) {
|
|
|
|
_isArray = function (x) {
|
|
|
|
return Object.prototype.toString.call(x) === "[object Array]";
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
_isArray = Array.isArray;
|
2014-07-31 05:53:14 +08:00
|
|
|
}
|
2015-05-14 02:12:54 +08:00
|
|
|
|
|
|
|
var registry = {}, seen = {}, state = {};
|
|
|
|
var FAILED = false;
|
|
|
|
|
|
|
|
define = function(name, deps, callback) {
|
|
|
|
|
|
|
|
if (!_isArray(deps)) {
|
|
|
|
callback = deps;
|
|
|
|
deps = [];
|
2014-07-31 05:53:14 +08:00
|
|
|
}
|
2015-05-14 02:12:54 +08:00
|
|
|
|
|
|
|
registry[name] = {
|
|
|
|
deps: deps,
|
|
|
|
callback: callback
|
|
|
|
};
|
|
|
|
};
|
2014-07-31 05:53:14 +08:00
|
|
|
|
2015-05-14 02:12:54 +08:00
|
|
|
function reify(deps, name, seen) {
|
|
|
|
var length = deps.length;
|
|
|
|
var reified = new Array(length);
|
|
|
|
var dep;
|
|
|
|
var exports;
|
2014-07-31 05:53:14 +08:00
|
|
|
|
2015-05-14 02:12:54 +08:00
|
|
|
for (var i = 0, l = length; i < l; i++) {
|
|
|
|
dep = deps[i];
|
|
|
|
if (dep === 'exports') {
|
|
|
|
exports = reified[i] = seen;
|
|
|
|
} else {
|
|
|
|
reified[i] = require(resolve(dep, name));
|
|
|
|
}
|
|
|
|
}
|
2014-07-31 05:53:14 +08:00
|
|
|
|
2015-05-14 02:12:54 +08:00
|
|
|
return {
|
|
|
|
deps: reified,
|
|
|
|
exports: exports
|
2014-07-31 05:53:14 +08:00
|
|
|
};
|
2015-05-14 02:12:54 +08:00
|
|
|
}
|
2014-07-31 05:53:14 +08:00
|
|
|
|
2015-05-14 02:12:54 +08:00
|
|
|
requirejs = require = requireModule = function(name) {
|
|
|
|
if (state[name] !== FAILED &&
|
|
|
|
seen.hasOwnProperty(name)) {
|
|
|
|
return seen[name];
|
|
|
|
}
|
2014-07-31 05:53:14 +08:00
|
|
|
|
2015-05-14 02:12:54 +08:00
|
|
|
if (!registry[name]) {
|
|
|
|
throw new Error('Could not find module ' + name);
|
|
|
|
}
|
|
|
|
|
|
|
|
var mod = registry[name];
|
|
|
|
var reified;
|
|
|
|
var module;
|
|
|
|
var loaded = false;
|
|
|
|
|
|
|
|
seen[name] = { }; // placeholder for run-time cycles
|
|
|
|
|
|
|
|
try {
|
|
|
|
reified = reify(mod.deps, name, seen[name]);
|
|
|
|
module = mod.callback.apply(this, reified.deps);
|
|
|
|
loaded = true;
|
|
|
|
} finally {
|
|
|
|
if (!loaded) {
|
|
|
|
state[name] = FAILED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return reified.exports ? seen[name] : (seen[name] = module);
|
|
|
|
};
|
|
|
|
|
|
|
|
function resolve(child, name) {
|
|
|
|
if (child.charAt(0) !== '.') { return child; }
|
|
|
|
|
|
|
|
var parts = child.split('/');
|
|
|
|
var nameParts = name.split('/');
|
|
|
|
var parentBase;
|
|
|
|
|
|
|
|
if (nameParts.length === 1) {
|
|
|
|
parentBase = nameParts;
|
|
|
|
} else {
|
|
|
|
parentBase = nameParts.slice(0, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (var i = 0, l = parts.length; i < l; i++) {
|
|
|
|
var part = parts[i];
|
|
|
|
|
|
|
|
if (part === '..') { parentBase.pop(); }
|
|
|
|
else if (part === '.') { continue; }
|
|
|
|
else { parentBase.push(part); }
|
|
|
|
}
|
|
|
|
|
|
|
|
return parentBase.join('/');
|
|
|
|
}
|
|
|
|
|
|
|
|
requirejs.entries = requirejs._eak_seen = registry;
|
|
|
|
requirejs.clear = function(){
|
|
|
|
requirejs.entries = requirejs._eak_seen = registry = {};
|
|
|
|
seen = state = {};
|
|
|
|
};
|
|
|
|
})();
|
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
define('ember-qunit', ['exports', 'ember-qunit/module-for', 'ember-qunit/module-for-component', 'ember-qunit/module-for-model', 'ember-qunit/test', 'ember-qunit/only', 'ember-test-helpers'], function (exports, moduleFor, moduleForComponent, moduleForModel, test, only, ember_test_helpers) {
|
2015-05-14 02:12:54 +08:00
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
exports.moduleFor = moduleFor['default'];
|
|
|
|
exports.moduleForComponent = moduleForComponent['default'];
|
|
|
|
exports.moduleForModel = moduleForModel['default'];
|
|
|
|
exports.test = test['default'];
|
|
|
|
exports.only = only['default'];
|
|
|
|
exports.setResolver = ember_test_helpers.setResolver;
|
2015-05-14 02:12:54 +08:00
|
|
|
|
|
|
|
});
|
2016-12-16 05:43:38 +08:00
|
|
|
define('ember-qunit/module-for-component', ['exports', 'ember-qunit/qunit-module', 'ember-test-helpers'], function (exports, qunit_module, ember_test_helpers) {
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
'use strict';
|
2016-12-13 05:18:42 +08:00
|
|
|
|
2016-12-13 05:24:36 +08:00
|
|
|
function moduleForComponent(name, description, callbacks) {
|
2016-12-16 05:43:38 +08:00
|
|
|
qunit_module.createModule(ember_test_helpers.TestModuleForComponent, name, description, callbacks);
|
2016-12-13 05:24:36 +08:00
|
|
|
}
|
2016-12-16 05:43:38 +08:00
|
|
|
exports['default'] = moduleForComponent;
|
|
|
|
|
2015-05-14 02:12:54 +08:00
|
|
|
});
|
2016-12-16 05:43:38 +08:00
|
|
|
define('ember-qunit/module-for-model', ['exports', 'ember-qunit/qunit-module', 'ember-test-helpers'], function (exports, qunit_module, ember_test_helpers) {
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
'use strict';
|
2016-12-13 05:18:42 +08:00
|
|
|
|
2016-12-13 05:24:36 +08:00
|
|
|
function moduleForModel(name, description, callbacks) {
|
2016-12-16 05:43:38 +08:00
|
|
|
qunit_module.createModule(ember_test_helpers.TestModuleForModel, name, description, callbacks);
|
2016-12-13 05:24:36 +08:00
|
|
|
}
|
2016-12-16 05:43:38 +08:00
|
|
|
exports['default'] = moduleForModel;
|
|
|
|
|
2015-05-14 02:12:54 +08:00
|
|
|
});
|
2016-12-16 05:43:38 +08:00
|
|
|
define('ember-qunit/module-for', ['exports', 'ember-qunit/qunit-module', 'ember-test-helpers'], function (exports, qunit_module, ember_test_helpers) {
|
|
|
|
|
2015-05-14 02:12:54 +08:00
|
|
|
'use strict';
|
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
function moduleFor(name, description, callbacks) {
|
|
|
|
qunit_module.createModule(ember_test_helpers.TestModule, name, description, callbacks);
|
|
|
|
}
|
2015-05-14 02:12:54 +08:00
|
|
|
exports['default'] = moduleFor;
|
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
});
|
|
|
|
define('ember-qunit/only', ['exports', 'ember-qunit/test-wrapper', 'qunit'], function (exports, testWrapper, qunit) {
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
function only(/* testName, expected, callback, async */) {
|
|
|
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; ++_key) {
|
|
|
|
args[_key] = arguments[_key];
|
|
|
|
}
|
|
|
|
args.unshift(qunit.only);
|
|
|
|
testWrapper['default'].apply(null, args);
|
2016-11-09 03:29:50 +08:00
|
|
|
}
|
2016-12-16 05:43:38 +08:00
|
|
|
exports['default'] = only;
|
|
|
|
|
2015-05-14 02:12:54 +08:00
|
|
|
});
|
2016-12-16 05:43:38 +08:00
|
|
|
define('ember-qunit/qunit-module', ['exports', 'qunit'], function (exports, qunit) {
|
|
|
|
|
2015-05-14 02:12:54 +08:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
exports.createModule = createModule;
|
|
|
|
|
|
|
|
function beforeEachCallback(callbacks) {
|
2016-12-16 05:43:38 +08:00
|
|
|
if (typeof callbacks !== 'object') { return; }
|
|
|
|
if (!callbacks) { return; }
|
2015-05-14 02:12:54 +08:00
|
|
|
|
|
|
|
var beforeEach;
|
2016-11-09 03:29:50 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
if (callbacks.setup) {
|
|
|
|
beforeEach = callbacks.setup;
|
|
|
|
delete callbacks.setup;
|
|
|
|
}
|
|
|
|
|
2015-05-14 02:12:54 +08:00
|
|
|
if (callbacks.beforeEach) {
|
|
|
|
beforeEach = callbacks.beforeEach;
|
|
|
|
delete callbacks.beforeEach;
|
|
|
|
}
|
|
|
|
|
|
|
|
return beforeEach;
|
|
|
|
}
|
|
|
|
|
|
|
|
function afterEachCallback(callbacks) {
|
2016-12-16 05:43:38 +08:00
|
|
|
if (typeof callbacks !== 'object') { return; }
|
|
|
|
if (!callbacks) { return; }
|
2015-05-14 02:12:54 +08:00
|
|
|
|
|
|
|
var afterEach;
|
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
if (callbacks.teardown) {
|
|
|
|
afterEach = callbacks.teardown;
|
|
|
|
delete callbacks.teardown;
|
|
|
|
}
|
|
|
|
|
2015-05-14 02:12:54 +08:00
|
|
|
if (callbacks.afterEach) {
|
|
|
|
afterEach = callbacks.afterEach;
|
|
|
|
delete callbacks.afterEach;
|
|
|
|
}
|
|
|
|
|
|
|
|
return afterEach;
|
|
|
|
}
|
|
|
|
|
|
|
|
function createModule(Constructor, name, description, callbacks) {
|
2016-12-16 05:43:38 +08:00
|
|
|
var beforeEach = beforeEachCallback(callbacks || description);
|
|
|
|
var afterEach = afterEachCallback(callbacks || description);
|
2015-05-14 02:12:54 +08:00
|
|
|
|
|
|
|
var module = new Constructor(name, description, callbacks);
|
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
qunit.module(module.name, {
|
|
|
|
setup: function(assert) {
|
|
|
|
var done = assert.async();
|
|
|
|
return module.setup().then(function() {
|
|
|
|
if (beforeEach) {
|
|
|
|
beforeEach.call(module.context, assert);
|
2015-05-14 02:12:54 +08:00
|
|
|
}
|
2016-12-16 05:43:38 +08:00
|
|
|
})['finally'](done);
|
2015-05-14 02:12:54 +08:00
|
|
|
},
|
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
teardown: function(assert) {
|
|
|
|
if (afterEach) {
|
|
|
|
afterEach.call(module.context, assert);
|
2015-05-14 02:12:54 +08:00
|
|
|
}
|
2016-12-16 05:43:38 +08:00
|
|
|
var done = assert.async();
|
|
|
|
return module.teardown()['finally'](done);
|
2014-07-31 05:53:14 +08:00
|
|
|
}
|
2015-05-14 02:12:54 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
2016-12-16 05:43:38 +08:00
|
|
|
define('ember-qunit/test-wrapper', ['exports', 'ember', 'ember-test-helpers'], function (exports, Ember, ember_test_helpers) {
|
2015-05-14 02:12:54 +08:00
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
function testWrapper(qunit /*, testName, expected, callback, async */) {
|
|
|
|
var callback;
|
|
|
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; ++_key) {
|
|
|
|
args[_key - 1] = arguments[_key];
|
2016-11-09 03:42:10 +08:00
|
|
|
}
|
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
function wrapper() {
|
|
|
|
var context = ember_test_helpers.getContext();
|
2016-12-13 05:24:36 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
var result = callback.apply(context, arguments);
|
2016-12-13 05:24:36 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
function failTestOnPromiseRejection(reason) {
|
|
|
|
var message;
|
|
|
|
if (reason instanceof Error) {
|
|
|
|
message = reason.stack;
|
|
|
|
if (reason.message && message.indexOf(reason.message) < 0) {
|
|
|
|
// PhantomJS has a `stack` that does not contain the actual
|
|
|
|
// exception message.
|
|
|
|
message = Ember['default'].inspect(reason) + "\n" + message;
|
|
|
|
}
|
2015-05-14 02:12:54 +08:00
|
|
|
} else {
|
2016-12-16 05:43:38 +08:00
|
|
|
message = Ember['default'].inspect(reason);
|
2015-05-14 02:12:54 +08:00
|
|
|
}
|
2016-12-16 05:43:38 +08:00
|
|
|
ok(false, message);
|
2015-05-14 02:12:54 +08:00
|
|
|
}
|
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
Ember['default'].run(function(){
|
|
|
|
QUnit.stop();
|
|
|
|
Ember['default'].RSVP.Promise.resolve(result)['catch'](failTestOnPromiseRejection)['finally'](QUnit.start);
|
2015-05-14 02:12:54 +08:00
|
|
|
});
|
2016-12-16 05:43:38 +08:00
|
|
|
}
|
2016-12-02 03:04:22 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
if (args.length === 2) {
|
|
|
|
callback = args.splice(1, 1, wrapper)[0];
|
|
|
|
} else {
|
|
|
|
callback = args.splice(2, 1, wrapper)[0];
|
|
|
|
}
|
2016-12-02 03:04:22 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
qunit.apply(null, args);
|
|
|
|
}
|
|
|
|
exports['default'] = testWrapper;
|
2016-12-13 05:24:36 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
});
|
|
|
|
define('ember-qunit/test', ['exports', 'ember-qunit/test-wrapper', 'qunit'], function (exports, testWrapper, qunit) {
|
2016-12-13 05:24:36 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
'use strict';
|
2016-12-13 05:24:36 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
function test(/* testName, expected, callback, async */) {
|
|
|
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; ++_key) {
|
|
|
|
args[_key] = arguments[_key];
|
|
|
|
}
|
|
|
|
args.unshift(qunit.test);
|
|
|
|
testWrapper['default'].apply(null, args);
|
|
|
|
}
|
|
|
|
exports['default'] = test;
|
2016-12-13 05:24:36 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
});
|
|
|
|
define('ember-test-helpers', ['exports', 'ember', 'ember-test-helpers/test-module', 'ember-test-helpers/test-module-for-component', 'ember-test-helpers/test-module-for-model', 'ember-test-helpers/test-context', 'ember-test-helpers/test-resolver'], function (exports, Ember, TestModule, TestModuleForComponent, TestModuleForModel, test_context, test_resolver) {
|
2016-12-13 05:24:36 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
'use strict';
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
Ember['default'].testing = true;
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
exports.TestModule = TestModule['default'];
|
|
|
|
exports.TestModuleForComponent = TestModuleForComponent['default'];
|
|
|
|
exports.TestModuleForModel = TestModuleForModel['default'];
|
|
|
|
exports.getContext = test_context.getContext;
|
|
|
|
exports.setContext = test_context.setContext;
|
|
|
|
exports.setResolver = test_resolver.setResolver;
|
2015-05-14 02:12:54 +08:00
|
|
|
|
|
|
|
});
|
2016-12-16 05:43:38 +08:00
|
|
|
define('ember-test-helpers/build-registry', ['exports', 'ember'], function (exports, Ember) {
|
2015-05-14 02:12:54 +08:00
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
function exposeRegistryMethodsWithoutDeprecations(container) {
|
2016-12-16 05:43:38 +08:00
|
|
|
var methods = [
|
|
|
|
'register',
|
|
|
|
'unregister',
|
|
|
|
'resolve',
|
|
|
|
'normalize',
|
|
|
|
'typeInjection',
|
|
|
|
'injection',
|
|
|
|
'factoryInjection',
|
|
|
|
'factoryTypeInjection',
|
|
|
|
'has',
|
|
|
|
'options',
|
|
|
|
'optionsForType'
|
|
|
|
];
|
2015-05-14 02:12:54 +08:00
|
|
|
|
|
|
|
function exposeRegistryMethod(container, method) {
|
2016-11-09 03:29:50 +08:00
|
|
|
if (method in container) {
|
2016-12-16 05:43:38 +08:00
|
|
|
container[method] = function() {
|
2016-11-09 03:29:50 +08:00
|
|
|
return container._registry[method].apply(container._registry, arguments);
|
|
|
|
};
|
|
|
|
}
|
2015-05-14 02:12:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
for (var i = 0, l = methods.length; i < l; i++) {
|
|
|
|
exposeRegistryMethod(container, methods[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
var Owner = (function() {
|
|
|
|
if (Ember['default']._RegistryProxyMixin && Ember['default']._ContainerProxyMixin) {
|
|
|
|
return Ember['default'].Object.extend(Ember['default']._RegistryProxyMixin, Ember['default']._ContainerProxyMixin);
|
2016-11-09 03:29:50 +08:00
|
|
|
}
|
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
return Ember['default'].Object.extend();
|
2016-11-09 03:29:50 +08:00
|
|
|
})();
|
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
exports['default'] = function(resolver) {
|
2016-11-09 03:29:50 +08:00
|
|
|
var fallbackRegistry, registry, container;
|
2016-12-16 05:43:38 +08:00
|
|
|
var namespace = Ember['default'].Object.create({
|
|
|
|
Resolver: { create: function() { return resolver; } }
|
2015-07-15 01:56:59 +08:00
|
|
|
});
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2015-07-15 01:56:59 +08:00
|
|
|
function register(name, factory) {
|
|
|
|
var thingToRegisterWith = registry || container;
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2015-07-15 01:56:59 +08:00
|
|
|
if (!container.lookupFactory(name)) {
|
|
|
|
thingToRegisterWith.register(name, factory);
|
|
|
|
}
|
|
|
|
}
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
if (Ember['default'].Application.buildRegistry) {
|
|
|
|
fallbackRegistry = Ember['default'].Application.buildRegistry(namespace);
|
|
|
|
fallbackRegistry.register('component-lookup:main', Ember['default'].ComponentLookup);
|
2016-11-09 03:29:50 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
registry = new Ember['default'].Registry({
|
2016-11-09 03:29:50 +08:00
|
|
|
fallback: fallbackRegistry
|
|
|
|
});
|
|
|
|
|
|
|
|
// these properties are set on the fallback registry by `buildRegistry`
|
|
|
|
// and on the primary registry within the ApplicationInstance constructor
|
|
|
|
// but we need to manually recreate them since ApplicationInstance's are not
|
|
|
|
// exposed externally
|
|
|
|
registry.normalizeFullName = fallbackRegistry.normalizeFullName;
|
|
|
|
registry.makeToString = fallbackRegistry.makeToString;
|
|
|
|
registry.describe = fallbackRegistry.describe;
|
|
|
|
|
|
|
|
var owner = Owner.create({
|
|
|
|
__registry__: registry,
|
|
|
|
__container__: null
|
|
|
|
});
|
|
|
|
|
|
|
|
container = registry.container({ owner: owner });
|
|
|
|
owner.__container__ = container;
|
2015-07-15 01:56:59 +08:00
|
|
|
|
2015-05-14 02:12:54 +08:00
|
|
|
exposeRegistryMethodsWithoutDeprecations(container);
|
2014-07-31 05:53:14 +08:00
|
|
|
} else {
|
2016-12-16 05:43:38 +08:00
|
|
|
container = Ember['default'].Application.buildContainer(namespace);
|
|
|
|
container.register('component-lookup:main', Ember['default'].ComponentLookup);
|
2014-07-31 05:53:14 +08:00
|
|
|
}
|
|
|
|
|
2015-07-15 01:56:59 +08:00
|
|
|
// Ember 1.10.0 did not properly add `view:toplevel` or `view:default`
|
|
|
|
// to the registry in Ember.Application.buildRegistry :(
|
2016-11-09 03:29:50 +08:00
|
|
|
//
|
|
|
|
// Ember 2.0.0 removed Ember.View as public API, so only do this when
|
|
|
|
// Ember.View is present
|
2016-12-16 05:43:38 +08:00
|
|
|
if (Ember['default'].View) {
|
|
|
|
register('view:toplevel', Ember['default'].View.extend());
|
2016-11-09 03:29:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Ember 2.0.0 removed Ember._MetamorphView from the Ember global, so only
|
|
|
|
// do this when present
|
2016-12-16 05:43:38 +08:00
|
|
|
if (Ember['default']._MetamorphView) {
|
|
|
|
register('view:default', Ember['default']._MetamorphView);
|
2016-11-09 03:29:50 +08:00
|
|
|
}
|
2014-07-31 05:53:14 +08:00
|
|
|
|
2015-05-14 02:12:54 +08:00
|
|
|
var globalContext = typeof global === 'object' && global || self;
|
2016-12-16 05:43:38 +08:00
|
|
|
if (globalContext.DS) {
|
2015-05-14 02:12:54 +08:00
|
|
|
var DS = globalContext.DS;
|
|
|
|
if (DS._setupContainer) {
|
2015-07-15 01:56:59 +08:00
|
|
|
DS._setupContainer(registry || container);
|
2015-05-14 02:12:54 +08:00
|
|
|
} else {
|
2015-07-15 01:56:59 +08:00
|
|
|
register('transform:boolean', DS.BooleanTransform);
|
|
|
|
register('transform:date', DS.DateTransform);
|
|
|
|
register('transform:number', DS.NumberTransform);
|
|
|
|
register('transform:string', DS.StringTransform);
|
|
|
|
register('serializer:-default', DS.JSONSerializer);
|
|
|
|
register('serializer:-rest', DS.RESTSerializer);
|
|
|
|
register('adapter:-rest', DS.RESTAdapter);
|
2015-05-14 02:12:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
2015-07-15 01:56:59 +08:00
|
|
|
registry: registry,
|
|
|
|
container: container
|
2014-07-31 05:53:14 +08:00
|
|
|
};
|
2016-12-16 05:43:38 +08:00
|
|
|
}
|
|
|
|
|
2015-07-15 01:56:59 +08:00
|
|
|
});
|
2016-12-16 05:43:38 +08:00
|
|
|
define('ember-test-helpers/has-ember-version', ['exports', 'ember'], function (exports, Ember) {
|
2016-12-02 03:04:22 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
'use strict';
|
2016-12-13 05:24:36 +08:00
|
|
|
|
2016-11-09 03:29:50 +08:00
|
|
|
function hasEmberVersion(major, minor) {
|
2016-12-16 05:43:38 +08:00
|
|
|
var numbers = Ember['default'].VERSION.split('-')[0].split('.');
|
2016-11-09 03:29:50 +08:00
|
|
|
var actualMajor = parseInt(numbers[0], 10);
|
|
|
|
var actualMinor = parseInt(numbers[1], 10);
|
2016-12-16 05:43:38 +08:00
|
|
|
return actualMajor > major || (actualMajor === major && actualMinor >= minor);
|
2016-11-09 03:29:50 +08:00
|
|
|
}
|
2016-12-16 05:43:38 +08:00
|
|
|
exports['default'] = hasEmberVersion;
|
|
|
|
|
2015-05-14 02:12:54 +08:00
|
|
|
});
|
2016-12-16 05:43:38 +08:00
|
|
|
define('ember-test-helpers/test-context', ['exports'], function (exports) {
|
|
|
|
|
|
|
|
'use strict';
|
2015-05-14 02:12:54 +08:00
|
|
|
|
|
|
|
exports.setContext = setContext;
|
|
|
|
exports.getContext = getContext;
|
2016-11-09 03:29:50 +08:00
|
|
|
exports.unsetContext = unsetContext;
|
2016-12-16 05:43:38 +08:00
|
|
|
|
2015-05-14 02:12:54 +08:00
|
|
|
var __test_context__;
|
|
|
|
|
|
|
|
function setContext(context) {
|
|
|
|
__test_context__ = context;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getContext() {
|
|
|
|
return __test_context__;
|
|
|
|
}
|
|
|
|
|
2016-11-09 03:29:50 +08:00
|
|
|
function unsetContext() {
|
|
|
|
__test_context__ = undefined;
|
|
|
|
}
|
2016-12-02 03:04:22 +08:00
|
|
|
|
2016-12-13 05:24:36 +08:00
|
|
|
});
|
2016-12-16 05:43:38 +08:00
|
|
|
define('ember-test-helpers/test-module-for-component', ['exports', 'ember-test-helpers/test-module', 'ember', 'ember-test-helpers/test-resolver'], function (exports, TestModule, Ember, test_resolver) {
|
2016-12-13 05:24:36 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
'use strict';
|
2016-12-13 05:24:36 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
exports['default'] = TestModule['default'].extend({
|
|
|
|
isComponentTestModule: true,
|
2016-11-09 03:42:10 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
init: function(componentName, description, callbacks) {
|
2015-05-14 02:12:54 +08:00
|
|
|
// Allow `description` to be omitted
|
|
|
|
if (!callbacks && typeof description === 'object') {
|
2015-07-15 01:56:59 +08:00
|
|
|
callbacks = description;
|
2015-05-14 02:12:54 +08:00
|
|
|
description = null;
|
2015-07-15 01:56:59 +08:00
|
|
|
} else if (!callbacks) {
|
|
|
|
callbacks = {};
|
2015-05-14 02:12:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
this.componentName = componentName;
|
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
if (callbacks.needs || callbacks.unit || callbacks.integration === false) {
|
2015-05-14 02:12:54 +08:00
|
|
|
this.isUnitTest = true;
|
2016-12-16 05:43:38 +08:00
|
|
|
} else if (callbacks.integration) {
|
2015-05-14 02:12:54 +08:00
|
|
|
this.isUnitTest = false;
|
|
|
|
} else {
|
2016-12-16 05:43:38 +08:00
|
|
|
Ember['default'].deprecate(
|
|
|
|
"the component:" + componentName + " test module is implicitly running in unit test mode, " +
|
|
|
|
"which will change to integration test mode by default in an upcoming version of " +
|
|
|
|
"ember-test-helpers. Add `unit: true` or a `needs:[]` list to explicitly opt in to unit " +
|
|
|
|
"test mode.",
|
|
|
|
false,
|
|
|
|
{ id: 'ember-test-helpers.test-module-for-component.test-type', until: '0.6.0' }
|
|
|
|
);
|
2015-05-14 02:12:54 +08:00
|
|
|
this.isUnitTest = true;
|
|
|
|
}
|
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
if (description) {
|
|
|
|
this._super.call(this, 'component:' + componentName, description, callbacks);
|
|
|
|
} else {
|
|
|
|
this._super.call(this, 'component:' + componentName, callbacks);
|
|
|
|
}
|
|
|
|
|
2016-11-09 03:42:10 +08:00
|
|
|
if (!this.isUnitTest && !this.isLegacy) {
|
|
|
|
callbacks.integration = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.isUnitTest || this.isLegacy) {
|
2015-05-14 02:12:54 +08:00
|
|
|
this.setupSteps.push(this.setupComponentUnitTest);
|
|
|
|
} else {
|
2016-12-16 05:43:38 +08:00
|
|
|
this.callbacks.subject = function() {
|
|
|
|
throw new Error("component integration tests do not support `subject()`.");
|
2015-05-14 02:12:54 +08:00
|
|
|
};
|
|
|
|
this.setupSteps.push(this.setupComponentIntegrationTest);
|
2016-11-09 03:29:50 +08:00
|
|
|
this.teardownSteps.unshift(this.teardownComponent);
|
2015-05-14 02:12:54 +08:00
|
|
|
}
|
2016-11-09 03:29:50 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
if (Ember['default'].View && Ember['default'].View.views) {
|
2016-11-09 03:29:50 +08:00
|
|
|
this.setupSteps.push(this._aliasViewRegistry);
|
|
|
|
this.teardownSteps.unshift(this._resetViewRegistry);
|
|
|
|
}
|
2016-12-16 05:43:38 +08:00
|
|
|
},
|
2016-11-09 03:29:50 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
_aliasViewRegistry: function() {
|
|
|
|
this._originalGlobalViewRegistry = Ember['default'].View.views;
|
2016-11-09 03:29:50 +08:00
|
|
|
var viewRegistry = this.container.lookup('-view-registry:main');
|
|
|
|
|
|
|
|
if (viewRegistry) {
|
2016-12-16 05:43:38 +08:00
|
|
|
Ember['default'].View.views = viewRegistry;
|
2016-11-09 03:29:50 +08:00
|
|
|
}
|
2016-12-16 05:43:38 +08:00
|
|
|
},
|
2016-11-09 03:29:50 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
_resetViewRegistry: function() {
|
|
|
|
Ember['default'].View.views = this._originalGlobalViewRegistry;
|
|
|
|
},
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
setupComponentUnitTest: function() {
|
2015-05-14 02:12:54 +08:00
|
|
|
var _this = this;
|
2016-12-16 05:43:38 +08:00
|
|
|
var resolver = test_resolver.getResolver();
|
2015-05-14 02:12:54 +08:00
|
|
|
var context = this.context;
|
|
|
|
|
|
|
|
var layoutName = 'template:components/' + this.componentName;
|
|
|
|
|
|
|
|
var layout = resolver.resolve(layoutName);
|
|
|
|
|
2016-11-09 03:29:50 +08:00
|
|
|
var thingToRegisterWith = this.registry || this.container;
|
2015-05-14 02:12:54 +08:00
|
|
|
if (layout) {
|
2016-11-09 03:29:50 +08:00
|
|
|
thingToRegisterWith.register(layoutName, layout);
|
|
|
|
thingToRegisterWith.injection(this.subjectName, 'layout', layoutName);
|
2015-05-14 02:12:54 +08:00
|
|
|
}
|
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
context.dispatcher = this.container.lookup('event_dispatcher:main') || Ember['default'].EventDispatcher.create();
|
2015-05-14 02:12:54 +08:00
|
|
|
context.dispatcher.setup({}, '#ember-testing');
|
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
this.callbacks.render = function() {
|
2016-11-09 03:29:50 +08:00
|
|
|
var subject;
|
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
Ember['default'].run(function(){
|
2016-11-09 03:29:50 +08:00
|
|
|
subject = context.subject();
|
|
|
|
subject.appendTo('#ember-testing');
|
2015-05-14 02:12:54 +08:00
|
|
|
});
|
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
_this.teardownSteps.unshift(function() {
|
|
|
|
Ember['default'].run(function() {
|
|
|
|
Ember['default'].tryInvoke(subject, 'destroy');
|
2015-05-14 02:12:54 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
this.callbacks.append = function() {
|
|
|
|
Ember['default'].deprecate(
|
|
|
|
'this.append() is deprecated. Please use this.render() or this.$() instead.',
|
|
|
|
false,
|
|
|
|
{ id: 'ember-test-helpers.test-module-for-component.append', until: '0.6.0' }
|
|
|
|
);
|
2015-05-14 02:12:54 +08:00
|
|
|
return context.$();
|
|
|
|
};
|
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
context.$ = function() {
|
2015-05-14 02:12:54 +08:00
|
|
|
this.render();
|
|
|
|
var subject = this.subject();
|
|
|
|
|
|
|
|
return subject.$.apply(subject, arguments);
|
|
|
|
};
|
2016-12-16 05:43:38 +08:00
|
|
|
},
|
2016-11-09 03:29:50 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
setupComponentIntegrationTest: function() {
|
|
|
|
var module = this;
|
|
|
|
var context = this.context;
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
this.actionHooks = {};
|
2016-12-02 03:04:22 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
context.dispatcher = this.container.lookup('event_dispatcher:main') || Ember['default'].EventDispatcher.create();
|
|
|
|
context.dispatcher.setup({}, '#ember-testing');
|
|
|
|
context.actions = module.actionHooks;
|
2016-12-02 03:04:22 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
(this.registry || this.container).register('component:-test-holder', Ember['default'].Component.extend());
|
2016-12-13 05:24:36 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
context.render = function(template) {
|
|
|
|
if (!template) {
|
|
|
|
throw new Error("in a component integration test you must pass a template to `render()`");
|
|
|
|
}
|
|
|
|
if (Ember['default'].isArray(template)) {
|
|
|
|
template = template.join('');
|
|
|
|
}
|
|
|
|
if (typeof template === 'string') {
|
|
|
|
template = Ember['default'].Handlebars.compile(template);
|
|
|
|
}
|
|
|
|
module.component = module.container.lookupFactory('component:-test-holder').create({
|
|
|
|
layout: template
|
|
|
|
});
|
2016-12-13 05:24:36 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
module.component.set('context' ,context);
|
|
|
|
module.component.set('controller', context);
|
2016-12-13 05:24:36 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
Ember['default'].run(function() {
|
|
|
|
module.component.appendTo('#ember-testing');
|
|
|
|
});
|
2016-12-13 05:18:42 +08:00
|
|
|
};
|
2016-12-02 03:04:22 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
context.$ = function() {
|
|
|
|
return module.component.$.apply(module.component, arguments);
|
|
|
|
};
|
2016-12-13 05:24:36 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
context.set = function(key, value) {
|
|
|
|
Ember['default'].run(function() {
|
|
|
|
Ember['default'].set(context, key, value);
|
2016-12-13 05:18:42 +08:00
|
|
|
});
|
2016-12-16 05:43:38 +08:00
|
|
|
};
|
2016-12-13 05:24:36 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
context.setProperties = function(hash) {
|
|
|
|
Ember['default'].run(function() {
|
|
|
|
Ember['default'].setProperties(context, hash);
|
|
|
|
});
|
|
|
|
};
|
2016-12-13 05:24:36 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
context.get = function(key) {
|
|
|
|
return Ember['default'].get(context, key);
|
|
|
|
};
|
2016-12-13 05:24:36 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
context.getProperties = function() {
|
|
|
|
var args = Array.prototype.slice.call(arguments);
|
|
|
|
return Ember['default'].getProperties(context, args);
|
2016-12-13 05:18:42 +08:00
|
|
|
};
|
2016-12-13 05:24:36 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
context.on = function(actionName, handler) {
|
|
|
|
module.actionHooks[actionName] = handler;
|
|
|
|
};
|
|
|
|
context.send = function(actionName) {
|
|
|
|
var hook = module.actionHooks[actionName];
|
|
|
|
if (!hook) {
|
|
|
|
throw new Error("integration testing template received unexpected action " + actionName);
|
2016-11-09 03:29:50 +08:00
|
|
|
}
|
2016-12-16 05:43:38 +08:00
|
|
|
hook.apply(module, Array.prototype.slice.call(arguments, 1));
|
|
|
|
};
|
|
|
|
},
|
2016-12-13 05:24:36 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
setupContext: function() {
|
|
|
|
this._super.call(this);
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2016-11-09 03:29:50 +08:00
|
|
|
// only setup the injection if we are running against a version
|
|
|
|
// of Ember that has `-view-registry:main` (Ember >= 1.12)
|
|
|
|
if (this.container.lookupFactory('-view-registry:main')) {
|
|
|
|
(this.registry || this.container).injection('component', '_viewRegistry', '-view-registry:main');
|
|
|
|
}
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
if (!this.isUnitTest && !this.isLegacy) {
|
|
|
|
this.context.factory = function() {};
|
2015-05-14 02:12:54 +08:00
|
|
|
}
|
2016-12-16 05:43:38 +08:00
|
|
|
},
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
teardownComponent: function() {
|
2015-05-14 02:12:54 +08:00
|
|
|
var component = this.component;
|
|
|
|
if (component) {
|
2016-12-16 05:43:38 +08:00
|
|
|
Ember['default'].run(function() {
|
2015-05-14 02:12:54 +08:00
|
|
|
component.destroy();
|
|
|
|
});
|
|
|
|
}
|
2016-12-16 05:43:38 +08:00
|
|
|
}
|
|
|
|
});
|
2016-12-13 05:24:36 +08:00
|
|
|
|
2015-05-14 02:12:54 +08:00
|
|
|
});
|
2016-12-16 05:43:38 +08:00
|
|
|
define('ember-test-helpers/test-module-for-model', ['exports', 'ember-test-helpers/test-module', 'ember'], function (exports, TestModule, Ember) {
|
2015-05-14 02:12:54 +08:00
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
exports['default'] = TestModule['default'].extend({
|
|
|
|
init: function(modelName, description, callbacks) {
|
2016-12-13 05:24:36 +08:00
|
|
|
this.modelName = modelName;
|
2016-12-13 05:18:42 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
this._super.call(this, 'model:' + modelName, description, callbacks);
|
|
|
|
|
2015-05-14 02:12:54 +08:00
|
|
|
this.setupSteps.push(this.setupModel);
|
2016-12-16 05:43:38 +08:00
|
|
|
},
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
setupModel: function() {
|
2015-05-14 02:12:54 +08:00
|
|
|
var container = this.container;
|
|
|
|
var defaultSubject = this.defaultSubject;
|
|
|
|
var callbacks = this.callbacks;
|
|
|
|
var modelName = this.modelName;
|
|
|
|
|
|
|
|
var adapterFactory = container.lookupFactory('adapter:application');
|
|
|
|
if (!adapterFactory) {
|
2016-12-16 05:43:38 +08:00
|
|
|
adapterFactory = DS.JSONAPIAdapter || DS.FixtureAdapter;
|
2016-11-09 03:29:50 +08:00
|
|
|
|
|
|
|
var thingToRegisterWith = this.registry || this.container;
|
|
|
|
thingToRegisterWith.register('adapter:application', adapterFactory);
|
2015-05-14 02:12:54 +08:00
|
|
|
}
|
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
callbacks.store = function(){
|
2015-05-14 02:12:54 +08:00
|
|
|
var container = this.container;
|
2016-12-16 05:43:38 +08:00
|
|
|
var store = container.lookup('service:store') || container.lookup('store:main');
|
|
|
|
return store;
|
2015-05-14 02:12:54 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
if (callbacks.subject === defaultSubject) {
|
2016-12-16 05:43:38 +08:00
|
|
|
callbacks.subject = function(options) {
|
2015-05-14 02:12:54 +08:00
|
|
|
var container = this.container;
|
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
return Ember['default'].run(function() {
|
2015-07-15 01:56:59 +08:00
|
|
|
var store = container.lookup('service:store') || container.lookup('store:main');
|
|
|
|
return store.createRecord(modelName, options);
|
2015-05-14 02:12:54 +08:00
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
2016-12-16 05:43:38 +08:00
|
|
|
}
|
|
|
|
});
|
2016-12-02 03:04:22 +08:00
|
|
|
|
2016-12-13 05:24:36 +08:00
|
|
|
});
|
2016-12-16 05:43:38 +08:00
|
|
|
define('ember-test-helpers/test-module', ['exports', 'ember', 'ember-test-helpers/test-context', 'klassy', 'ember-test-helpers/test-resolver', 'ember-test-helpers/build-registry', 'ember-test-helpers/has-ember-version', 'ember-test-helpers/wait'], function (exports, Ember, test_context, klassy, test_resolver, buildRegistry, hasEmberVersion, wait) {
|
2016-12-13 05:24:36 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
'use strict';
|
2016-12-13 05:24:36 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
exports['default'] = klassy.Klass.extend({
|
|
|
|
init: function(subjectName, description, callbacks) {
|
2015-05-14 02:12:54 +08:00
|
|
|
// Allow `description` to be omitted, in which case it should
|
|
|
|
// default to `subjectName`
|
|
|
|
if (!callbacks && typeof description === 'object') {
|
|
|
|
callbacks = description;
|
|
|
|
description = subjectName;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.subjectName = subjectName;
|
|
|
|
this.description = description || subjectName;
|
2016-12-16 05:43:38 +08:00
|
|
|
this.name = description || subjectName;
|
|
|
|
this.callbacks = callbacks || {};
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2016-11-09 03:29:50 +08:00
|
|
|
if (this.callbacks.integration && this.callbacks.needs) {
|
|
|
|
throw new Error("cannot declare 'integration: true' and 'needs' in the same module");
|
|
|
|
}
|
|
|
|
|
2015-05-14 02:12:54 +08:00
|
|
|
if (this.callbacks.integration) {
|
2016-12-16 05:43:38 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2015-05-14 02:12:54 +08:00
|
|
|
delete callbacks.integration;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.initSubject();
|
|
|
|
this.initNeeds();
|
2016-12-16 05:43:38 +08:00
|
|
|
this.initSetupSteps();
|
|
|
|
this.initTeardownSteps();
|
|
|
|
},
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
initSubject: function() {
|
2015-05-14 02:12:54 +08:00
|
|
|
this.callbacks.subject = this.callbacks.subject || this.defaultSubject;
|
2016-12-16 05:43:38 +08:00
|
|
|
},
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
initNeeds: function() {
|
2015-05-14 02:12:54 +08:00
|
|
|
this.needs = [this.subjectName];
|
|
|
|
if (this.callbacks.needs) {
|
2015-07-15 01:56:59 +08:00
|
|
|
this.needs = this.needs.concat(this.callbacks.needs);
|
2015-05-14 02:12:54 +08:00
|
|
|
delete this.callbacks.needs;
|
|
|
|
}
|
2016-12-16 05:43:38 +08:00
|
|
|
},
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
initSetupSteps: function() {
|
2015-05-14 02:12:54 +08:00
|
|
|
this.setupSteps = [];
|
|
|
|
this.contextualizedSetupSteps = [];
|
|
|
|
|
|
|
|
if (this.callbacks.beforeSetup) {
|
2016-12-16 05:43:38 +08:00
|
|
|
this.setupSteps.push( this.callbacks.beforeSetup );
|
2015-05-14 02:12:54 +08:00
|
|
|
delete this.callbacks.beforeSetup;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setupSteps.push(this.setupContainer);
|
|
|
|
this.setupSteps.push(this.setupContext);
|
|
|
|
this.setupSteps.push(this.setupTestElements);
|
2016-11-09 03:29:50 +08:00
|
|
|
this.setupSteps.push(this.setupAJAXListeners);
|
2015-05-14 02:12:54 +08:00
|
|
|
|
|
|
|
if (this.callbacks.setup) {
|
2016-12-16 05:43:38 +08:00
|
|
|
this.contextualizedSetupSteps.push( this.callbacks.setup );
|
2015-05-14 02:12:54 +08:00
|
|
|
delete this.callbacks.setup;
|
|
|
|
}
|
2016-12-16 05:43:38 +08:00
|
|
|
},
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
initTeardownSteps: function() {
|
2015-05-14 02:12:54 +08:00
|
|
|
this.teardownSteps = [];
|
|
|
|
this.contextualizedTeardownSteps = [];
|
|
|
|
|
|
|
|
if (this.callbacks.teardown) {
|
2016-12-16 05:43:38 +08:00
|
|
|
this.contextualizedTeardownSteps.push( this.callbacks.teardown );
|
2015-05-14 02:12:54 +08:00
|
|
|
delete this.callbacks.teardown;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.teardownSteps.push(this.teardownSubject);
|
|
|
|
this.teardownSteps.push(this.teardownContainer);
|
|
|
|
this.teardownSteps.push(this.teardownContext);
|
|
|
|
this.teardownSteps.push(this.teardownTestElements);
|
2016-11-09 03:29:50 +08:00
|
|
|
this.teardownSteps.push(this.teardownAJAXListeners);
|
2015-05-14 02:12:54 +08:00
|
|
|
|
|
|
|
if (this.callbacks.afterTeardown) {
|
2016-12-16 05:43:38 +08:00
|
|
|
this.teardownSteps.push( this.callbacks.afterTeardown );
|
2015-05-14 02:12:54 +08:00
|
|
|
delete this.callbacks.afterTeardown;
|
|
|
|
}
|
2016-12-16 05:43:38 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
setup: function() {
|
|
|
|
var self = this;
|
|
|
|
return self.invokeSteps(self.setupSteps).then(function() {
|
|
|
|
self.contextualizeCallbacks();
|
|
|
|
return self.invokeSteps(self.contextualizedSetupSteps, self.context);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
teardown: function() {
|
|
|
|
var self = this;
|
|
|
|
return self.invokeSteps(self.contextualizedTeardownSteps, self.context).then(function() {
|
|
|
|
return self.invokeSteps(self.teardownSteps);
|
|
|
|
}).then(function() {
|
|
|
|
self.cache = null;
|
|
|
|
self.cachedCalls = null;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
invokeSteps: function(steps, _context) {
|
|
|
|
var context = _context;
|
|
|
|
if (!context) {
|
|
|
|
context = this;
|
|
|
|
}
|
|
|
|
steps = steps.slice();
|
|
|
|
function nextStep() {
|
|
|
|
var step = steps.shift();
|
|
|
|
if (step) {
|
|
|
|
// guard against exceptions, for example missing components referenced from needs.
|
|
|
|
return new Ember['default'].RSVP.Promise(function(ok) {
|
|
|
|
ok(step.call(context));
|
|
|
|
}).then(nextStep);
|
|
|
|
} else {
|
|
|
|
return Ember['default'].RSVP.resolve();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nextStep();
|
|
|
|
},
|
2016-11-26 03:59:16 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
setupContainer: function() {
|
2016-11-09 03:42:10 +08:00
|
|
|
if (this.isIntegration || this.isLegacy) {
|
2015-05-14 02:12:54 +08:00
|
|
|
this._setupIntegratedContainer();
|
|
|
|
} else {
|
|
|
|
this._setupIsolatedContainer();
|
|
|
|
}
|
2016-12-16 05:43:38 +08:00
|
|
|
},
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
setupContext: function() {
|
2015-05-14 02:12:54 +08:00
|
|
|
var subjectName = this.subjectName;
|
|
|
|
var container = this.container;
|
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
var factory = function() {
|
2015-05-14 02:12:54 +08:00
|
|
|
return container.lookupFactory(subjectName);
|
|
|
|
};
|
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
test_context.setContext({
|
|
|
|
container: this.container,
|
2015-05-14 02:12:54 +08:00
|
|
|
registry: this.registry,
|
2016-12-16 05:43:38 +08:00
|
|
|
factory: factory,
|
|
|
|
dispatcher: null,
|
|
|
|
register: function() {
|
2016-11-09 03:29:50 +08:00
|
|
|
var target = this.registry || this.container;
|
|
|
|
return target.register.apply(target, arguments);
|
2016-12-16 05:43:38 +08:00
|
|
|
},
|
|
|
|
inject: {}
|
2015-05-14 02:12:54 +08:00
|
|
|
});
|
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
var context = this.context = test_context.getContext();
|
2016-12-13 05:24:36 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
if (Ember['default'].setOwner) {
|
|
|
|
Ember['default'].setOwner(context, this.container.owner);
|
|
|
|
}
|
2016-12-13 05:24:36 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
if (Ember['default'].inject) {
|
|
|
|
var keys = (Object.keys || Ember['default'].keys)(Ember['default'].inject);
|
|
|
|
keys.forEach(function(typeName) {
|
|
|
|
context.inject[typeName] = function(name, opts) {
|
|
|
|
var alias = (opts && opts.as) || name;
|
|
|
|
Ember['default'].set(context, alias, context.container.lookup(typeName + ':' + name));
|
2016-11-09 03:29:50 +08:00
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|
2016-12-16 05:43:38 +08:00
|
|
|
},
|
2016-12-13 05:18:42 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
setupTestElements: function() {
|
|
|
|
if (Ember['default'].$('#ember-testing').length === 0) {
|
|
|
|
Ember['default'].$('<div id="ember-testing"/>').appendTo(document.body);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
setupAJAXListeners: function() {
|
|
|
|
wait._setupAJAXHooks();
|
|
|
|
},
|
|
|
|
|
|
|
|
teardownSubject: function() {
|
2015-05-14 02:12:54 +08:00
|
|
|
var subject = this.cache.subject;
|
|
|
|
|
|
|
|
if (subject) {
|
2016-12-16 05:43:38 +08:00
|
|
|
Ember['default'].run(function() {
|
|
|
|
Ember['default'].tryInvoke(subject, 'destroy');
|
2015-05-14 02:12:54 +08:00
|
|
|
});
|
2014-07-31 05:53:14 +08:00
|
|
|
}
|
2016-12-16 05:43:38 +08:00
|
|
|
},
|
2014-07-31 05:53:14 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
teardownContainer: function() {
|
2015-05-14 02:12:54 +08:00
|
|
|
var container = this.container;
|
2016-12-16 05:43:38 +08:00
|
|
|
Ember['default'].run(function() {
|
2014-07-31 05:53:14 +08:00
|
|
|
container.destroy();
|
2015-05-14 02:12:54 +08:00
|
|
|
});
|
2016-12-16 05:43:38 +08:00
|
|
|
},
|
2016-12-13 05:24:36 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
teardownContext: function() {
|
2016-11-26 03:59:16 +08:00
|
|
|
var context = this.context;
|
2016-12-16 05:43:38 +08:00
|
|
|
this.context = undefined;
|
|
|
|
test_context.unsetContext();
|
2016-11-26 03:59:16 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
if (context.dispatcher && !context.dispatcher.isDestroyed) {
|
|
|
|
Ember['default'].run(function() {
|
|
|
|
context.dispatcher.destroy();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2016-11-26 03:59:16 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
teardownTestElements: function() {
|
|
|
|
Ember['default'].$('#ember-testing').empty();
|
2016-11-26 03:59:16 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
// Ember 2.0.0 removed Ember.View as public API, so only do this when
|
|
|
|
// Ember.View is present
|
|
|
|
if (Ember['default'].View && Ember['default'].View.views) {
|
|
|
|
Ember['default'].View.views = {};
|
2016-11-26 03:59:16 +08:00
|
|
|
}
|
2016-12-16 05:43:38 +08:00
|
|
|
},
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
teardownAJAXListeners: function() {
|
|
|
|
wait._teardownAJAXHooks();
|
|
|
|
},
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
defaultSubject: function(options, factory) {
|
|
|
|
return factory.create(options);
|
|
|
|
},
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
// allow arbitrary named factories, like rspec let
|
|
|
|
contextualizeCallbacks: function() {
|
|
|
|
var _this = this;
|
|
|
|
var callbacks = this.callbacks;
|
|
|
|
var context = this.context;
|
|
|
|
var factory = context.factory;
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
this.cache = this.cache || {};
|
|
|
|
this.cachedCalls = this.cachedCalls || {};
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
var keys = (Object.keys || Ember['default'].keys)(callbacks);
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
for (var i = 0, l = keys.length; i < l; i++) {
|
|
|
|
(function(key) {
|
2016-11-26 03:29:24 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
context[key] = function(options) {
|
|
|
|
if (_this.cachedCalls[key]) { return _this.cache[key]; }
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
var result = callbacks[key].call(_this, options, factory());
|
2016-12-02 03:04:22 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
_this.cache[key] = result;
|
|
|
|
_this.cachedCalls[key] = true;
|
2016-12-13 05:24:36 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
return result;
|
|
|
|
};
|
2016-11-26 03:29:24 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
})(keys[i]);
|
2015-05-14 02:12:54 +08:00
|
|
|
}
|
2016-12-16 05:43:38 +08:00
|
|
|
},
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
_setupContainer: function(isolated) {
|
|
|
|
var resolver = test_resolver.getResolver();
|
2016-11-09 03:42:10 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
var items = buildRegistry['default'](!isolated ? resolver : Object.create(resolver, {
|
2016-11-09 03:42:10 +08:00
|
|
|
resolve: {
|
2016-12-16 05:43:38 +08:00
|
|
|
value: function() {}
|
2016-11-09 03:42:10 +08:00
|
|
|
}
|
|
|
|
}));
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2015-07-15 01:56:59 +08:00
|
|
|
this.container = items.container;
|
|
|
|
this.registry = items.registry;
|
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
if (hasEmberVersion['default'](1, 13)) {
|
2016-11-09 03:29:50 +08:00
|
|
|
var thingToRegisterWith = this.registry || this.container;
|
|
|
|
var router = resolver.resolve('router:main');
|
2016-12-16 05:43:38 +08:00
|
|
|
router = router || Ember['default'].Router.extend();
|
2016-11-09 03:29:50 +08:00
|
|
|
thingToRegisterWith.register('router:main', router);
|
|
|
|
}
|
2016-12-16 05:43:38 +08:00
|
|
|
},
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
_setupIsolatedContainer: function() {
|
|
|
|
var resolver = test_resolver.getResolver();
|
2016-11-09 03:42:10 +08:00
|
|
|
this._setupContainer(true);
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2015-07-15 01:56:59 +08:00
|
|
|
var thingToRegisterWith = this.registry || this.container;
|
|
|
|
|
|
|
|
for (var i = this.needs.length; i > 0; i--) {
|
|
|
|
var fullName = this.needs[i - 1];
|
|
|
|
var normalizedFullName = resolver.normalize(fullName);
|
|
|
|
thingToRegisterWith.register(fullName, resolver.resolve(normalizedFullName));
|
2015-05-14 02:12:54 +08:00
|
|
|
}
|
2015-07-15 01:56:59 +08:00
|
|
|
|
2016-11-09 03:42:10 +08:00
|
|
|
if (!this.registry) {
|
2016-12-16 05:43:38 +08:00
|
|
|
this.container.resolver = function() {};
|
2016-11-09 03:29:50 +08:00
|
|
|
}
|
2016-12-16 05:43:38 +08:00
|
|
|
},
|
2015-07-15 01:56:59 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
_setupIntegratedContainer: function() {
|
2015-07-15 01:56:59 +08:00
|
|
|
this._setupContainer();
|
2016-12-16 05:43:38 +08:00
|
|
|
}
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
});
|
2015-05-14 02:12:54 +08:00
|
|
|
|
|
|
|
});
|
|
|
|
define('ember-test-helpers/test-resolver', ['exports'], function (exports) {
|
2016-12-16 05:43:38 +08:00
|
|
|
|
2015-05-14 02:12:54 +08:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
exports.setResolver = setResolver;
|
|
|
|
exports.getResolver = getResolver;
|
2016-12-16 05:43:38 +08:00
|
|
|
|
2015-05-14 02:12:54 +08:00
|
|
|
var __resolver__;
|
|
|
|
|
|
|
|
function setResolver(resolver) {
|
|
|
|
__resolver__ = resolver;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getResolver() {
|
2016-12-16 05:43:38 +08:00
|
|
|
if (__resolver__ == null) throw new Error('you must set a resolver with `testResolver.set(resolver)`');
|
2015-05-14 02:12:54 +08:00
|
|
|
return __resolver__;
|
|
|
|
}
|
2016-12-16 05:43:38 +08:00
|
|
|
|
2016-11-09 03:29:50 +08:00
|
|
|
});
|
2016-12-16 05:43:38 +08:00
|
|
|
define('ember-test-helpers/wait', ['exports', 'ember'], function (exports, Ember) {
|
2016-11-09 03:29:50 +08:00
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
exports._teardownAJAXHooks = _teardownAJAXHooks;
|
|
|
|
exports._setupAJAXHooks = _setupAJAXHooks;
|
|
|
|
|
|
|
|
var requests;
|
|
|
|
function incrementAjaxPendingRequests(_, xhr) {
|
|
|
|
requests.push(xhr);
|
|
|
|
}
|
|
|
|
|
|
|
|
function decrementAjaxPendingRequests(_, xhr) {
|
2016-12-16 05:43:38 +08:00
|
|
|
for (var i = 0;i < requests.length;i++) {
|
2016-11-09 03:29:50 +08:00
|
|
|
if (xhr === requests[i]) {
|
|
|
|
requests.splice(i, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function _teardownAJAXHooks() {
|
|
|
|
jQuery(document).off('ajaxSend', incrementAjaxPendingRequests);
|
|
|
|
jQuery(document).off('ajaxComplete', decrementAjaxPendingRequests);
|
|
|
|
}
|
|
|
|
|
|
|
|
function _setupAJAXHooks() {
|
|
|
|
requests = [];
|
|
|
|
|
|
|
|
jQuery(document).on('ajaxSend', incrementAjaxPendingRequests);
|
|
|
|
jQuery(document).on('ajaxComplete', decrementAjaxPendingRequests);
|
|
|
|
}
|
|
|
|
|
|
|
|
function wait(_options) {
|
|
|
|
var options = _options || {};
|
|
|
|
var waitForTimers = options.hasOwnProperty('waitForTimers') ? options.waitForTimers : true;
|
|
|
|
var waitForAJAX = options.hasOwnProperty('waitForAJAX') ? options.waitForAJAX : true;
|
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
return new Ember['default'].RSVP.Promise(function(resolve) {
|
|
|
|
var watcher = self.setInterval(function() {
|
|
|
|
if (waitForTimers && (Ember['default'].run.hasScheduledTimers() || Ember['default'].run.currentRunLoop)) {
|
2016-11-09 03:29:50 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (waitForAJAX && requests && requests.length > 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Stop polling
|
|
|
|
self.clearInterval(watcher);
|
|
|
|
|
|
|
|
// Synchronously resolve the promise
|
2016-12-16 05:43:38 +08:00
|
|
|
Ember['default'].run(null, resolve);
|
2016-11-09 03:29:50 +08:00
|
|
|
}, 10);
|
|
|
|
});
|
|
|
|
}
|
2016-12-16 05:43:38 +08:00
|
|
|
exports['default'] = wait;
|
|
|
|
|
2015-05-14 02:12:54 +08:00
|
|
|
});
|
2016-12-16 05:43:38 +08:00
|
|
|
define('klassy', ['exports'], function (exports) {
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/**
|
|
|
|
Extend a class with the properties and methods of one or more other classes.
|
|
|
|
|
|
|
|
When a method is replaced with another method, it will be wrapped in a
|
|
|
|
function that makes the replaced method accessible via `this._super`.
|
|
|
|
|
|
|
|
@method extendClass
|
|
|
|
@param {Object} destination The class to merge into
|
|
|
|
@param {Object} source One or more source classes
|
|
|
|
*/
|
|
|
|
var extendClass = function(destination) {
|
|
|
|
var sources = Array.prototype.slice.call(arguments, 1);
|
|
|
|
var source;
|
|
|
|
|
|
|
|
for (var i = 0, l = sources.length; i < l; i++) {
|
|
|
|
source = sources[i];
|
|
|
|
|
|
|
|
for (var p in source) {
|
|
|
|
if (source.hasOwnProperty(p) &&
|
|
|
|
destination[p] &&
|
|
|
|
typeof destination[p] === 'function' &&
|
|
|
|
typeof source[p] === 'function') {
|
|
|
|
|
|
|
|
/* jshint loopfunc:true */
|
|
|
|
destination[p] =
|
|
|
|
(function(destinationFn, sourceFn) {
|
|
|
|
var wrapper = function() {
|
|
|
|
var prevSuper = this._super;
|
|
|
|
this._super = destinationFn;
|
|
|
|
|
|
|
|
var ret = sourceFn.apply(this, arguments);
|
|
|
|
|
|
|
|
this._super = prevSuper;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
};
|
|
|
|
wrapper.wrappedFunction = sourceFn;
|
|
|
|
return wrapper;
|
|
|
|
})(destination[p], source[p]);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
destination[p] = source[p];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// `subclassing` is a state flag used by `defineClass` to track when a class is
|
|
|
|
// being subclassed. It allows constructors to avoid calling `init`, which can
|
|
|
|
// be expensive and cause undesirable side effects.
|
|
|
|
var subclassing = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Define a new class with the properties and methods of one or more other classes.
|
|
|
|
|
|
|
|
The new class can be based on a `SuperClass`, which will be inserted into its
|
|
|
|
prototype chain.
|
|
|
|
|
|
|
|
Furthermore, one or more mixins (object that contain properties and/or methods)
|
|
|
|
may be specified, which will be applied in order. When a method is replaced
|
|
|
|
with another method, it will be wrapped in a function that makes the previous
|
|
|
|
method accessible via `this._super`.
|
|
|
|
|
|
|
|
@method defineClass
|
|
|
|
@param {Object} SuperClass A base class to extend. If `mixins` are to be included
|
|
|
|
without a `SuperClass`, pass `null` for SuperClass.
|
|
|
|
@param {Object} mixins One or more objects that contain properties and methods
|
|
|
|
to apply to the new class.
|
|
|
|
*/
|
|
|
|
var defineClass = function(SuperClass) {
|
|
|
|
var Klass = function() {
|
|
|
|
if (!subclassing && this.init) {
|
|
|
|
this.init.apply(this, arguments);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
if (SuperClass) {
|
|
|
|
subclassing = true;
|
|
|
|
Klass.prototype = new SuperClass();
|
|
|
|
subclassing = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (arguments.length > 1) {
|
|
|
|
var extendArgs = Array.prototype.slice.call(arguments, 1);
|
|
|
|
extendArgs.unshift(Klass.prototype);
|
|
|
|
extendClass.apply(Klass.prototype, extendArgs);
|
|
|
|
}
|
|
|
|
|
|
|
|
Klass.constructor = Klass;
|
|
|
|
|
|
|
|
Klass.extend = function() {
|
|
|
|
var args = Array.prototype.slice.call(arguments, 0);
|
|
|
|
args.unshift(Klass);
|
|
|
|
return defineClass.apply(Klass, args);
|
|
|
|
};
|
|
|
|
|
|
|
|
return Klass;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
A base class that can be extended.
|
|
|
|
|
|
|
|
@example
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
var CelestialObject = Klass.extend({
|
|
|
|
init: function(name) {
|
|
|
|
this._super();
|
|
|
|
this.name = name;
|
|
|
|
this.isCelestialObject = true;
|
|
|
|
},
|
|
|
|
greeting: function() {
|
|
|
|
return 'Hello from ' + this.name;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var Planet = CelestialObject.extend({
|
|
|
|
init: function(name) {
|
|
|
|
this._super.apply(this, arguments);
|
|
|
|
this.isPlanet = true;
|
|
|
|
},
|
|
|
|
greeting: function() {
|
|
|
|
return this._super() + '!';
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
var earth = new Planet('Earth');
|
|
|
|
|
|
|
|
console.log(earth instanceof Klass); // true
|
|
|
|
console.log(earth instanceof CelestialObject); // true
|
|
|
|
console.log(earth instanceof Planet); // true
|
|
|
|
|
|
|
|
console.log(earth.isCelestialObject); // true
|
|
|
|
console.log(earth.isPlanet); // true
|
|
|
|
|
|
|
|
console.log(earth.greeting()); // 'Hello from Earth!'
|
|
|
|
```
|
|
|
|
|
|
|
|
@class Klass
|
|
|
|
*/
|
|
|
|
var Klass = defineClass(null, {
|
|
|
|
init: function() {}
|
|
|
|
});
|
|
|
|
|
|
|
|
exports.Klass = Klass;
|
|
|
|
exports.defineClass = defineClass;
|
|
|
|
exports.extendClass = extendClass;
|
|
|
|
|
|
|
|
});
|
|
|
|
define('qunit', ['exports'], function (exports) {
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/* globals test:true */
|
|
|
|
|
|
|
|
var module = QUnit.module;
|
|
|
|
var test = QUnit.test;
|
|
|
|
var skip = QUnit.skip;
|
|
|
|
var only = QUnit.only;
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
exports['default'] = QUnit;
|
2015-05-14 02:12:54 +08:00
|
|
|
|
2016-12-16 05:43:38 +08:00
|
|
|
exports.module = module;
|
|
|
|
exports.test = test;
|
|
|
|
exports.skip = skip;
|
|
|
|
exports.only = only;
|
2015-05-14 02:12:54 +08:00
|
|
|
|
|
|
|
});
|
|
|
|
define("ember", ["exports"], function(__exports__) {
|
|
|
|
__exports__["default"] = window.Ember;
|
|
|
|
});
|
|
|
|
|
|
|
|
var emberQunit = requireModule("ember-qunit");
|
|
|
|
|
|
|
|
window.moduleFor = emberQunit.moduleFor;
|
|
|
|
window.moduleForComponent = emberQunit.moduleForComponent;
|
|
|
|
window.moduleForModel = emberQunit.moduleForModel;
|
|
|
|
window.test = emberQunit.test;
|
|
|
|
window.setResolver = emberQunit.setResolver;
|
|
|
|
|
|
|
|
})();
|
2016-11-26 03:59:16 +08:00
|
|
|
//# sourceMappingURL=ember-qunit.map
|