[Code Style] Run gulp fixstyle
...to apply code style settings from #142.
This commit is contained in:
@@ -21,10 +21,10 @@
|
||||
*****************************************************************************/
|
||||
|
||||
define([
|
||||
|
||||
|
||||
'legacyRegistry'
|
||||
], function (
|
||||
|
||||
|
||||
legacyRegistry
|
||||
) {
|
||||
|
||||
|
||||
@@ -102,4 +102,4 @@ define([
|
||||
};
|
||||
|
||||
return FrameworkLayer;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -106,8 +106,8 @@ define(
|
||||
*/
|
||||
Bundle.prototype.getSourcePath = function (sourceFile) {
|
||||
var subpath = sourceFile ?
|
||||
[ this.definition.sources, sourceFile ] :
|
||||
[ this.definition.sources ];
|
||||
[this.definition.sources, sourceFile] :
|
||||
[this.definition.sources];
|
||||
|
||||
return this.resolvePath(subpath);
|
||||
};
|
||||
@@ -124,8 +124,8 @@ define(
|
||||
*/
|
||||
Bundle.prototype.getResourcePath = function (resourceFile) {
|
||||
var subpath = resourceFile ?
|
||||
[ this.definition.resources, resourceFile ] :
|
||||
[ this.definition.resources ];
|
||||
[this.definition.resources, resourceFile] :
|
||||
[this.definition.resources];
|
||||
|
||||
return this.resolvePath(subpath);
|
||||
};
|
||||
@@ -142,8 +142,8 @@ define(
|
||||
*/
|
||||
Bundle.prototype.getLibraryPath = function (libraryFile) {
|
||||
var subpath = libraryFile ?
|
||||
[ this.definition.libraries, libraryFile ] :
|
||||
[ this.definition.libraries ];
|
||||
[this.definition.libraries, libraryFile] :
|
||||
[this.definition.libraries];
|
||||
|
||||
return this.resolvePath(subpath);
|
||||
};
|
||||
|
||||
@@ -73,7 +73,9 @@ define(
|
||||
// loadBundleDefinition, so at this point they are safe
|
||||
// to discard.
|
||||
function filterBundles(array) {
|
||||
return array.filter(function (x) { return x !== undefined; });
|
||||
return array.filter(function (x) {
|
||||
return x !== undefined;
|
||||
});
|
||||
}
|
||||
|
||||
// Load a definition for a bundle
|
||||
|
||||
@@ -92,7 +92,9 @@ define(
|
||||
// Always return a static value; used to represent plain
|
||||
// metadata as a single dependency in Angular.
|
||||
function staticFunction(value) {
|
||||
return function () { return value; };
|
||||
return function () {
|
||||
return value;
|
||||
};
|
||||
}
|
||||
|
||||
// Utility function; create the second argument for Angular's
|
||||
|
||||
@@ -50,13 +50,17 @@ define(
|
||||
it("calls injected stages in order", function () {
|
||||
var result;
|
||||
|
||||
initializer.runApplication([]).then(function (v) { result = v; });
|
||||
initializer.runApplication([]).then(function (v) {
|
||||
result = v;
|
||||
});
|
||||
|
||||
waitsFor(
|
||||
function () { return result !== undefined; },
|
||||
"promise resolution",
|
||||
250
|
||||
);
|
||||
function () {
|
||||
return result !== undefined;
|
||||
},
|
||||
"promise resolution",
|
||||
250
|
||||
);
|
||||
|
||||
runs(function () {
|
||||
expect(result).toEqual(
|
||||
@@ -67,4 +71,4 @@ define(
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
);
|
||||
|
||||
@@ -95,4 +95,4 @@ define(
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
);
|
||||
|
||||
@@ -104,4 +104,4 @@ define(
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
);
|
||||
|
||||
@@ -44,7 +44,7 @@ define(
|
||||
|
||||
beforeEach(function () {
|
||||
testBundles = {
|
||||
"bundles.json": [ "bundle/a", "bundle/b"],
|
||||
"bundles.json": ["bundle/a", "bundle/b"],
|
||||
"bundle/a/bundle.json": {"someValue": 6},
|
||||
"bundle/b/bundle.json": {"someValue": 7}
|
||||
};
|
||||
@@ -54,7 +54,7 @@ define(
|
||||
mockLog = jasmine.createSpyObj("$log", ["error", "warn", "info", "debug"]);
|
||||
mockRegistry = jasmine.createSpyObj(
|
||||
'legacyRegistry',
|
||||
[ 'list', 'contains', 'get' ]
|
||||
['list', 'contains', 'get']
|
||||
);
|
||||
mockRegistry.list.andReturn([]);
|
||||
mockRegistry.contains.andReturn(false);
|
||||
@@ -145,4 +145,4 @@ define(
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
);
|
||||
|
||||
@@ -78,17 +78,17 @@ define(
|
||||
|
||||
it("reports all extensions that have been declared", function () {
|
||||
var bundle = new Bundle(PATH, {
|
||||
extensions: { things: [ {}, {}, {} ] }
|
||||
extensions: { things: [{}, {}, {}] }
|
||||
});
|
||||
expect(bundle.getExtensions("things").length).toEqual(3);
|
||||
});
|
||||
|
||||
it("reports an empty list for extensions that have not been declared", function () {
|
||||
var bundle = new Bundle(PATH, {
|
||||
extensions: { things: [ {}, {}, {} ] }
|
||||
extensions: { things: [{}, {}, {}] }
|
||||
});
|
||||
expect(bundle.getExtensions("stuffs").length).toEqual(0);
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
);
|
||||
|
||||
@@ -104,4 +104,4 @@ define(
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
);
|
||||
|
||||
@@ -40,7 +40,9 @@ define(
|
||||
mockSorter = jasmine.createSpyObj("sorter", ["sort"]);
|
||||
customRegistrars = {};
|
||||
|
||||
mockSorter.sort.andCallFake(function (v) { return v; });
|
||||
mockSorter.sort.andCallFake(function (v) {
|
||||
return v;
|
||||
});
|
||||
|
||||
registrar = new ExtensionRegistrar(
|
||||
mockApp,
|
||||
@@ -51,7 +53,7 @@ define(
|
||||
});
|
||||
|
||||
it("registers extensions using the factory", function () {
|
||||
registrar.registerExtensions({ things: [ {} ] });
|
||||
registrar.registerExtensions({ things: [{}] });
|
||||
expect(mockApp.factory).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -60,7 +62,7 @@ define(
|
||||
mockApp.factory.andCallFake(function (name, value) {
|
||||
callbacks[name] = value[value.length - 1];
|
||||
});
|
||||
registrar.registerExtensions({ things: [ {} ] });
|
||||
registrar.registerExtensions({ things: [{}] });
|
||||
expect(callbacks["things[]"]).toBeDefined();
|
||||
|
||||
// Verify dependency echo behavior
|
||||
@@ -68,9 +70,9 @@ define(
|
||||
});
|
||||
|
||||
it("warns if multiple registrations are made for the same category of extension", function () {
|
||||
registrar.registerExtensions({ things: [ {} ] });
|
||||
registrar.registerExtensions({ things: [{}] });
|
||||
expect(mockLog.warn).not.toHaveBeenCalled();
|
||||
registrar.registerExtensions({ things: [ {} ] });
|
||||
registrar.registerExtensions({ things: [{}] });
|
||||
expect(mockLog.warn).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -81,14 +83,14 @@ define(
|
||||
});
|
||||
// Nobody has registered tests[], but it looks like an extension dependency,
|
||||
// so register it as an empty array.
|
||||
registrar.registerExtensions({ things: [ { depends: [ "tests[]", "other" ] } ] });
|
||||
registrar.registerExtensions({ things: [{ depends: ["tests[]", "other"] }] });
|
||||
expect(lengths["tests[]"]).toEqual(1);
|
||||
expect(lengths.other).toBeUndefined();
|
||||
});
|
||||
|
||||
it("invokes custom registrars (not app.factory) when available", function () {
|
||||
customRegistrars.things = jasmine.createSpy("things");
|
||||
registrar.registerExtensions({ things: [ {} ] });
|
||||
registrar.registerExtensions({ things: [{}] });
|
||||
expect(mockApp.factory).not.toHaveBeenCalled();
|
||||
expect(customRegistrars.things).toHaveBeenCalled();
|
||||
});
|
||||
@@ -98,13 +100,15 @@ define(
|
||||
var a = { a: 'a' }, b = { b: 'b' }, c = { c: 'c' };
|
||||
|
||||
// Fake sorting; just reverse the array
|
||||
mockSorter.sort.andCallFake(function (v) { return v.reverse(); });
|
||||
mockSorter.sort.andCallFake(function (v) {
|
||||
return v.reverse();
|
||||
});
|
||||
|
||||
// Register the extensions
|
||||
registrar.registerExtensions({ things: [ a, b, c ] });
|
||||
registrar.registerExtensions({ things: [a, b, c] });
|
||||
|
||||
// Verify registration interactions occurred in reverse-order
|
||||
[ c, b, a ].forEach(function (extension, index) {
|
||||
[c, b, a].forEach(function (extension, index) {
|
||||
expect(mockApp.factory.calls[index].args[1][0]())
|
||||
.toEqual(extension);
|
||||
});
|
||||
@@ -112,4 +116,4 @@ define(
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
);
|
||||
|
||||
@@ -93,4 +93,4 @@ define(
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
);
|
||||
|
||||
@@ -37,8 +37,8 @@ define(
|
||||
beforeEach(function () {
|
||||
registered = {};
|
||||
|
||||
mockApp = jasmine.createSpyObj("app", [ "service" ]);
|
||||
mockLog = jasmine.createSpyObj("$log", [ "error", "warn", "info", "debug" ]);
|
||||
mockApp = jasmine.createSpyObj("app", ["service"]);
|
||||
mockLog = jasmine.createSpyObj("$log", ["error", "warn", "info", "debug"]);
|
||||
|
||||
mockApp.service.andCallFake(function (name, value) {
|
||||
var factory = value[value.length - 1];
|
||||
@@ -66,11 +66,21 @@ define(
|
||||
it("allows composite services to be registered", function () {
|
||||
// Prepare components that look like resolved extensions
|
||||
var components, name;
|
||||
function MyDecorator() { return {}; }
|
||||
function MyOtherDecorator() { return {}; }
|
||||
function MyProvider() { return {}; }
|
||||
function MyOtherProvider() { return {}; }
|
||||
function MyAggregator() { return {}; }
|
||||
function MyDecorator() {
|
||||
return {};
|
||||
}
|
||||
function MyOtherDecorator() {
|
||||
return {};
|
||||
}
|
||||
function MyProvider() {
|
||||
return {};
|
||||
}
|
||||
function MyOtherProvider() {
|
||||
return {};
|
||||
}
|
||||
function MyAggregator() {
|
||||
return {};
|
||||
}
|
||||
|
||||
components = [
|
||||
MyDecorator,
|
||||
@@ -85,11 +95,13 @@ define(
|
||||
MyProvider.type = "provider";
|
||||
MyOtherProvider.type = "provider";
|
||||
MyAggregator.type = "aggregator";
|
||||
components.forEach(function (c) { c.provides = "testService"; });
|
||||
components.forEach(function (c) {
|
||||
c.provides = "testService";
|
||||
});
|
||||
|
||||
// Add some test dependencies, to check prepending
|
||||
MyOtherDecorator.depends = [ "someOtherService" ];
|
||||
MyAggregator.depends = [ "tests[]" ];
|
||||
MyOtherDecorator.depends = ["someOtherService"];
|
||||
MyAggregator.depends = ["tests[]"];
|
||||
|
||||
// Register!
|
||||
compositor.registerCompositeServices(components);
|
||||
@@ -117,16 +129,24 @@ define(
|
||||
it("allows registered composite services to be instantiated", function () {
|
||||
// Prepare components that look like resolved extensions
|
||||
var components, name;
|
||||
function MyProvider() { return {}; }
|
||||
function MyOtherProvider() { return {}; }
|
||||
function MyAggregator() { return {}; }
|
||||
function MyProvider() {
|
||||
return {};
|
||||
}
|
||||
function MyOtherProvider() {
|
||||
return {};
|
||||
}
|
||||
function MyAggregator() {
|
||||
return {};
|
||||
}
|
||||
|
||||
components = [ MyProvider, MyAggregator, MyOtherProvider ];
|
||||
components = [MyProvider, MyAggregator, MyOtherProvider];
|
||||
|
||||
MyProvider.type = "provider";
|
||||
MyOtherProvider.type = "provider";
|
||||
MyAggregator.type = "aggregator";
|
||||
components.forEach(function (c) { c.provides = "testService"; });
|
||||
components.forEach(function (c) {
|
||||
c.provides = "testService";
|
||||
});
|
||||
|
||||
// Register!
|
||||
compositor.registerCompositeServices(components);
|
||||
@@ -149,11 +169,17 @@ define(
|
||||
it("warns and skips components with no service type", function () {
|
||||
// Prepare components that look like resolved extensions
|
||||
var components;
|
||||
function MyProvider() { return {}; }
|
||||
function MyDecorator() { return {}; }
|
||||
function MyAggregator() { return {}; }
|
||||
function MyProvider() {
|
||||
return {};
|
||||
}
|
||||
function MyDecorator() {
|
||||
return {};
|
||||
}
|
||||
function MyAggregator() {
|
||||
return {};
|
||||
}
|
||||
|
||||
components = [ MyProvider, MyAggregator, MyDecorator ];
|
||||
components = [MyProvider, MyAggregator, MyDecorator];
|
||||
|
||||
MyProvider.type = "provider";
|
||||
MyDecorator.type = "decorator";
|
||||
@@ -175,9 +201,11 @@ define(
|
||||
it("warns about and skips aggregators with zero providers", function () {
|
||||
// Prepare components that look like resolved extensions
|
||||
var components;
|
||||
function MyAggregator() { return {}; }
|
||||
function MyAggregator() {
|
||||
return {};
|
||||
}
|
||||
|
||||
components = [ MyAggregator ];
|
||||
components = [MyAggregator];
|
||||
|
||||
MyAggregator.type = "aggregator";
|
||||
MyAggregator.provides = "testService";
|
||||
@@ -195,9 +223,11 @@ define(
|
||||
it("warns about and skips decorators with nothing to decorate", function () {
|
||||
// Prepare components that look like resolved extensions
|
||||
var components;
|
||||
function MyDecorator() { return {}; }
|
||||
function MyDecorator() {
|
||||
return {};
|
||||
}
|
||||
|
||||
components = [ MyDecorator ];
|
||||
components = [MyDecorator];
|
||||
|
||||
MyDecorator.type = "decorator";
|
||||
MyDecorator.provides = "testService";
|
||||
@@ -214,4 +244,4 @@ define(
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
);
|
||||
|
||||
@@ -60,16 +60,20 @@ define(
|
||||
var result;
|
||||
|
||||
resolver.resolveBundles([
|
||||
new Bundle("x", { extensions: { tests: [ {}, {}, {} ] } }),
|
||||
new Bundle("y", { extensions: { tests: [ {}, {} ], others: [ {}, {} ] } }),
|
||||
new Bundle("z", { extensions: { others: [ {} ] } })
|
||||
]).then(function (v) { result = v; });
|
||||
new Bundle("x", { extensions: { tests: [{}, {}, {}] } }),
|
||||
new Bundle("y", { extensions: { tests: [{}, {}], others: [{}, {}] } }),
|
||||
new Bundle("z", { extensions: { others: [{}] } })
|
||||
]).then(function (v) {
|
||||
result = v;
|
||||
});
|
||||
|
||||
waitsFor(
|
||||
function () { return result !== undefined; },
|
||||
"promise resolution",
|
||||
250
|
||||
);
|
||||
function () {
|
||||
return result !== undefined;
|
||||
},
|
||||
"promise resolution",
|
||||
250
|
||||
);
|
||||
|
||||
// Should get back the result from the resolver, and
|
||||
// should be binned by extension category.
|
||||
@@ -81,9 +85,9 @@ define(
|
||||
|
||||
it("configures require before loading implementations", function () {
|
||||
var bundles = [
|
||||
new Bundle("x", { extensions: { tests: [ {}, {}, {} ] } }),
|
||||
new Bundle("y", { extensions: { tests: [ {}, {} ], others: [ {}, {} ] } }),
|
||||
new Bundle("z", { extensions: { others: [ {} ] } })
|
||||
new Bundle("x", { extensions: { tests: [{}, {}, {}] } }),
|
||||
new Bundle("y", { extensions: { tests: [{}, {}], others: [{}, {}] } }),
|
||||
new Bundle("z", { extensions: { others: [{}] } })
|
||||
];
|
||||
|
||||
resolver.resolveBundles(bundles);
|
||||
@@ -93,4 +97,4 @@ define(
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
);
|
||||
|
||||
@@ -33,7 +33,9 @@ define(
|
||||
resolver;
|
||||
|
||||
// Test implementation, to load from the mock loader
|
||||
function Constructor() { return { someKey: "some value" }; }
|
||||
function Constructor() {
|
||||
return { someKey: "some value" };
|
||||
}
|
||||
Constructor.someProperty = "some static value";
|
||||
|
||||
beforeEach(function () {
|
||||
@@ -52,18 +54,22 @@ define(
|
||||
it("requests implementations from the implementation loader", function () {
|
||||
var bundle = new Bundle("w", {
|
||||
sources: "x",
|
||||
extensions: { tests: [ { implementation: "y/z.js" } ] }
|
||||
extensions: { tests: [{ implementation: "y/z.js" }] }
|
||||
}),
|
||||
extension = bundle.getExtensions("tests")[0],
|
||||
result;
|
||||
|
||||
resolver.resolve(extension).then(function (v) { result = v; });
|
||||
resolver.resolve(extension).then(function (v) {
|
||||
result = v;
|
||||
});
|
||||
|
||||
waitsFor(
|
||||
function () { return result !== undefined; },
|
||||
"promise resolution",
|
||||
250
|
||||
);
|
||||
function () {
|
||||
return result !== undefined;
|
||||
},
|
||||
"promise resolution",
|
||||
250
|
||||
);
|
||||
|
||||
runs(function () {
|
||||
// Verify that the right file was requested
|
||||
@@ -79,22 +85,26 @@ define(
|
||||
it("issues a warning and defaults to plain definition if load fails", function () {
|
||||
var bundle = new Bundle("w", {
|
||||
sources: "x",
|
||||
extensions: { tests: [ {
|
||||
extensions: { tests: [{
|
||||
someOtherKey: "some other value",
|
||||
implementation: "y/z.js"
|
||||
} ] }
|
||||
}] }
|
||||
}),
|
||||
extension = bundle.getExtensions("tests")[0],
|
||||
result;
|
||||
|
||||
mockLoader.load.andReturn(Promise.reject(new Error("test error")));
|
||||
resolver.resolve(extension).then(function (v) { result = v; });
|
||||
resolver.resolve(extension).then(function (v) {
|
||||
result = v;
|
||||
});
|
||||
|
||||
waitsFor(
|
||||
function () { return result !== undefined; },
|
||||
"promise resolution",
|
||||
250
|
||||
);
|
||||
function () {
|
||||
return result !== undefined;
|
||||
},
|
||||
"promise resolution",
|
||||
250
|
||||
);
|
||||
|
||||
runs(function () {
|
||||
// Should have gotten a warning
|
||||
@@ -109,18 +119,22 @@ define(
|
||||
it("ensures implementation properties are exposed", function () {
|
||||
var bundle = new Bundle("w", {
|
||||
sources: "x",
|
||||
extensions: { tests: [ { implementation: "y/z.js" } ] }
|
||||
extensions: { tests: [{ implementation: "y/z.js" }] }
|
||||
}),
|
||||
extension = bundle.getExtensions("tests")[0],
|
||||
result;
|
||||
|
||||
resolver.resolve(extension).then(function (v) { result = v; });
|
||||
resolver.resolve(extension).then(function (v) {
|
||||
result = v;
|
||||
});
|
||||
|
||||
waitsFor(
|
||||
function () { return result !== undefined; },
|
||||
"promise resolution",
|
||||
250
|
||||
);
|
||||
function () {
|
||||
return result !== undefined;
|
||||
},
|
||||
"promise resolution",
|
||||
250
|
||||
);
|
||||
|
||||
runs(function () {
|
||||
// Verify that the right file was requested
|
||||
@@ -136,4 +150,4 @@ define(
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
);
|
||||
|
||||
@@ -53,17 +53,21 @@ define(
|
||||
var result;
|
||||
|
||||
// Load and get the result
|
||||
loader.load("xyz.js").then(function (v) { result = v; });
|
||||
loader.load("xyz.js").then(function (v) {
|
||||
result = v;
|
||||
});
|
||||
|
||||
expect(result).toBeUndefined();
|
||||
|
||||
required.fulfill("test result");
|
||||
|
||||
waitsFor(
|
||||
function () { return result !== undefined; },
|
||||
"promise resolution",
|
||||
250
|
||||
);
|
||||
function () {
|
||||
return result !== undefined;
|
||||
},
|
||||
"promise resolution",
|
||||
250
|
||||
);
|
||||
|
||||
runs(function () {
|
||||
expect(result).toEqual("test result");
|
||||
@@ -76,19 +80,25 @@ define(
|
||||
|
||||
// Load and get the result
|
||||
loader.load("xyz.js").then(
|
||||
function (v) { result = v; },
|
||||
function (v) { rejection = v; }
|
||||
);
|
||||
function (v) {
|
||||
result = v;
|
||||
},
|
||||
function (v) {
|
||||
rejection = v;
|
||||
}
|
||||
);
|
||||
|
||||
expect(result).toBeUndefined();
|
||||
|
||||
required.reject("test result");
|
||||
|
||||
waitsFor(
|
||||
function () { return rejection !== undefined; },
|
||||
"promise resolution",
|
||||
250
|
||||
);
|
||||
function () {
|
||||
return rejection !== undefined;
|
||||
},
|
||||
"promise resolution",
|
||||
250
|
||||
);
|
||||
|
||||
runs(function () {
|
||||
expect(result).toBeUndefined();
|
||||
@@ -98,4 +108,4 @@ define(
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
);
|
||||
|
||||
@@ -31,7 +31,7 @@ define(
|
||||
beforeEach(function () {
|
||||
mockRequire = jasmine.createSpyObj(
|
||||
"requirejs",
|
||||
[ "config" ]
|
||||
["config"]
|
||||
);
|
||||
configurator = new RequireConfigurator(mockRequire);
|
||||
});
|
||||
@@ -79,4 +79,4 @@ define(
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user