dist/ember-tests.js in ember-source-2.13.2 vs dist/ember-tests.js in ember-source-2.13.3
- old
+ new
@@ -4,11 +4,11 @@
* @copyright Copyright 2011-2017 Tilde Inc. and contributors
* Portions Copyright 2006-2011 Strobe Inc.
* Portions Copyright 2008-2011 Apple Inc. All rights reserved.
* @license Licensed under MIT license
* See https://raw.github.com/emberjs/ember.js/master/LICENSE
- * @version 2.13.2
+ * @version 2.13.3
*/
var enifed, requireModule, Ember;
var mainContext = this; // Used in ember-environment/lib/global.js
@@ -1104,17 +1104,17 @@
QUnit.test('should pass ESLint', function (assert) {
assert.expect(1);
assert.ok(true, 'container/tests/owner_test.js should pass ESLint\n\n');
});
});
-enifed('container/tests/registry_test', ['exports', 'container/index', 'internal-test-helpers'], function (exports, _containerIndex, _internalTestHelpers) {
+enifed('container/tests/registry_test', ['exports', 'container', 'internal-test-helpers'], function (exports, _container, _internalTestHelpers) {
'use strict';
QUnit.module('Registry');
QUnit.test('A registered factory is returned from resolve', function () {
- var registry = new _containerIndex.Registry();
+ var registry = new _container.Registry();
var PostController = _internalTestHelpers.factory();
registry.register('controller:post', PostController);
var PostControllerFactory = registry.resolve('controller:post');
@@ -1122,20 +1122,20 @@
ok(PostControllerFactory, 'factory is returned');
ok(PostControllerFactory.create() instanceof PostController, 'The return of factory.create is an instance of PostController');
});
QUnit.test('The registered factory returned from resolve is the same factory each time', function () {
- var registry = new _containerIndex.Registry();
+ var registry = new _container.Registry();
var PostController = _internalTestHelpers.factory();
registry.register('controller:post', PostController);
deepEqual(registry.resolve('controller:post'), registry.resolve('controller:post'), 'The return of resolve is always the same');
});
QUnit.test('The registered value returned from resolve is the same value each time even if the value is falsy', function () {
- var registry = new _containerIndex.Registry();
+ var registry = new _container.Registry();
registry.register('falsy:value', null, { instantiate: false });
strictEqual(registry.resolve('falsy:value'), registry.resolve('falsy:value'), 'The return of resolve is always the same');
});
@@ -1146,27 +1146,27 @@
if (fullName === 'falsy:value') {
return null;
}
}
};
- var registry = new _containerIndex.Registry({ resolver: resolver });
+ var registry = new _container.Registry({ resolver: resolver });
strictEqual(registry.resolve('falsy:value'), null);
});
QUnit.test('A registered factory returns true for `has` if an item is registered', function () {
- var registry = new _containerIndex.Registry();
+ var registry = new _container.Registry();
var PostController = _internalTestHelpers.factory();
registry.register('controller:post', PostController);
equal(registry.has('controller:post'), true, 'The `has` method returned true for registered factories');
equal(registry.has('controller:posts'), false, 'The `has` method returned false for unregistered factories');
});
QUnit.test('Throw exception when trying to inject `type:thing` on all type(s)', function () {
- var registry = new _containerIndex.Registry();
+ var registry = new _container.Registry();
var PostController = _internalTestHelpers.factory();
registry.register('controller:post', PostController);
throws(function () {
@@ -1181,11 +1181,11 @@
if (fullName === 'controller:post') {
return PostController;
}
}
};
- var registry = new _containerIndex.Registry({ resolver: resolver });
+ var registry = new _container.Registry({ resolver: resolver });
strictEqual(registry.resolve('controller:post'), PostController, 'The correct factory was provided');
});
QUnit.test('The registry respects the resolver hook for `has`', function () {
@@ -1195,17 +1195,17 @@
if (fullName === 'controller:post') {
return PostController;
}
}
};
- var registry = new _containerIndex.Registry({ resolver: resolver });
+ var registry = new _container.Registry({ resolver: resolver });
ok(registry.has('controller:post'), 'the `has` method uses the resolver hook');
});
QUnit.test('The registry normalizes names when resolving', function () {
- var registry = new _containerIndex.Registry();
+ var registry = new _container.Registry();
var PostController = _internalTestHelpers.factory();
registry.normalizeFullName = function (fullName) {
return 'controller:post';
};
@@ -1215,11 +1215,11 @@
strictEqual(type, PostController, 'Normalizes the name when resolving');
});
QUnit.test('The registry normalizes names when checking if the factory is registered', function () {
- var registry = new _containerIndex.Registry();
+ var registry = new _container.Registry();
var PostController = _internalTestHelpers.factory();
registry.normalizeFullName = function (fullName) {
return fullName === 'controller:normalized' ? 'controller:post' : fullName;
};
@@ -1231,11 +1231,11 @@
});
QUnit.test('validateFullName throws an error if name is incorrect', function () {
expect(2);
- var registry = new _containerIndex.Registry();
+ var registry = new _container.Registry();
var PostController = _internalTestHelpers.factory();
registry.normalize = function (fullName) {
return 'controller:post';
};
@@ -1249,11 +1249,11 @@
registry.validateFullName('route:http://foo.bar.com/baz');
}, /TypeError: Invalid Fullname, expected: 'type:name' got: route:http:\/\/foo.bar.com\/baz/);
});
QUnit.test('The registry normalizes names when injecting', function () {
- var registry = new _containerIndex.Registry();
+ var registry = new _container.Registry();
var PostController = _internalTestHelpers.factory();
var user = { name: 'Stef' };
registry.normalize = function (fullName) {
return 'controller:post';
@@ -1265,30 +1265,30 @@
deepEqual(registry.resolve('controller:post'), user, 'Normalizes the name when injecting');
});
QUnit.test('cannot register an `undefined` factory', function () {
- var registry = new _containerIndex.Registry();
+ var registry = new _container.Registry();
throws(function () {
registry.register('controller:apple', undefined);
}, '');
});
QUnit.test('can re-register a factory', function () {
- var registry = new _containerIndex.Registry();
+ var registry = new _container.Registry();
var FirstApple = _internalTestHelpers.factory('first');
var SecondApple = _internalTestHelpers.factory('second');
registry.register('controller:apple', FirstApple);
registry.register('controller:apple', SecondApple);
ok(registry.resolve('controller:apple').create() instanceof SecondApple);
});
QUnit.test('cannot re-register a factory if it has been resolved', function () {
- var registry = new _containerIndex.Registry();
+ var registry = new _container.Registry();
var FirstApple = _internalTestHelpers.factory('first');
var SecondApple = _internalTestHelpers.factory('second');
registry.register('controller:apple', FirstApple);
strictEqual(registry.resolve('controller:apple'), FirstApple);
@@ -1301,11 +1301,11 @@
});
QUnit.test('registry.has should not accidentally cause injections on that factory to be run. (Mitigate merely on observing)', function () {
expect(1);
- var registry = new _containerIndex.Registry();
+ var registry = new _container.Registry();
var FirstApple = _internalTestHelpers.factory('first');
var SecondApple = _internalTestHelpers.factory('second');
SecondApple.extend = function (a, b, c) {
ok(false, 'should not extend or touch the injected model, merely to inspect existence of another');
@@ -1319,19 +1319,19 @@
});
QUnit.test('registry.has should not error for invalid fullNames)', function () {
expect(1);
- var registry = new _containerIndex.Registry();
+ var registry = new _container.Registry();
ok(!registry.has('foo:bar:baz'));
});
QUnit.test('once resolved, always return the same result', function () {
expect(1);
- var registry = new _containerIndex.Registry();
+ var registry = new _container.Registry();
registry.resolver = {
resolve: function () {
return 'bar';
}
@@ -1347,11 +1347,11 @@
equal(registry.resolve('models:bar'), Bar);
});
QUnit.test('factory resolves are cached', function () {
- var registry = new _containerIndex.Registry();
+ var registry = new _container.Registry();
var PostController = _internalTestHelpers.factory();
var resolveWasCalled = [];
registry.resolver = {
resolve: function (fullName) {
@@ -1367,11 +1367,11 @@
registry.resolve('controller:post');
deepEqual(resolveWasCalled, ['controller:post']);
});
QUnit.test('factory for non extendables (MODEL) resolves are cached', function () {
- var registry = new _containerIndex.Registry();
+ var registry = new _container.Registry();
var PostController = _internalTestHelpers.factory();
var resolveWasCalled = [];
registry.resolver = {
resolve: function (fullName) {
@@ -1387,11 +1387,11 @@
registry.resolve('model:post');
deepEqual(resolveWasCalled, ['model:post']);
});
QUnit.test('factory for non extendables resolves are cached', function () {
- var registry = new _containerIndex.Registry();
+ var registry = new _container.Registry();
var PostController = {};
var resolveWasCalled = [];
registry.resolver = {
resolve: function (fullName) {
@@ -1407,11 +1407,11 @@
registry.resolve('foo:post');
deepEqual(resolveWasCalled, ['foo:post']);
});
QUnit.test('registry.container creates a container', function () {
- var registry = new _containerIndex.Registry();
+ var registry = new _container.Registry();
var PostController = _internalTestHelpers.factory();
registry.register('controller:post', PostController);
var container = registry.container();
var postController = container.lookup('controller:post');
@@ -1430,11 +1430,11 @@
lookupDescription: function (fullName) {
return fullName + '-resolver';
}
};
- var registry = new _containerIndex.Registry({ fallback: fallback, resolver: resolver });
+ var registry = new _container.Registry({ fallback: fallback, resolver: resolver });
equal(registry.describe('controller:post'), 'controller:post-resolver', '`describe` handled by the resolver first.');
registry.resolver = null;
@@ -1456,11 +1456,11 @@
normalize: function (fullName) {
return fullName + '-resolver';
}
};
- var registry = new _containerIndex.Registry({ fallback: fallback, resolver: resolver });
+ var registry = new _container.Registry({ fallback: fallback, resolver: resolver });
equal(registry.normalizeFullName('controller:post'), 'controller:post-resolver', '`normalizeFullName` handled by the resolver first.');
registry.resolver = null;
@@ -1482,11 +1482,11 @@
makeToString: function (fullName) {
return fullName + '-resolver';
}
};
- var registry = new _containerIndex.Registry({ fallback: fallback, resolver: resolver });
+ var registry = new _container.Registry({ fallback: fallback, resolver: resolver });
equal(registry.makeToString('controller:post'), 'controller:post-resolver', '`makeToString` handled by the resolver first.');
registry.resolver = null;
@@ -1496,13 +1496,13 @@
equal(registry.makeToString('controller:post'), 'controller:post', '`makeToString` by default returns argument.');
});
QUnit.test('`resolve` can be handled by a fallback registry', function () {
- var fallback = new _containerIndex.Registry();
+ var fallback = new _container.Registry();
- var registry = new _containerIndex.Registry({ fallback: fallback });
+ var registry = new _container.Registry({ fallback: fallback });
var PostController = _internalTestHelpers.factory();
fallback.register('controller:post', PostController);
var PostControllerFactory = registry.resolve('controller:post');
@@ -1510,66 +1510,66 @@
ok(PostControllerFactory, 'factory is returned');
ok(PostControllerFactory.create() instanceof PostController, 'The return of factory.create is an instance of PostController');
});
QUnit.test('`has` can be handled by a fallback registry', function () {
- var fallback = new _containerIndex.Registry();
+ var fallback = new _container.Registry();
- var registry = new _containerIndex.Registry({ fallback: fallback });
+ var registry = new _container.Registry({ fallback: fallback });
var PostController = _internalTestHelpers.factory();
fallback.register('controller:post', PostController);
equal(registry.has('controller:post'), true, 'Fallback registry is checked for registration');
});
QUnit.test('`getInjections` includes injections from a fallback registry', function () {
- var fallback = new _containerIndex.Registry();
- var registry = new _containerIndex.Registry({ fallback: fallback });
+ var fallback = new _container.Registry();
+ var registry = new _container.Registry({ fallback: fallback });
equal(registry.getInjections('model:user').length, 0, 'No injections in the primary registry');
fallback.injection('model:user', 'post', 'model:post');
equal(registry.getInjections('model:user').length, 1, 'Injections from the fallback registry are merged');
});
QUnit.test('`getTypeInjections` includes type injections from a fallback registry', function () {
- var fallback = new _containerIndex.Registry();
- var registry = new _containerIndex.Registry({ fallback: fallback });
+ var fallback = new _container.Registry();
+ var registry = new _container.Registry({ fallback: fallback });
equal(registry.getTypeInjections('model').length, 0, 'No injections in the primary registry');
fallback.injection('model', 'source', 'source:main');
equal(registry.getTypeInjections('model').length, 1, 'Injections from the fallback registry are merged');
});
QUnit.test('`getFactoryInjections` includes factory injections from a fallback registry', function () {
- var fallback = new _containerIndex.Registry();
- var registry = new _containerIndex.Registry({ fallback: fallback });
+ var fallback = new _container.Registry();
+ var registry = new _container.Registry({ fallback: fallback });
equal(registry.getFactoryInjections('model:user').length, 0, 'No factory injections in the primary registry');
fallback.factoryInjection('model:user', 'store', 'store:main');
equal(registry.getFactoryInjections('model:user').length, 1, 'Factory injections from the fallback registry are merged');
});
QUnit.test('`getFactoryTypeInjections` includes factory type injections from a fallback registry', function () {
- var fallback = new _containerIndex.Registry();
- var registry = new _containerIndex.Registry({ fallback: fallback });
+ var fallback = new _container.Registry();
+ var registry = new _container.Registry({ fallback: fallback });
equal(registry.getFactoryTypeInjections('model').length, 0, 'No factory type injections in the primary registry');
fallback.factoryInjection('model', 'store', 'store:main');
equal(registry.getFactoryTypeInjections('model').length, 1, 'Factory type injections from the fallback registry are merged');
});
QUnit.test('`knownForType` contains keys for each item of a given type', function () {
- var registry = new _containerIndex.Registry();
+ var registry = new _container.Registry();
registry.register('foo:bar-baz', 'baz');
registry.register('foo:qux-fez', 'fez');
var found = registry.knownForType('foo');
@@ -1579,12 +1579,12 @@
'foo:qux-fez': true
});
});
QUnit.test('`knownForType` includes fallback registry results', function () {
- var fallback = new _containerIndex.Registry();
- var registry = new _containerIndex.Registry({ fallback: fallback });
+ var fallback = new _container.Registry();
+ var registry = new _container.Registry({ fallback: fallback });
registry.register('foo:bar-baz', 'baz');
registry.register('foo:qux-fez', 'fez');
fallback.register('foo:zurp-zorp', 'zorp');
@@ -1607,11 +1607,11 @@
return { 'foo:yorp': true };
}
};
- var registry = new _containerIndex.Registry({
+ var registry = new _container.Registry({
resolver: resolver
});
registry.register('foo:bar-baz', 'baz');
var found = registry.knownForType('foo');
@@ -1626,11 +1626,11 @@
expect(2);
var registry = undefined;
expectDeprecation(function () {
- registry = new _containerIndex.Registry({
+ registry = new _container.Registry({
resolver: function (fullName) {
return fullName + '-resolved';
}
});
}, 'Passing a `resolver` function into a Registry is deprecated. Please pass in a Resolver object with a `resolve` method.');
@@ -1639,11 +1639,11 @@
});
QUnit.test('resolver.expandLocalLookup is not required', function (assert) {
assert.expect(1);
- var registry = new _containerIndex.Registry({
+ var registry = new _container.Registry({
resolver: {}
});
var result = registry.expandLocalLookup('foo:bar', {
source: 'baz:qux'
@@ -1663,11 +1663,11 @@
return 'foo:qux/bar';
}
};
- var registry = new _containerIndex.Registry({
+ var registry = new _container.Registry({
resolver: resolver
});
var result = registry.expandLocalLookup('foo:bar', {
source: 'baz:qux'
@@ -1697,15 +1697,15 @@
return 'foo:qux/bar-resolver';
}
};
- var fallbackRegistry = new _containerIndex.Registry({
+ var fallbackRegistry = new _container.Registry({
resolver: fallbackResolver
});
- var registry = new _containerIndex.Registry({
+ var registry = new _container.Registry({
fallback: fallbackRegistry,
resolver: resolver
});
var result = registry.expandLocalLookup('foo:bar', {
@@ -1741,11 +1741,11 @@
return 'foo:qux/bar';
}
};
- var registry = new _containerIndex.Registry({
+ var registry = new _container.Registry({
resolver: resolver
});
result = registry.expandLocalLookup('foo:bar', {
source: 'baz:qux'
@@ -1770,11 +1770,11 @@
return 'foo:qux/bar';
}
};
- var registry = new _containerIndex.Registry({
+ var registry = new _container.Registry({
resolver: resolver
});
result = registry.expandLocalLookup('foo:bar', {
source: 'baz:qux'
@@ -1803,11 +1803,11 @@
return 'foo:qux/bar';
}
};
- var registry = new _containerIndex.Registry({
+ var registry = new _container.Registry({
resolver: resolver
});
registry.resolve('foo:bar', {
source: 'baz:qux'
@@ -1835,11 +1835,11 @@
return null;
}
}
};
- var registry = new _containerIndex.Registry({
+ var registry = new _container.Registry({
resolver: resolver
});
result = registry.has('foo:bar', {
source: 'baz:qux'
@@ -1852,9 +1852,21 @@
});
assert.ok(!result, 'foo:baz/qux not found');
assert.deepEqual(['foo:qux/bar'], resolvedFullNames);
+ });
+
+ QUnit.module('Registry privatize');
+
+ QUnit.test('valid format', function (assert) {
+ var privatized = _container.privatize(['secret:factory']);
+ var matched = privatized.match(/^([^:]+):([^:]+)-(\d+)$/);
+
+ assert.ok(matched, 'privatized format was recognized');
+ assert.equal(matched[1], 'secret');
+ assert.equal(matched[2], 'factory');
+ assert.ok(/^\d+$/.test(matched[3]));
});
});
enifed('container/tests/registry_test.lint-test', ['exports'], function (exports) {
'use strict';