[Code Style] Run gulp fixstyle

...to apply code style settings from #142.
This commit is contained in:
Victor Woeltjen
2016-05-19 11:29:13 -07:00
parent f12b9704d9
commit fa77139077
440 changed files with 1885 additions and 1662 deletions

View File

@ -316,7 +316,7 @@ define([
"transactionService"
]
}
],
]
}
});
});

View File

@ -24,8 +24,12 @@ define(
function () {
// Utility functions for reducing truth arrays
function and(a, b) { return a && b; }
function or(a, b) { return a || b; }
function and(a, b) {
return a && b;
}
function or(a, b) {
return a || b;
}
/**

View File

@ -38,7 +38,9 @@ define(
beforeEach(function () {
capabilities = {
type: {
getProperties: function () { return []; },
getProperties: function () {
return [];
},
hasFeature: jasmine.createSpy('hasFeature')
},
persistence: jasmine.createSpyObj("persistence", ["persist"]),
@ -47,11 +49,21 @@ define(
model = {};
input = {};
object = {
getId: function () { return 'test-id'; },
getCapability: function (k) { return capabilities[k]; },
getModel: function () { return model; },
useCapability: function (k, v) { return capabilities[k](v); },
hasCapability: function () { return true; }
getId: function () {
return 'test-id';
},
getCapability: function (k) {
return capabilities[k];
},
getModel: function () {
return model;
},
useCapability: function (k, v) {
return capabilities[k](v);
},
hasCapability: function () {
return true;
}
};
context = { someKey: "some value", domainObject: object };
dialogService = {

View File

@ -30,14 +30,22 @@ define(
beforeEach(function () {
type = {
getProperties: function () { return properties; }
getProperties: function () {
return properties;
}
};
model = { x: "initial value" };
properties = ["x", "y", "z"].map(function (k) {
return {
getValue: function (model) { return model[k]; },
setValue: function (model, v) { model[k] = v; },
getDefinition: function () { return { control: 'textfield '}; }
getValue: function (model) {
return model[k];
},
setValue: function (model, v) {
model[k] = v;
},
getDefinition: function () {
return { control: 'textfield '};
}
};
});

View File

@ -126,7 +126,9 @@ define(
it("reads properties from getters", function () {
var structure, state;
testABC.a = function () { return "from a getter!"; };
testABC.a = function () {
return "from a getter!";
};
toolbar.setSelection([testABC]);
structure = toolbar.getStructure();

View File

@ -40,7 +40,9 @@ define(
});
// Return constructors
mockFormats = KEYS.map(function (k, i) {
function MockFormat() { return mockFormatInstances[i]; }
function MockFormat() {
return mockFormatInstances[i];
}
MockFormat.key = k;
return MockFormat;
});

View File

@ -69,7 +69,9 @@ define(
function updateList(ids) {
function updateSelectedObjects(objects) {
// Look up from the
function getObject(id) { return objects[id]; }
function getObject(id) {
return objects[id];
}
self.selectedObjects =
ids.filter(getObject).map(getObject);
}

View File

@ -39,7 +39,9 @@ define(
);
testIndicatorA = {};
testIndicatorB = function () { return mockIndicator; };
testIndicatorB = function () {
return mockIndicator;
};
testIndicatorC = { template: "someTemplate" };
testIndicators = [

View File

@ -32,7 +32,9 @@ define(
function TestObject(id, context) {
return {
getId: function () { return id; },
getId: function () {
return id;
},
getCapability: function (key) {
return key === 'context' ? context : undefined;
}

View File

@ -35,7 +35,9 @@ define(
beforeEach(function () {
mockScope = jasmine.createSpyObj("$scope", ["$watch"]);
mockTimeout = jasmine.createSpy("$timeout");
mockTimeout.andCallFake(function (cb) { cb(); });
mockTimeout.andCallFake(function (cb) {
cb();
});
mockScope.ngModel = {};
controller = new ViewSwitcherController(mockScope, mockTimeout);
});

View File

@ -46,7 +46,9 @@ define(
*/
function RootModelProvider(roots, $q, $log) {
// Pull out identifiers to used as ROOT's
var ids = roots.map(function (root) { return root.id; });
var ids = roots.map(function (root) {
return root.id;
});
// Assign an initial location to root models
roots.forEach(function (root) {

View File

@ -33,8 +33,12 @@ define(
}
},
identity: {
toModelValue: function (v) { return v; },
toFormValue: function (v) { return v; }
toModelValue: function (v) {
return v;
},
toFormValue: function (v) {
return v;
}
}
},
ARRAY_SUFFIX = '[]';

View File

@ -33,29 +33,41 @@ define(
actionProvider;
function SimpleAction() {
return { perform: function () { return "simple"; } };
return { perform: function () {
return "simple";
} };
}
function CategorizedAction() {
return { perform: function () { return "categorized"; } };
return { perform: function () {
return "categorized";
} };
}
CategorizedAction.category = "someCategory";
function KeyedAction() {
return { perform: function () { return "keyed"; } };
return { perform: function () {
return "keyed";
} };
}
KeyedAction.key = "someKey";
function CategorizedKeyedAction() {
return { perform: function () { return "both"; } };
return { perform: function () {
return "both";
} };
}
CategorizedKeyedAction.key = "someKey";
CategorizedKeyedAction.category = "someCategory";
function MetadataAction() {
return {
perform: function () { return "metadata"; },
getMetadata: function () { return "custom metadata"; }
perform: function () {
return "metadata";
},
getMetadata: function () {
return "custom metadata";
}
};
}
MetadataAction.key = "metadata";

View File

@ -114,7 +114,9 @@ define(
mockObjectService.getObjects.andReturn(mockPromise({x: mockChild}));
mockChild.getCapability.andReturn(undefined);
composition.invoke().then(function (c) { result = c; });
composition.invoke().then(function (c) {
result = c;
});
// Should have been added by a wrapper
expect(result[0].getCapability('context')).toBeDefined();

View File

@ -31,16 +31,22 @@ define(
var mockLog,
provider;
function BasicCapability() { return; }
function BasicCapability() {
return;
}
BasicCapability.key = "basic";
function ApplicableCapability() { return; }
function ApplicableCapability() {
return;
}
ApplicableCapability.key = "applicable";
ApplicableCapability.appliesTo = function (model) {
return !model.isNotApplicable;
};
function KeylessCapability() { return; }
function KeylessCapability() {
return;
}
beforeEach(function () {
mockLog = jasmine.createSpyObj(

View File

@ -36,7 +36,11 @@ define(
object = {},
delegation;
function capture(k) { return function (v) { captured[k] = v; }; }
function capture(k) {
return function (v) {
captured[k] = v;
};
}
function TestDomainObject(caps, id) {
return {
getId: function () {
@ -68,11 +72,15 @@ define(
captured = {};
typeDef = {};
typeDef.delegates = ["foo"];
type = { getDefinition: function () { return typeDef; } };
type = { getDefinition: function () {
return typeDef;
} };
children = [];
capabilities = {
type: type,
composition: { invoke: function () { return mockPromise(children); } }
composition: { invoke: function () {
return mockPromise(children);
} }
};
object = new TestDomainObject(capabilities);

View File

@ -35,8 +35,12 @@ define(
topic,
mockNow,
domainObject = {
getId: function () { return "test-id"; },
getModel: function () { return testModel; }
getId: function () {
return "test-id";
},
getModel: function () {
return testModel;
}
},
mutation;

View File

@ -85,8 +85,12 @@ define(
);
mockDomainObject = {
getId: function () { return id; },
getModel: function () { return model; },
getId: function () {
return id;
},
getModel: function () {
return model;
},
useCapability: jasmine.createSpy()
};
// Simulate mutation capability

View File

@ -61,14 +61,18 @@ define(
it("provides models for any IDs which are missing", function () {
var models;
decorator.getModels(['testId', 'otherId'])
.then(function (m) { models = m; });
.then(function (m) {
models = m;
});
expect(models.otherId).toBeDefined();
});
it("does not overwrite existing models", function () {
var models;
decorator.getModels(['testId', 'otherId'])
.then(function (m) { models = m; });
.then(function (m) {
models = m;
});
expect(models.testId).toEqual({ someKey: "some value" });
});

View File

@ -48,7 +48,9 @@ define(
});
mockQ.all.andReturn({
then: function (c) { return c(modelList); }
then: function (c) {
return c(modelList);
}
});
aggregator = new ModelAggregator(mockQ, mockProviders);

View File

@ -57,7 +57,9 @@ define(
};
}
function capture(value) { captured = value; }
function capture(value) {
captured = value;
}
beforeEach(function () {

View File

@ -55,7 +55,9 @@ define(
});
it("provides models from extension declarations", function () {
var mockPromise = { then: function () { return; } };
var mockPromise = { then: function () {
return;
} };
mockQ.when.andReturn(mockPromise);
// Verify that we got the promise as the return value

View File

@ -74,10 +74,14 @@ define(
it("supports instance-of checks by type object", function () {
expect(type.instanceOf({
getKey: function () { return 'test-parent-1'; }
getKey: function () {
return 'test-parent-1';
}
})).toBeTruthy();
expect(type.instanceOf({
getKey: function () { return 'some-other-type'; }
getKey: function () {
return 'some-other-type';
}
})).toBeFalsy();
});

View File

@ -167,7 +167,8 @@ define(
// set, however linked objects will not.
return composeChild(clonedComposee, clonedParent, clonedComposee !== originalComposee);
});
});}, self.$q.when(undefined)
});
}, self.$q.when(undefined)
).then(function () {
//Replace any references in the cloned parent to
// contained objects that have been composed with the

View File

@ -67,7 +67,9 @@ define(
.then(function (objectInNewContext) {
return parentObject.getCapability('persistence')
.persist()
.then(function () { return objectInNewContext; });
.then(function () {
return objectInNewContext;
});
});
};

View File

@ -171,7 +171,9 @@ define(
['notify', 'resolve', 'reject']
);
mockDeferred.notify.andCallFake(function () {});
mockDeferred.resolve.andCallFake(function(value){resolvedValue = value;});
mockDeferred.resolve.andCallFake(function (value) {
resolvedValue = value;
});
mockDeferred.promise = {
then: function (callback) {
return synchronousPromise(callback(resolvedValue));
@ -187,7 +189,9 @@ define(
mockQ.all.andCallFake(function (promises) {
var result = {};
Object.keys(promises).forEach(function (k) {
promises[k].then(function (v) { result[k] = v; });
promises[k].then(function (v) {
result[k] = v;
});
});
return synchronousPromise(result);
});

View File

@ -130,7 +130,9 @@ define(
mockQ.all.andCallFake(function (promises) {
return synchronousPromise(promises.map(function (promise) {
var value;
promise.then(function (v) { value = v; });
promise.then(function (v) {
value = v;
});
return value;
}));
});

View File

@ -76,7 +76,9 @@ define(
mockQ.all.andCallFake(function (promises) {
var result = {};
Object.keys(promises).forEach(function (k) {
promises[k].then(function (v) { result[k] = v; });
promises[k].then(function (v) {
result[k] = v;
});
});
return testPromise(result);
});

View File

@ -63,7 +63,9 @@ define(
beforeEach(function () {
title = "Get a location to do something";
label = "a location";
validate = function () { return true; };
validate = function () {
return true;
};
initialLocation = { key: "a key" };
locationResult = locationService.getLocationFromUser(
title,

View File

@ -27,7 +27,9 @@
define(
function () {
function identity(x) { return x; }
function identity(x) {
return x;
}
/**
* The PlotPreparer is responsible for handling data sets and

View File

@ -96,7 +96,9 @@ define(
);
mockHandler.handle.andReturn(mockHandle);
mockThrottle.andCallFake(function (fn) { return fn; });
mockThrottle.andCallFake(function (fn) {
return fn;
});
mockHandle.getTelemetryObjects.andReturn([mockDomainObject]);
mockHandle.getMetadata.andReturn([{}]);
mockHandle.getDomainValue.andReturn(123);

View File

@ -88,7 +88,7 @@ define(
enableFilter: "=?",
enableSort: "=?",
autoScroll: "=?"
},
}
};
}

View File

@ -87,7 +87,7 @@ define(
'column1': true,
'column2': true,
'column3': false,
'column4': true,
'column4': true
}
}
}

View File

@ -42,7 +42,9 @@ define(
candidates;
// Filter an id for inclustion
function include(id) { return id !== exclude; }
function include(id) {
return id !== exclude;
}
// Evaluate a candidate timestamp as a snap-to location
function evaluate(candidate) {

View File

@ -67,8 +67,12 @@ define(
mockQ.when.andCallFake(asPromise);
mockQ.all.andCallFake(function (values) {
var result = [];
function addResult(v) { result.push(v); }
function promiseResult(v) { asPromise(v).then(addResult); }
function addResult(v) {
result.push(v);
}
function promiseResult(v) {
asPromise(v).then(addResult);
}
values.forEach(promiseResult);
return asPromise(result);
});

View File

@ -61,7 +61,9 @@ define(
mockTimespan.getDuration.andReturn(50);
mockTimespan.getEnd.andReturn(150);
mockToPixels.andCallFake(function (t) { return t * 10; });
mockToPixels.andCallFake(function (t) {
return t * 10;
});
controller = new TimelineGanttController(TEST_MAX_OFFSCREEN);
});

View File

@ -90,7 +90,9 @@ define(
mockScope.domainObject.getCapability.andCallFake(function (c) {
if (c === 'editor') {
return {
inEditContext: function () {return true;}
inEditContext: function () {
return true;
}
};
}
});

View File

@ -49,10 +49,14 @@ define(
var colors = {}, i, ids = [];
// Add item to set
function set(c) { colors[c] = true; }
function set(c) {
colors[c] = true;
}
// Generate ids
for (i = 0; i < 30; i += 1) { ids.push("id" + i); }
for (i = 0; i < 30; i += 1) {
ids.push("id" + i);
}
// Assign colors to each id, then retrieve colors,
// storing into the set

View File

@ -36,7 +36,9 @@ define(
testConfiguration;
function asPromise(v) {
return { then: function (cb) { cb(v); } };
return { then: function (cb) {
cb(v);
} };
}
beforeEach(function () {

View File

@ -82,8 +82,12 @@ define(
mockQ.when.andCallFake(asPromise);
mockQ.all.andCallFake(function (values) {
var result = [];
function addResult(v) { result.push(v); }
function promiseResult(v) { asPromise(v).then(addResult); }
function addResult(v) {
result.push(v);
}
function promiseResult(v) {
asPromise(v).then(addResult);
}
values.forEach(promiseResult);
return asPromise(result);
});

View File

@ -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

View File

@ -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

View File

@ -50,10 +50,14 @@ 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; },
function () {
return result !== undefined;
},
"promise resolution",
250
);

View File

@ -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,
@ -98,7 +100,9 @@ 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] });

View File

@ -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,7 +95,9 @@ 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"];
@ -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];
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,9 +169,15 @@ 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];
@ -175,7 +201,9 @@ 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];
@ -195,7 +223,9 @@ 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];

View File

@ -63,10 +63,14 @@ define(
new Bundle("x", { extensions: { tests: [{}, {}, {}] } }),
new Bundle("y", { extensions: { tests: [{}, {}], others: [{}, {}] } }),
new Bundle("z", { extensions: { others: [{}] } })
]).then(function (v) { result = v; });
]).then(function (v) {
result = v;
});
waitsFor(
function () { return result !== undefined; },
function () {
return result !== undefined;
},
"promise resolution",
250
);

View File

@ -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 () {
@ -57,10 +59,14 @@ define(
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; },
function () {
return result !== undefined;
},
"promise resolution",
250
);
@ -88,10 +94,14 @@ define(
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; },
function () {
return result !== undefined;
},
"promise resolution",
250
);
@ -114,10 +124,14 @@ define(
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; },
function () {
return result !== undefined;
},
"promise resolution",
250
);

View File

@ -53,14 +53,18 @@ 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; },
function () {
return result !== undefined;
},
"promise resolution",
250
);
@ -76,8 +80,12 @@ 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();
@ -85,7 +93,9 @@ define(
required.reject("test result");
waitsFor(
function () { return rejection !== undefined; },
function () {
return rejection !== undefined;
},
"promise resolution",
250
);

View File

@ -61,7 +61,9 @@ define(
}
this.providerMapPromise = $q.all(providers.map(addToMap))
.then(function () { return providerMap; });
.then(function () {
return providerMap;
});
}
PersistenceAggregator.prototype.listSpaces = function () {

View File

@ -70,7 +70,9 @@ define(
mockQ.all.andCallFake(function (fakePromises) {
var result = [];
fakePromises.forEach(function (p) {
p.then(function (v) { result.push(v); });
p.then(function (v) {
result.push(v);
});
});
return fakePromise(result);
});

View File

@ -57,7 +57,9 @@ define(
// Pull out a list of document IDs from CouchDB's
// _all_docs response
function getIdsFromAllDocs(allDocs) {
return allDocs.rows.map(function (r) { return r.id; });
return allDocs.rows.map(function (r) {
return r.id;
});
}
// Check the response to a create/update/delete request;

View File

@ -84,7 +84,9 @@ define(
var model = models[failure.id];
return failure.domainObject.useCapability(
"mutation",
function () { return model; },
function () {
return model;
},
model.modified
);
}

View File

@ -43,7 +43,9 @@ define(
];
mockPolicies = testPolicies.map(function (p) {
var mockPolicy = jasmine.createSpyObj("policy", ['allow']);
mockPolicy.allow.andCallFake(function () { return p.result; });
mockPolicy.allow.andCallFake(function () {
return p.result;
});
return mockPolicy;
});
mockPolicyConstructors = testPolicies.map(function (p, i) {

View File

@ -59,8 +59,12 @@ define(
this.agentService = agentService;
this.actionContext = actionContext;
this.popupService = popupService;
this.getDocument = function () { return $document; };
this.getRootScope = function () { return $rootScope; };
this.getDocument = function () {
return $document;
};
this.getRootScope = function () {
return $rootScope;
};
}
ContextMenuAction.prototype.perform = function () {

View File

@ -35,7 +35,9 @@ define(
it("allows setting of arbitrary objects", function () {
var foo = {
bar: function () { return 42; }
bar: function () {
return 42;
}
};
service.setData('xyz', foo);

View File

@ -27,7 +27,9 @@ define(
[],
function () {
var ZERO = function () { return 0; },
var ZERO = function () {
return 0;
},
EMPTY_SERIES = {
getPointCount: ZERO,
getDomainValue: ZERO,

View File

@ -119,7 +119,9 @@ define(
it("provides an empty series when telemetry is missing", function () {
var series;
mockTelemetryService.requestTelemetry.andReturn(mockPromise({}));
telemetry.requestData({}).then(function (s) { series = s; });
telemetry.requestData({}).then(function (s) {
series = s;
});
expect(series.getPointCount()).toEqual(0);
});
@ -147,7 +149,9 @@ define(
it("warns if no telemetry service can be injected", function () {
mockInjector.get.andCallFake(function () { throw ""; });
mockInjector.get.andCallFake(function () {
throw "";
});
// Verify precondition
expect(mockLog.warn).not.toHaveBeenCalled();

View File

@ -71,7 +71,9 @@ define(
mockQ.all.andCallFake(function (values) {
return values.map(function (v) {
var r;
asPromise(v).then(function (value) { r = value; });
asPromise(v).then(function (value) {
r = value;
});
return r;
});
});