[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

@@ -44,15 +44,15 @@ define(
beforeEach(function () {
mockLocation = jasmine.createSpyObj(
"$location",
[ "path" ]
["path"]
);
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getCapability", "hasCapability" ]
["getCapability", "hasCapability"]
);
mockEditorCapability = jasmine.createSpyObj(
"editor",
[ "save", "cancel" ]
["save", "cancel"]
);
mockUrlService = jasmine.createSpyObj(
"urlService",
@@ -100,4 +100,4 @@ define(
});
});
}
);
);

View File

@@ -38,23 +38,23 @@ define(
beforeEach(function () {
mockLocation = jasmine.createSpyObj(
"$location",
[ "path" ]
["path"]
);
mockNavigationService = jasmine.createSpyObj(
"navigationService",
[ "setNavigation", "getNavigation", "addListener", "removeListener" ]
["setNavigation", "getNavigation", "addListener", "removeListener"]
);
mockLog = jasmine.createSpyObj(
"$log",
[ "error", "warn", "info", "debug" ]
["error", "warn", "info", "debug"]
);
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getModel", "getCapability", "hasCapability", "useCapability" ]
["getId", "getModel", "getCapability", "hasCapability", "useCapability"]
);
mockType = jasmine.createSpyObj(
"type",
[ "hasFeature" ]
["hasFeature"]
);
mockEditor = jasmine.createSpyObj(
"editorCapability",
@@ -66,7 +66,7 @@ define(
editor: mockEditor
};
mockDomainObject.getCapability.andCallFake( function (name) {
mockDomainObject.getCapability.andCallFake(function (name) {
return capabilities[name];
});
mockDomainObject.hasCapability.andReturn(true);
@@ -112,4 +112,4 @@ define(
});
}
);
);

View File

@@ -50,7 +50,7 @@ define(
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getCapability" ]
["getId", "getCapability"]
);
mockQ = { when: mockPromise };
mockParent = {
@@ -64,10 +64,10 @@ define(
return capabilities[k].invoke(v);
}
};
mockContext = jasmine.createSpyObj("context", [ "getParent" ]);
mockComposition = jasmine.createSpyObj("composition", [ "invoke", "add" ]);
mockPersistence = jasmine.createSpyObj("persistence", [ "persist" ]);
mockType = jasmine.createSpyObj("type", [ "hasFeature" ]);
mockContext = jasmine.createSpyObj("context", ["getParent"]);
mockComposition = jasmine.createSpyObj("composition", ["invoke", "add"]);
mockPersistence = jasmine.createSpyObj("persistence", ["persist"]);
mockType = jasmine.createSpyObj("type", ["hasFeature"]);
mockDomainObject.getId.andReturn("test");
mockDomainObject.getCapability.andReturn(mockContext);
@@ -82,7 +82,7 @@ define(
type: mockType
};
model = {
composition: [ "a", "b", "c" ]
composition: ["a", "b", "c"]
};
actionContext = {

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

@@ -57,19 +57,19 @@ define(
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getCapability" ]
["getId", "getCapability"]
);
mockChildObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getCapability" ]
["getId", "getCapability"]
);
mockGrandchildObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getCapability" ]
["getId", "getCapability"]
);
mockRootObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getCapability" ]
["getId", "getCapability"]
);
mockQ = { when: mockPromise };
mockParent = {
@@ -83,13 +83,13 @@ define(
return capabilities[k].invoke(v);
}
};
mockContext = jasmine.createSpyObj("context", [ "getParent" ]);
mockChildContext = jasmine.createSpyObj("context", [ "getParent" ]);
mockGrandchildContext = jasmine.createSpyObj("context", [ "getParent" ]);
mockRootContext = jasmine.createSpyObj("context", [ "getParent" ]);
mockMutation = jasmine.createSpyObj("mutation", [ "invoke" ]);
mockPersistence = jasmine.createSpyObj("persistence", [ "persist" ]);
mockType = jasmine.createSpyObj("type", [ "hasFeature" ]);
mockContext = jasmine.createSpyObj("context", ["getParent"]);
mockChildContext = jasmine.createSpyObj("context", ["getParent"]);
mockGrandchildContext = jasmine.createSpyObj("context", ["getParent"]);
mockRootContext = jasmine.createSpyObj("context", ["getParent"]);
mockMutation = jasmine.createSpyObj("mutation", ["invoke"]);
mockPersistence = jasmine.createSpyObj("persistence", ["persist"]);
mockType = jasmine.createSpyObj("type", ["hasFeature"]);
mockNavigationService = jasmine.createSpyObj(
"navigationService",
[
@@ -100,8 +100,8 @@ define(
]
);
mockNavigationService.getNavigation.andReturn(mockDomainObject);
mockDomainObject.getId.andReturn("test");
mockDomainObject.getCapability.andReturn(mockContext);
mockContext.getParent.andReturn(mockParent);
@@ -113,7 +113,7 @@ define(
type: mockType
};
model = {
composition: [ "a", "test", "b" ]
composition: ["a", "test", "b"]
};
actionContext = { domainObject: mockDomainObject };
@@ -158,60 +158,60 @@ define(
// Finally, should have persisted
expect(mockPersistence.persist).toHaveBeenCalled();
});
it("removes parent of object currently navigated to", function () {
// Navigates to child object
mockNavigationService.getNavigation.andReturn(mockChildObject);
// Test is id of object being removed
// Child object has different id
mockDomainObject.getId.andReturn("test");
mockChildObject.getId.andReturn("not test");
// Sets context for the child and domainObject
mockDomainObject.getCapability.andReturn(mockContext);
mockChildObject.getCapability.andReturn(mockChildContext);
// Parents of child and domainObject are set
mockContext.getParent.andReturn(mockParent);
mockChildContext.getParent.andReturn(mockDomainObject);
mockType.hasFeature.andReturn(true);
action.perform();
// Expects navigation to parent of domainObject (removed object)
expect(mockNavigationService.setNavigation).toHaveBeenCalledWith(mockParent);
});
it("checks if removing object not in ascendent path (reaches ROOT)", function () {
// Navigates to grandchild of ROOT
mockNavigationService.getNavigation.andReturn(mockGrandchildObject);
// domainObject (grandparent) is set as ROOT, child and grandchild
// are set objects not being removed
mockDomainObject.getId.andReturn("test 1");
mockRootObject.getId.andReturn("ROOT");
mockChildObject.getId.andReturn("not test 2");
mockGrandchildObject.getId.andReturn("not test 3");
// Sets context for the grandchild, child, and domainObject
mockRootObject.getCapability.andReturn(mockRootContext);
mockChildObject.getCapability.andReturn(mockChildContext);
mockGrandchildObject.getCapability.andReturn(mockGrandchildContext);
// Parents of grandchild and child are set
mockChildContext.getParent.andReturn(mockRootObject);
mockGrandchildContext.getParent.andReturn(mockChildObject);
mockType.hasFeature.andReturn(true);
action.perform();
// Expects no navigation to occur
expect(mockNavigationService.setNavigation).not.toHaveBeenCalled();
});
});
}
);
);

View File

@@ -52,11 +52,11 @@ define(
);
mockEditorCapability = jasmine.createSpyObj(
"editor",
[ "save", "cancel", "isEditContextRoot" ]
["save", "cancel", "isEditContextRoot"]
);
mockActionCapability = jasmine.createSpyObj(
"actionCapability",
[ "perform"]
["perform"]
);
capabilities.editor = mockEditorCapability;
capabilities.action = mockActionCapability;
@@ -90,7 +90,7 @@ define(
function () {
mockDomainObject.getModel.andReturn({persisted: undefined});
expect(SaveAction.appliesTo(actionContext)).toBe(false);
});
});
it("uses the editor capability to save the object",
function () {
@@ -106,4 +106,4 @@ define(
});
}
);
);

View File

@@ -38,7 +38,7 @@ define(
capabilities = {},
action;
function noop () {}
function noop() {}
function mockPromise(value) {
return (value || {}).then ? value :
@@ -49,7 +49,7 @@ define(
catch: function (callback) {
return mockPromise(callback(value));
}
} ;
} ;
}
beforeEach(function () {
@@ -78,7 +78,7 @@ define(
mockEditorCapability = jasmine.createSpyObj(
"editor",
[ "save", "cancel", "isEditContextRoot" ]
["save", "cancel", "isEditContextRoot"]
);
mockEditorCapability.cancel.andReturn(mockPromise(undefined));
mockEditorCapability.save.andReturn(mockPromise(true));
@@ -130,7 +130,7 @@ define(
action.createWizard.andReturn({
getFormStructure: noop,
getInitialFormValue: noop,
populateObjectFromInput: function() {
populateObjectFromInput: function () {
return mockDomainObject;
}
});

View File

@@ -82,7 +82,7 @@ define(
status: mockStatusCapability
};
mockDomainObject.hasCapability.andCallFake(function(name) {
mockDomainObject.hasCapability.andCallFake(function (name) {
return capabilities[name] !== undefined;
});
@@ -126,8 +126,8 @@ define(
expect(capability.inEditContext()).toBe(true);
});
describe("save", function() {
beforeEach(function() {
describe("save", function () {
beforeEach(function () {
capability.edit();
capability.save();
});
@@ -139,8 +139,8 @@ define(
});
});
describe("cancel", function() {
beforeEach(function() {
describe("cancel", function () {
beforeEach(function () {
capability.edit();
capability.cancel();
});
@@ -152,10 +152,10 @@ define(
});
});
describe("dirty", function() {
describe("dirty", function () {
var model = {};
beforeEach(function() {
beforeEach(function () {
mockDomainObject.getModel.andReturn(model);
capability.edit();
capability.cancel();
@@ -170,4 +170,4 @@ define(
});
});
}
);
);

View File

@@ -33,22 +33,22 @@ define(
mockCapabilityService,
provider;
beforeEach(function() {
beforeEach(function () {
mockQ = {};
mockTransactionService = {};
mockCapabilityService = jasmine.createSpyObj("capabilityService", ["getCapabilities"]);
mockCapabilityService.getCapabilities.andReturn({
persistence: function() {}
persistence: function () {}
});
provider = new TransactionCapabilityDecorator(mockQ, mockTransactionService, mockCapabilityService);
});
it("decorates the persistence capability", function() {
it("decorates the persistence capability", function () {
var capabilities = provider.getCapabilities();
expect(capabilities.persistence({}) instanceof TransactionalPersistenceCapability).toBe(true);
});
});
}
);
);

View File

@@ -29,7 +29,7 @@ define(
function fastPromise(val) {
return {
then: function(callback) {
then: function (callback) {
return callback(val);
}
};
@@ -42,7 +42,7 @@ define(
mockDomainObject,
capability;
beforeEach(function() {
beforeEach(function () {
mockQ = jasmine.createSpyObj("$q", ["when"]);
mockQ.when.andCallFake(function (val) {
return fastPromise(val);
@@ -61,14 +61,14 @@ define(
});
it("if no transaction is active, passes through to persistence" +
" provider", function() {
" provider", function () {
mockTransactionService.isActive.andReturn(false);
capability.persist();
expect(mockPersistence.persist).toHaveBeenCalled();
});
it("if transaction is active, persist and cancel calls are" +
" queued", function() {
" queued", function () {
mockTransactionService.isActive.andReturn(true);
capability.persist();
expect(mockTransactionService.addToTransaction).toHaveBeenCalled();
@@ -78,7 +78,7 @@ define(
expect(mockPersistence.refresh).toHaveBeenCalled();
});
it("persist call is only added to transaction once", function() {
it("persist call is only added to transaction once", function () {
mockTransactionService.isActive.andReturn(true);
capability.persist();
expect(mockTransactionService.addToTransaction).toHaveBeenCalled();
@@ -89,4 +89,4 @@ define(
});
}
);
);

View File

@@ -56,4 +56,4 @@ define(
});
});
}
);
);

View File

@@ -52,15 +52,15 @@ define(
);
mockScope = jasmine.createSpyObj(
"$scope",
[ "$on", "$watch" ]
["$on", "$watch"]
);
mockObject = jasmine.createSpyObj(
"domainObject",
[ "getId", "getModel", "getCapability", "hasCapability", "useCapability" ]
["getId", "getModel", "getCapability", "hasCapability", "useCapability"]
);
mockType = jasmine.createSpyObj(
"type",
[ "hasFeature" ]
["hasFeature"]
);
mockStatusCapability = jasmine.createSpyObj('statusCapability',
["get"]
@@ -99,8 +99,8 @@ define(
expect(controller.getUnloadWarning()).toBeUndefined();
// Override the policy service to prevent navigation
mockPolicyService.allow.andCallFake(function(category, object, context, callback){
callback(errorMessage);
mockPolicyService.allow.andCallFake(function (category, object, context, callback) {
callback(errorMessage);
});
// Should have some warning message here now

View File

@@ -34,11 +34,11 @@ define(
mockScope = jasmine.createSpyObj("$scope", ["$watch"]);
mockDomainObject = jasmine.createSpyObj(
'domainObject',
[ 'getId', 'getCapability' ]
['getId', 'getCapability']
);
mockContext = jasmine.createSpyObj(
'context',
[ 'getTrueRoot' ]
['getTrueRoot']
);
mockDomainObject.getId.andReturn('test-id');
@@ -110,4 +110,4 @@ define(
});
});
}
);
);

View File

@@ -34,8 +34,8 @@ define(
controller = new ElementsController(mockScope);
});
function getModel (model) {
return function() {
function getModel(model) {
return function () {
return model;
};
}

View File

@@ -111,4 +111,4 @@ define(
});
}
);
);

View File

@@ -58,10 +58,10 @@ define(
mockEditAction = jasmine.createSpyObj('edit', ['getMetadata']);
mockPropertiesAction = jasmine.createSpyObj('edit', ['getMetadata']);
mockDomainObject.getCapability.andCallFake(function(capability){
mockDomainObject.getCapability.andCallFake(function (capability) {
return capabilities[capability];
});
mockDomainObject.hasCapability.andCallFake(function(capability){
mockDomainObject.hasCapability.andCallFake(function (capability) {
return !!capabilities[capability];
});
@@ -88,42 +88,42 @@ define(
});
it("allows the edit action when there are editable views", function () {
testViews = [ editableView ];
testViews = [editableView];
expect(policy.allow(mockEditAction, testContext)).toBe(true);
});
it("allows the edit properties action when there are no editable views", function () {
testViews = [ nonEditableView, nonEditableView ];
testViews = [nonEditableView, nonEditableView];
expect(policy.allow(mockPropertiesAction, testContext)).toBe(true);
});
it("disallows the edit action when there are no editable views", function () {
testViews = [ nonEditableView, nonEditableView ];
testViews = [nonEditableView, nonEditableView];
expect(policy.allow(mockEditAction, testContext)).toBe(false);
});
it("disallows the edit properties action when there are" +
" editable views", function () {
testViews = [ editableView ];
testViews = [editableView];
expect(policy.allow(mockPropertiesAction, testContext)).toBe(false);
});
it("disallows the edit action when object is already being" +
" edited", function () {
testViews = [ editableView ];
testViews = [editableView];
mockEditorCapability.isEditContextRoot.andReturn(true);
expect(policy.allow(mockEditAction, testContext)).toBe(false);
});
it("allows editing of panels in plot view", function () {
testViews = [ plotView ];
testViews = [plotView];
mockTypeCapability.getKey.andReturn('telemetry.panel');
expect(policy.allow(mockEditAction, testContext)).toBe(true);
});
it("disallows editing of plot view when object not a panel type", function () {
testViews = [ plotView ];
testViews = [plotView];
mockTypeCapability.getKey.andReturn('something.else');
expect(policy.allow(mockEditAction, testContext)).toBe(false);
@@ -131,10 +131,10 @@ define(
it("allows the edit properties outside of the 'view-control' category", function () {
testViews = [ nonEditableView ];
testViews = [nonEditableView];
testContext.category = "something-else";
expect(policy.allow(mockPropertiesAction, testContext)).toBe(true);
});
});
}
);
);

View File

@@ -61,12 +61,12 @@ define(
policy = new EditContextualActionPolicy(navigationService, editModeBlacklist, nonEditContextBlacklist);
});
it('Allows all actions when navigated object not in edit mode', function() {
it('Allows all actions when navigated object not in edit mode', function () {
expect(policy.allow(mockAction, context)).toBe(true);
});
it('Allows "window" action when navigated object in edit mode,' +
' but selected object not in edit mode ', function() {
' but selected object not in edit mode ', function () {
navigatedObject.hasCapability.andReturn(true);
mockEditorCapability.isEditContextRoot.andReturn(true);
metadata.key = "window";
@@ -75,7 +75,7 @@ define(
it('Allows "remove" action when navigated object in edit mode,' +
' and selected object not editable, but its parent is.',
function() {
function () {
var mockParent = jasmine.createSpyObj("parentObject", ["hasCapability"]),
mockContextCapability = jasmine.createSpyObj("contextCapability", ["getParent"]);
@@ -93,10 +93,10 @@ define(
metadata.key = "remove";
expect(policy.allow(mockAction, context)).toBe(true);
});
});
it('Disallows "move" action when navigated object in edit mode,' +
' but selected object not in edit mode ', function() {
' but selected object not in edit mode ', function () {
navigatedObject.hasCapability.andReturn(true);
mockEditorCapability.isEditContextRoot.andReturn(true);
mockEditorCapability.inEditContext.andReturn(false);
@@ -105,7 +105,7 @@ define(
});
it('Disallows copy action when navigated object and' +
' selected object in edit mode', function() {
' selected object in edit mode', function () {
navigatedObject.hasCapability.andReturn(true);
mockDomainObject.hasCapability.andReturn(true);
mockEditorCapability.isEditContextRoot.andReturn(true);

View File

@@ -36,7 +36,7 @@ define(
['hasCapability', 'getCapability']
);
mockDomainObject.getCapability.andReturn({
inEditContext: function () {
inEditContext: function () {
return true;
}
});
@@ -76,4 +76,4 @@ define(
});
});
}
);
);

View File

@@ -72,7 +72,7 @@ define(
mockDomainObject.getModel.andReturn({});
mockDomainObject.hasCapability.andReturn(true);
mockDomainObject.useCapability.andReturn(true);
mockDomainObject.getCapability.andCallFake(function(capability){
mockDomainObject.getCapability.andCallFake(function (capability) {
return mockCapabilities[capability];
});

View File

@@ -34,13 +34,13 @@ define(
beforeEach(function () {
mockScope = jasmine.createSpyObj(
'$scope',
[ '$on', '$watch', '$watchCollection', "commit" ]
['$on', '$watch', '$watchCollection', "commit"]
);
mockElement = {};
testAttrs = { toolbar: 'testToolbar' };
mockScope.$parent = jasmine.createSpyObj(
'$parent',
[ '$watch', '$watchCollection' ]
['$watch', '$watchCollection']
);
mockUnwatch = jasmine.createSpy('unwatch');
@@ -92,7 +92,7 @@ define(
// Provide a view which has a toolbar
representer.represent({
toolbar: { sections: [ { items: [ { property: 'k' } ] } ] }
toolbar: { sections: [{ items: [{ property: 'k' }] }] }
});
// Update the selection
@@ -120,7 +120,7 @@ define(
// Provide a view which has a toolbar
representer.represent({
toolbar: { sections: [ { items: [ { property: 'k' } ] } ] }
toolbar: { sections: [{ items: [{ property: 'k' }] }] }
});
// Update the selection
@@ -140,4 +140,4 @@ define(
});
}
);
);

View File

@@ -76,7 +76,7 @@ define(
it("provides properties from the original structure", function () {
expect(
new EditToolbar(testStructure, [ testABC ])
new EditToolbar(testStructure, [testABC])
.getStructure()
.sections[0]
.items[1]
@@ -87,7 +87,7 @@ define(
// This is needed by mct-toolbar
it("adds keys to form structure", function () {
expect(
new EditToolbar(testStructure, [ testABC ])
new EditToolbar(testStructure, [testABC])
.getStructure()
.sections[0]
.items[1]
@@ -97,20 +97,20 @@ define(
it("marks empty sections as hidden", function () {
// Verify that all sections are included when applicable...
toolbar.setSelection([ testABCXYZ ]);
toolbar.setSelection([testABCXYZ]);
expect(toolbar.getStructure().sections.map(getVisibility))
.toEqual([ true, true, false ]);
.toEqual([true, true, false]);
// ...but omitted when only some are applicable
toolbar.setSelection([ testABC ]);
toolbar.setSelection([testABC]);
expect(toolbar.getStructure().sections.map(getVisibility))
.toEqual([ true, false, false ]);
.toEqual([true, false, false]);
});
it("reads properties from selections", function () {
var structure, state;
toolbar.setSelection([ testABC ]);
toolbar.setSelection([testABC]);
structure = toolbar.getStructure();
state = toolbar.getState();
@@ -126,9 +126,11 @@ 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 ]);
toolbar.setSelection([testABC]);
structure = toolbar.getStructure();
state = toolbar.getState();
@@ -137,7 +139,7 @@ define(
});
it("sets properties on update", function () {
toolbar.setSelection([ testABC ]);
toolbar.setSelection([testABC]);
toolbar.updateState(
toolbar.getStructure().sections[0].items[0].key,
"new value"
@@ -151,7 +153,7 @@ define(
testABC.a = jasmine.createSpy('a');
toolbar.setSelection([ testABC ]);
toolbar.setSelection([testABC]);
structure = toolbar.getStructure();
toolbar.updateState(
@@ -165,7 +167,7 @@ define(
it("provides a return value describing update status", function () {
// Should return true if actually updated, otherwise false
var key;
toolbar.setSelection([ testABC ]);
toolbar.setSelection([testABC]);
key = toolbar.getStructure().sections[0].items[0].key;
expect(toolbar.updateState(key, testABC.a)).toBeFalsy();
expect(toolbar.updateState(key, "new value")).toBeTruthy();
@@ -173,35 +175,35 @@ define(
it("removes inapplicable items", function () {
// First, verify with all items
toolbar.setSelection([ testABC ]);
toolbar.setSelection([testABC]);
expect(toolbar.getStructure().sections[0].items.map(getVisibility))
.toEqual([ true, true, true ]);
.toEqual([true, true, true]);
// Then, try with some items omitted
toolbar.setSelection([ testABC, testAB ]);
toolbar.setSelection([testABC, testAB]);
expect(toolbar.getStructure().sections[0].items.map(getVisibility))
.toEqual([ true, true, false ]);
.toEqual([true, true, false]);
});
it("removes inconsistent states", function () {
// Only two of three values match among these selections
toolbar.setSelection([ testABC, testABC2 ]);
toolbar.setSelection([testABC, testABC2]);
expect(toolbar.getStructure().sections[0].items.map(getVisibility))
.toEqual([ false, true, true ]);
.toEqual([false, true, true]);
});
it("allows inclusive items", function () {
// One inclusive item is in the set, property 'x' of the
// second section; make sure items are pruned down
// when only some of the selection has x,y,z properties
toolbar.setSelection([ testABC, testABCXYZ ]);
toolbar.setSelection([testABC, testABCXYZ]);
expect(toolbar.getStructure().sections[1].items.map(getVisibility))
.toEqual([ true, false, false ]);
.toEqual([true, false, false]);
});
it("removes inclusive items when there are no matches", function () {
toolbar.setSelection([ testABCYZ ]);
toolbar.setSelection([testABCYZ]);
expect(toolbar.getStructure().sections[1].items.map(getVisibility))
.toEqual([ false, true, true ]);
.toEqual([false, true, true]);
});
it("adds click functions when a method is specified", function () {

View File

@@ -30,7 +30,7 @@ define(
mockLog,
transactionService;
function fastPromise (val) {
function fastPromise(val) {
return {
then: function (callback) {
return fastPromise(callback(val));
@@ -75,8 +75,8 @@ define(
describe("commit", function () {
var onCommits;
beforeEach(function() {
onCommits = [0, 1, 2].map(function(val) {
beforeEach(function () {
onCommits = [0, 1, 2].map(function (val) {
return jasmine.createSpy("onCommit" + val);
});
@@ -87,7 +87,7 @@ define(
it("commit calls all queued commit functions", function () {
expect(transactionService.onCommits.length).toBe(3);
transactionService.commit();
onCommits.forEach( function (spy) {
onCommits.forEach(function (spy) {
expect(spy).toHaveBeenCalled();
});
});
@@ -104,8 +104,8 @@ define(
describe("cancel", function () {
var onCancels;
beforeEach(function() {
onCancels = [0, 1, 2].map(function(val) {
beforeEach(function () {
onCancels = [0, 1, 2].map(function (val) {
return jasmine.createSpy("onCancel" + val);
});
@@ -118,7 +118,7 @@ define(
it("cancel calls all queued cancel functions", function () {
expect(transactionService.onCancels.length).toBe(3);
transactionService.cancel();
onCancels.forEach( function (spy) {
onCancels.forEach(function (spy) {
expect(spy).toHaveBeenCalled();
});
});
@@ -134,4 +134,4 @@ define(
});
}
);
);