[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

@@ -56,7 +56,7 @@ define(
return {
cssClass: alarm && alarm.cssClass,
text: typeof(value) === 'undefined' ? undefined : this.telemetryFormatter.formatRangeValue(value)
text: typeof (value) === 'undefined' ? undefined : this.telemetryFormatter.formatRangeValue(value)
};
};

View File

@@ -64,7 +64,7 @@ define(
});
});
if (this.columns.length > 0){
if (this.columns.length > 0) {
self.addColumn(new NameColumn(), 0);
}
}
@@ -91,7 +91,7 @@ define(
* @returns {*|string}
*/
TableConfiguration.prototype.getColumnTitle = function (column) {
return column.getTitle();
return column.getTitle();
};
/**
@@ -100,7 +100,7 @@ define(
*/
TableConfiguration.prototype.getHeaders = function () {
var self = this;
return this.columns.map(function (column, i){
return this.columns.map(function (column, i) {
return self.getColumnTitle(column) || 'Column ' + (i + 1);
});
};
@@ -115,11 +115,11 @@ define(
*/
TableConfiguration.prototype.getRowValues = function (telemetryObject, datum) {
var self = this;
return this.columns.reduce(function (rowObject, column, i){
return this.columns.reduce(function (rowObject, column, i) {
var columnTitle = self.getColumnTitle(column) || 'Column ' + (i + 1),
columnValue = column.getValue(telemetryObject, datum);
if (columnValue !== undefined && columnValue.text === undefined){
if (columnValue !== undefined && columnValue.text === undefined) {
columnValue.text = '';
}
// Don't replace something with nothing.
@@ -158,7 +158,7 @@ define(
config2Keys = Object.keys(config2);
return (config1Keys.length !== config2Keys.length) ||
config1Keys.some(function(key){
config1Keys.some(function (key) {
return config1[key] !== config2[key];
});
}

View File

@@ -49,7 +49,7 @@ define(
var rowData = [],
self = this;
this.handle.getTelemetryObjects().forEach(function (telemetryObject){
this.handle.getTelemetryObjects().forEach(function (telemetryObject) {
var series = self.handle.getSeries(telemetryObject) || {},
pointCount = series.getPointCount ? series.getPointCount() : 0,
i = 0;

View File

@@ -89,8 +89,8 @@ define(
//Use timeout to defer execution until next digest when any
// pending UI changes have completed, eg. a new row in the table.
if (this.$scope.autoScroll) {
this.$timeout(function (){
self.scrollable[0].scrollTop = self.scrollable[0].scrollHeight;
this.$timeout(function () {
self.scrollable[0].scrollTop = self.scrollable[0].scrollHeight;
});
}
};
@@ -125,10 +125,10 @@ define(
// Do a sequential search here. Only way of finding row is by
// object equality, so array is in effect unsorted.
indexInDisplayRows = this.$scope.displayRows.indexOf(row);
if (indexInDisplayRows !== -1) {
this.$scope.displayRows.splice(indexInDisplayRows, 1);
this.setVisibleRows();
}
if (indexInDisplayRows !== -1) {
this.$scope.displayRows.splice(indexInDisplayRows, 1);
this.setVisibleRows();
}
};
/**
@@ -222,7 +222,7 @@ define(
* sorting.
*/
MCTTableController.prototype.setHeaders = function (newHeaders) {
if (!newHeaders){
if (!newHeaders) {
return;
}
@@ -234,8 +234,8 @@ define(
// contain the column currently sorted on.
if (this.$scope.enableSort &&
newHeaders.indexOf(this.$scope.sortColumn) === -1) {
this.$scope.sortColumn = undefined;
this.$scope.sortDirection = undefined;
this.$scope.sortColumn = undefined;
this.$scope.sortDirection = undefined;
}
this.setRows(this.$scope.rows);
};
@@ -283,14 +283,14 @@ define(
self = this,
sortKey = this.$scope.sortColumn;
function binarySearch(searchArray, searchElement, min, max){
function binarySearch(searchArray, searchElement, min, max) {
var sampleAt = Math.floor((max - min) / 2) + min;
if (max < min) {
return min; // Element is not in array, min gives direction
}
switch(self.sortComparator(searchElement[sortKey].text,
switch (self.sortComparator(searchElement[sortKey].text,
searchArray[sampleAt][sortKey].text)) {
case -1:
return binarySearch(searchArray, searchElement, min,
@@ -310,9 +310,9 @@ define(
//Sort is enabled, perform binary search to find insertion point
index = binarySearch(array, element, 0, array.length - 1);
}
if (index === -1){
if (index === -1) {
array.unshift(element);
} else if (index === array.length){
} else if (index === array.length) {
array.push(element);
} else {
array.splice(index, 0, element);
@@ -342,7 +342,7 @@ define(
* @returns {*} The value cast to a Number, or the original value if
* a Number representation is not possible.
*/
function toNumber (value){
function toNumber(value) {
var val = !isNaN(Number(value)) && !isNaN(parseFloat(value)) ? Number(value) : value;
return val;
}
@@ -410,7 +410,7 @@ define(
currentColumnLength,
largestColumn,
largestColumnLength;
if (row[key]){
if (row[key]) {
currentColumn = (row[key]).text;
currentColumnLength =
(currentColumn && currentColumn.length) ?

View File

@@ -58,7 +58,7 @@ define(
$scope.$watch('domainObject', function (domainObject) {
//When a domain object becomes available, check whether the
// view should auto-scroll to the bottom.
if (domainObject && hasStringTelemetry(domainObject)){
if (domainObject && hasStringTelemetry(domainObject)) {
$scope.autoScroll = true;
}
});
@@ -70,11 +70,11 @@ define(
* Overrides method on TelemetryTableController providing handling
* for realtime data.
*/
RealtimeTableController.prototype.addRealtimeData = function() {
RealtimeTableController.prototype.addRealtimeData = function () {
var self = this,
datum,
row;
this.handle.getTelemetryObjects().forEach(function (telemetryObject){
this.handle.getTelemetryObjects().forEach(function (telemetryObject) {
datum = self.handle.getDatum(telemetryObject);
if (datum) {
//Populate row values from telemetry datum

View File

@@ -59,7 +59,7 @@ define(
});
}
$scope.$watch('domainObject', function(domainObject) {
$scope.$watch('domainObject', function (domainObject) {
unlisten();
self.populateForm(domainObject.getModel());
@@ -72,10 +72,10 @@ define(
* Maintain a configuration object on scope that stores column
* configuration. On change, synchronize with object model.
*/
$scope.$watchCollection('configuration.table.columns', function (columns){
if (columns){
$scope.$watchCollection('configuration.table.columns', function (columns) {
if (columns) {
self.domainObject.useCapability('mutation', function (model) {
model.configuration.table.columns = columns;
model.configuration.table.columns = columns;
});
self.domainObject.getCapability('persistence').persist();
}
@@ -92,13 +92,13 @@ define(
var columnsDefinition = (((model.configuration || {}).table || {}).columns || {}),
rows = [];
this.$scope.columnsForm = {
'name':'Columns',
'name': 'Columns',
'sections': [{
'name': 'Columns',
'rows': rows
}]};
Object.keys(columnsDefinition).forEach(function (key){
Object.keys(columnsDefinition).forEach(function (key) {
rows.push({
'name': key,
'control': 'checkbox',

View File

@@ -58,7 +58,7 @@ define(
$scope.rows = [];
// Subscribe to telemetry when a domain object becomes available
this.$scope.$watch('domainObject', function(){
this.$scope.$watch('domainObject', function () {
self.subscribe();
self.registerChangeListeners();
});

View File

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

View File

@@ -38,11 +38,11 @@ define(
beforeEach(function () {
mockDataSet = jasmine.createSpyObj(
"data",
[ "getDomainValue" ]
["getDomainValue"]
);
mockFormatter = jasmine.createSpyObj(
"formatter",
[ "formatDomainValue", "formatRangeValue" ]
["formatDomainValue", "formatRangeValue"]
);
testMetadata = {
key: "testKey",

View File

@@ -34,7 +34,7 @@ define(
beforeEach(function () {
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getModel" ]
["getModel"]
);
mockDomainObject.getModel.andReturn({
name: "Test object name"

View File

@@ -40,7 +40,7 @@ define(
testDatum = { testKey: 123, otherKey: 456 };
mockFormatter = jasmine.createSpyObj(
"formatter",
[ "formatDomainValue", "formatRangeValue" ]
["formatDomainValue", "formatRangeValue"]
);
testMetadata = {
key: "testKey",
@@ -48,7 +48,7 @@ define(
};
mockDomainObject = jasmine.createSpyObj(
"domainObject",
[ "getModel", "getCapability" ]
["getModel", "getCapability"]
);
mockFormatter.formatRangeValue.andReturn(TEST_RANGE_VALUE);

View File

@@ -44,10 +44,10 @@ define(
'formatDomainValue',
'formatRangeValue'
]);
mockTelemetryFormatter.formatDomainValue.andCallFake(function(valueIn){
mockTelemetryFormatter.formatDomainValue.andCallFake(function (valueIn) {
return valueIn;
});
mockTelemetryFormatter.formatRangeValue.andCallFake(function(valueIn){
mockTelemetryFormatter.formatRangeValue.andCallFake(function (valueIn) {
return valueIn;
});
@@ -87,7 +87,7 @@ define(
expect(table.columns[2]).toBe(thirdColumn);
});
describe("Building columns from telemetry metadata", function() {
describe("Building columns from telemetry metadata", function () {
var metadata = [{
ranges: [
{
@@ -113,21 +113,21 @@ define(
]
}];
beforeEach(function() {
beforeEach(function () {
table.populateColumns(metadata);
});
it("populates columns", function() {
it("populates columns", function () {
expect(table.columns.length).toBe(5);
});
it("Build columns populates columns with domains to the left", function() {
it("Build columns populates columns with domains to the left", function () {
expect(table.columns[1] instanceof DomainColumn).toBeTruthy();
expect(table.columns[2] instanceof DomainColumn).toBeTruthy();
expect(table.columns[3] instanceof DomainColumn).toBeFalsy();
});
it("Produces headers for each column based on title", function() {
it("Produces headers for each column based on title", function () {
var headers,
firstColumn = table.columns[0];
@@ -138,16 +138,16 @@ define(
});
it("Provides a default configuration with all columns" +
" visible", function() {
" visible", function () {
var configuration = table.buildColumnConfiguration();
expect(configuration).toBeDefined();
expect(Object.keys(configuration).every(function(key){
expect(Object.keys(configuration).every(function (key) {
return configuration[key];
}));
});
it("Column configuration exposes persisted configuration", function() {
it("Column configuration exposes persisted configuration", function () {
var tableConfig,
modelConfig = {
table: {
@@ -168,7 +168,7 @@ define(
var datum,
rowValues;
beforeEach(function() {
beforeEach(function () {
datum = {
'range1': 'range 1 value',
'range2': 'range 2 value',
@@ -178,14 +178,14 @@ define(
rowValues = table.getRowValues(mockDomainObject, datum);
});
it("Returns a value for every column", function() {
it("Returns a value for every column", function () {
expect(rowValues['Range 1'].text).toBeDefined();
expect(rowValues['Range 1'].text).toEqual('range 1' +
' value');
});
it("Uses the telemetry formatter to appropriately format" +
" telemetry values", function() {
" telemetry values", function () {
expect(mockTelemetryFormatter.formatRangeValue).toHaveBeenCalled();
});
});

View File

@@ -39,7 +39,7 @@ define(
function promise(value) {
return {
then: function (callback){
then: function (callback) {
return promise(callback(value));
}
};
@@ -53,13 +53,13 @@ define(
'$watchCollection'
]);
mockScope.$on.andCallFake(function (expression, callback){
mockScope.$on.andCallFake(function (expression, callback) {
watches[expression] = callback;
});
mockScope.$watch.andCallFake(function (expression, callback){
watches[expression] = callback;
mockScope.$watch.andCallFake(function (expression, callback) {
watches[expression] = callback;
});
mockScope.$watchCollection.andCallFake(function (expression, callback){
mockScope.$watchCollection.andCallFake(function (expression, callback) {
watches[expression] = callback;
});
@@ -80,7 +80,7 @@ define(
mockTable.columns = [];
mockTable.buildColumnConfiguration.andReturn(mockConfiguration);
mockDomainObject= jasmine.createSpyObj('domainObject', [
mockDomainObject = jasmine.createSpyObj('domainObject', [
'getCapability',
'useCapability',
'getModel'
@@ -118,7 +118,7 @@ define(
expect(mockTelemetryHandle.request).toHaveBeenCalled();
});
it('Unsubscribes from telemetry when scope is destroyed',function () {
it('Unsubscribes from telemetry when scope is destroyed', function () {
controller.handle = mockTelemetryHandle;
watches.$destroy();
expect(mockTelemetryHandle.unsubscribe).toHaveBeenCalled();
@@ -139,7 +139,7 @@ define(
});
});
it('updates the rows on scope when historical telemetry is received', function (){
it('updates the rows on scope when historical telemetry is received', function () {
var mockSeries = {
getPointCount: function () {
return 5;
@@ -154,7 +154,7 @@ define(
mockRow = {'domain': 'Domain Value', 'range': 'Range' +
' Value'};
mockTelemetryHandle.makeDatum.andCallFake(function (){
mockTelemetryHandle.makeDatum.andCallFake(function () {
return mockRow;
});
mockTable.getRowValues.andReturn(mockRow);
@@ -167,7 +167,7 @@ define(
expect(controller.$scope.rows[0]).toBe(mockRow);
});
it('filters the visible columns based on configuration', function (){
it('filters the visible columns based on configuration', function () {
controller.filterColumns();
expect(controller.$scope.headers.length).toBe(3);
expect(controller.$scope.headers[2]).toEqual('domain1');
@@ -178,9 +178,9 @@ define(
expect(controller.$scope.headers[2]).toBeUndefined();
});
describe('creates event listeners', function (){
describe('creates event listeners', function () {
beforeEach(function () {
spyOn(controller,'subscribe');
spyOn(controller, 'subscribe');
spyOn(controller, 'filterColumns');
});

View File

@@ -26,7 +26,7 @@ define(
],
function (MCTTableController) {
describe('The MCTTable Controller', function() {
describe('The MCTTable Controller', function () {
var controller,
mockScope,
@@ -42,7 +42,7 @@ define(
};
}
beforeEach(function() {
beforeEach(function () {
watches = {};
mockScope = jasmine.createSpyObj('scope', [
@@ -50,7 +50,7 @@ define(
'$on',
'$watchCollection'
]);
mockScope.$watchCollection.andCallFake(function(event, callback) {
mockScope.$watchCollection.andCallFake(function (event, callback) {
watches[event] = callback;
});
@@ -75,15 +75,15 @@ define(
spyOn(controller, 'setVisibleRows').andCallThrough();
});
it('Reacts to changes to filters, headers, and rows', function() {
it('Reacts to changes to filters, headers, and rows', function () {
expect(mockScope.$watchCollection).toHaveBeenCalledWith('filters', jasmine.any(Function));
expect(mockScope.$watch).toHaveBeenCalledWith('headers', jasmine.any(Function));
expect(mockScope.$watch).toHaveBeenCalledWith('rows', jasmine.any(Function));
});
describe('rows', function() {
describe('rows', function () {
var testRows = [];
beforeEach(function() {
beforeEach(function () {
testRows = [
{
'col1': {'text': 'row1 col1 match'},
@@ -104,30 +104,30 @@ define(
mockScope.rows = testRows;
});
it('Filters results based on filter input', function() {
var filters = {},
filteredRows;
it('Filters results based on filter input', function () {
var filters = {},
filteredRows;
mockScope.filters = filters;
mockScope.filters = filters;
filteredRows = controller.filterRows(testRows);
expect(filteredRows.length).toBe(3);
filters.col1 = 'row1';
filteredRows = controller.filterRows(testRows);
expect(filteredRows.length).toBe(1);
filters.col1 = 'match';
filteredRows = controller.filterRows(testRows);
expect(filteredRows.length).toBe(2);
filteredRows = controller.filterRows(testRows);
expect(filteredRows.length).toBe(3);
filters.col1 = 'row1';
filteredRows = controller.filterRows(testRows);
expect(filteredRows.length).toBe(1);
filters.col1 = 'match';
filteredRows = controller.filterRows(testRows);
expect(filteredRows.length).toBe(2);
});
it('Sets rows on scope when rows change', function() {
it('Sets rows on scope when rows change', function () {
controller.setRows(testRows);
expect(mockScope.displayRows.length).toBe(3);
expect(mockScope.displayRows).toEqual(testRows);
});
it('Supports adding rows individually', function() {
var addRowFunc = mockScope.$on.calls[mockScope.$on.calls.length-2].args[1],
it('Supports adding rows individually', function () {
var addRowFunc = mockScope.$on.calls[mockScope.$on.calls.length - 2].args[1],
row4 = {
'col1': {'text': 'row3 col1'},
'col2': {'text': 'ghi'},
@@ -140,8 +140,8 @@ define(
expect(mockScope.displayRows.length).toBe(4);
});
it('Supports removing rows individually', function() {
var removeRowFunc = mockScope.$on.calls[mockScope.$on.calls.length-1].args[1];
it('Supports removing rows individually', function () {
var removeRowFunc = mockScope.$on.calls[mockScope.$on.calls.length - 1].args[1];
controller.setRows(testRows);
expect(mockScope.displayRows.length).toBe(3);
removeRowFunc(undefined, 2);
@@ -149,10 +149,10 @@ define(
expect(controller.setVisibleRows).toHaveBeenCalled();
});
describe('sorting', function() {
describe('sorting', function () {
var sortedRows;
it('Sorts rows ascending', function() {
it('Sorts rows ascending', function () {
mockScope.sortColumn = 'col1';
mockScope.sortDirection = 'asc';
@@ -164,7 +164,7 @@ define(
});
it('Sorts rows descending', function() {
it('Sorts rows descending', function () {
mockScope.sortColumn = 'col1';
mockScope.sortDirection = 'desc';
@@ -173,7 +173,7 @@ define(
expect(sortedRows[1].col1.text).toEqual('row2 col1 match');
expect(sortedRows[2].col1.text).toEqual('row1 col1 match');
});
it('Sorts rows descending based on selected sort column', function() {
it('Sorts rows descending based on selected sort column', function () {
mockScope.sortColumn = 'col2';
mockScope.sortDirection = 'desc';
@@ -218,9 +218,9 @@ define(
expect(sortedRows[1].col2.text).toEqual('def');
expect(sortedRows[2].col2.text).toEqual('abc');
expect(sortedRows[sortedRows.length-3].col2.text).toEqual('456');
expect(sortedRows[sortedRows.length-2].col2.text).toEqual('123');
expect(sortedRows[sortedRows.length-1].col2.text).toEqual('');
expect(sortedRows[sortedRows.length - 3].col2.text).toEqual('456');
expect(sortedRows[sortedRows.length - 2].col2.text).toEqual('123');
expect(sortedRows[sortedRows.length - 1].col2.text).toEqual('');
});
describe('The sort comparator', function () {
@@ -245,7 +245,7 @@ define(
row5,
row6;
beforeEach(function() {
beforeEach(function () {
row4 = {
'col1': {'text': 'row5 col1'},
'col2': {'text': 'xyz'},
@@ -264,33 +264,33 @@ define(
});
it('Adds new rows at the correct sort position when' +
' sorted ', function() {
' sorted ', function () {
mockScope.sortColumn = 'col2';
mockScope.sortDirection = 'desc';
mockScope.displayRows = controller.sortRows(testRows.slice(0));
mockScope.rows.push(row4);
controller.addRow(undefined, mockScope.rows.length-1);
controller.addRow(undefined, mockScope.rows.length - 1);
expect(mockScope.displayRows[0].col2.text).toEqual('xyz');
mockScope.rows.push(row5);
controller.addRow(undefined, mockScope.rows.length-1);
controller.addRow(undefined, mockScope.rows.length - 1);
expect(mockScope.displayRows[4].col2.text).toEqual('aaa');
mockScope.rows.push(row6);
controller.addRow(undefined, mockScope.rows.length-1);
controller.addRow(undefined, mockScope.rows.length - 1);
expect(mockScope.displayRows[2].col2.text).toEqual('ggg');
//Add a duplicate row
mockScope.rows.push(row6);
controller.addRow(undefined, mockScope.rows.length-1);
controller.addRow(undefined, mockScope.rows.length - 1);
expect(mockScope.displayRows[2].col2.text).toEqual('ggg');
expect(mockScope.displayRows[3].col2.text).toEqual('ggg');
});
it('Adds new rows at the correct sort position when' +
' sorted and filtered', function() {
' sorted and filtered', function () {
mockScope.sortColumn = 'col2';
mockScope.sortDirection = 'desc';
mockScope.filters = {'col2': 'a'};//Include only
@@ -300,12 +300,12 @@ define(
mockScope.displayRows = controller.filterRows(testRows);
mockScope.rows.push(row5);
controller.addRow(undefined, mockScope.rows.length-1);
controller.addRow(undefined, mockScope.rows.length - 1);
expect(mockScope.displayRows.length).toBe(2);
expect(mockScope.displayRows[1].col2.text).toEqual('aaa');
mockScope.rows.push(row6);
controller.addRow(undefined, mockScope.rows.length-1);
controller.addRow(undefined, mockScope.rows.length - 1);
expect(mockScope.displayRows.length).toBe(2);
//Row was not added because does not match filter
});
@@ -319,16 +319,16 @@ define(
mockScope.displayRows = testRows.slice(0);
mockScope.rows.push(row5);
controller.addRow(undefined, mockScope.rows.length-1);
controller.addRow(undefined, mockScope.rows.length - 1);
expect(mockScope.displayRows[3].col2.text).toEqual('aaa');
mockScope.rows.push(row6);
controller.addRow(undefined, mockScope.rows.length-1);
controller.addRow(undefined, mockScope.rows.length - 1);
expect(mockScope.displayRows[4].col2.text).toEqual('ggg');
});
it('Resizes columns if length of any columns in new' +
' row exceeds corresponding existing column', function() {
' row exceeds corresponding existing column', function () {
var row7 = {
'col1': {'text': 'row6 col1'},
'col2': {'text': 'some longer string'},
@@ -342,7 +342,7 @@ define(
mockScope.displayRows = testRows.slice(0);
mockScope.rows.push(row7);
controller.addRow(undefined, mockScope.rows.length-1);
controller.addRow(undefined, mockScope.rows.length - 1);
expect(controller.$scope.sizingRow.col2).toEqual({text: 'some longer string'});
});

View File

@@ -40,7 +40,7 @@ define(
function promise(value) {
return {
then: function (callback){
then: function (callback) {
return promise(callback(value));
}
};
@@ -57,13 +57,13 @@ define(
'$digest',
'$broadcast'
]);
mockScope.$on.andCallFake(function (expression, callback){
mockScope.$on.andCallFake(function (expression, callback) {
watches[expression] = callback;
});
mockScope.$watch.andCallFake(function (expression, callback){
watches[expression] = callback;
mockScope.$watch.andCallFake(function (expression, callback) {
watches[expression] = callback;
});
mockScope.$watchCollection.andCallFake(function (expression, callback){
mockScope.$watchCollection.andCallFake(function (expression, callback) {
watches[expression] = callback;
});
@@ -85,7 +85,7 @@ define(
mockTable.buildColumnConfiguration.andReturn(mockConfiguration);
mockTable.getRowValues.andReturn(mockTableRow);
mockDomainObject= jasmine.createSpyObj('domainObject', [
mockDomainObject = jasmine.createSpyObj('domainObject', [
'getCapability',
'useCapability',
'getModel'
@@ -93,7 +93,7 @@ define(
mockDomainObject.getModel.andReturn({});
mockDomainObject.getCapability.andReturn(
{
getMetadata: function (){
getMetadata: function () {
return {ranges: [{format: 'string'}]};
}
});
@@ -132,7 +132,7 @@ define(
});
describe('receives new telemetry', function () {
beforeEach(function() {
beforeEach(function () {
controller.subscribe();
mockScope.rows = [];
});
@@ -151,7 +151,7 @@ define(
}
mockTelemetryHandler.handle.mostRecentCall.args[1]();
expect(mockScope.rows.length).toBe(controller.maxRows);
expect(mockScope.rows[mockScope.rows.length-1]).toBe(mockTableRow);
expect(mockScope.rows[mockScope.rows.length - 1]).toBe(mockTableRow);
expect(mockScope.rows[0].row).toBe(1);
});
});

View File

@@ -26,13 +26,13 @@ define(
],
function (TableOptionsController) {
describe('The Table Options Controller', function() {
describe('The Table Options Controller', function () {
var mockDomainObject,
mockCapability,
controller,
mockScope;
beforeEach(function() {
beforeEach(function () {
mockCapability = jasmine.createSpyObj('mutationCapability', [
'listen'
]);
@@ -53,11 +53,11 @@ define(
controller = new TableOptionsController(mockScope);
});
it('Listens for changing domain object', function() {
it('Listens for changing domain object', function () {
expect(mockScope.$watch).toHaveBeenCalledWith('domainObject', jasmine.any(Function));
});
it('On destruction of controller, destroys listeners', function() {
it('On destruction of controller, destroys listeners', function () {
var unlistenFunc = jasmine.createSpy("unlisten");
controller.listeners.push(unlistenFunc);
expect(mockScope.$on).toHaveBeenCalledWith('$destroy', jasmine.any(Function));
@@ -65,21 +65,21 @@ define(
expect(unlistenFunc).toHaveBeenCalled();
});
it('Registers a listener for mutation events on the object', function() {
it('Registers a listener for mutation events on the object', function () {
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
expect(mockCapability.listen).toHaveBeenCalled();
});
it('Listens for changes to object composition and updates' +
' options accordingly', function() {
' options accordingly', function () {
expect(mockScope.$watchCollection).toHaveBeenCalledWith('configuration.table.columns', jasmine.any(Function));
});
describe('Populates scope with a form definition based on provided' +
' column configuration', function() {
' column configuration', function () {
var mockModel;
beforeEach(function() {
beforeEach(function () {
mockModel = {
configuration: {
table: {
@@ -87,7 +87,7 @@ define(
'column1': true,
'column2': true,
'column3': false,
'column4': true,
'column4': true
}
}
}
@@ -95,19 +95,19 @@ define(
controller.populateForm(mockModel);
});
it('creates form on scope', function() {
it('creates form on scope', function () {
expect(mockScope.columnsForm).toBeDefined();
expect(mockScope.columnsForm.sections[0]).toBeDefined();
expect(mockScope.columnsForm.sections[0].rows).toBeDefined();
expect(mockScope.columnsForm.sections[0].rows.length).toBe(4);
});
it('presents columns as checkboxes', function() {
expect(mockScope.columnsForm.sections[0].rows.every(function(row){
it('presents columns as checkboxes', function () {
expect(mockScope.columnsForm.sections[0].rows.every(function (row) {
return row.control === 'checkbox';
})).toBe(true);
});
});
});
});
});