New eslint rules auto fix (#3058)

* no-implicit-coercion and no-unneeded-ternary

* End every line with a semicolon

* Spacing and formatting

* Enabled semi-spacing

* Applies npm run lint:fix to code after master merge

* Fix merge issues

* Switched operator-linebreak to 'before'

Co-authored-by: Joshi <simplyrender@gmail.com>
This commit is contained in:
Andrew Henry
2020-07-31 12:11:03 -07:00
committed by GitHub
parent 573a63d359
commit a09da30768
739 changed files with 4660 additions and 2339 deletions

View File

@@ -117,7 +117,7 @@ define([
) {
return {
name:"platform/commonUI/general",
name: "platform/commonUI/general",
definition: {
"name": "General UI elements",
"description": "General UI elements, meant to be reused across modes",

View File

@@ -20,7 +20,6 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define([
], function (
@@ -34,6 +33,7 @@ define([
if (!splash) {
return;
}
splash.className += ' fadeout';
splash.addEventListener('transitionend', function () {
splash.parentNode.removeChild(splash);

View File

@@ -67,8 +67,8 @@ define(
// Stylesheets which specify themes should only be applied
// when that theme has been declared.
function matchesTheme(stylesheet) {
return stylesheet.theme === undefined ||
stylesheet.theme === activeTheme;
return stylesheet.theme === undefined
|| stylesheet.theme === activeTheme;
}
assetPath = assetPath || ".";

View File

@@ -46,18 +46,22 @@ define(
notification button
*/
$event.stopPropagation();
return action();
};
$scope.dismiss = function (notification, $event) {
$event.stopPropagation();
notification.dismiss();
};
$scope.maximize = function (notification) {
if (notification.model.severity !== "info") {
var dialog;
notification.model.cancel = function () {
dialog.dismiss();
};
//If the notification is dismissed by the user, close
// the dialog.
notification.on('dismiss', function () {
@@ -68,5 +72,6 @@ define(
}
};
}
return BannerController;
});

View File

@@ -56,6 +56,7 @@ define(
this.state = false;
this.$document.off("mouseup", this.clickaway);
};
ClickAwayController.prototype.activate = function () {
this.state = true;
this.$document.on("mouseup", this.clickaway);

View File

@@ -47,12 +47,13 @@ define(
function updateFromModel(value) {
// Only reformat if the value is different from user
// input (to avoid reformatting valid input while typing.)
if (!formatter.validate($scope.textValue) ||
formatter.parse($scope.textValue) !== value) {
if (!formatter.validate($scope.textValue)
|| formatter.parse($scope.textValue) !== value) {
$scope.textValue = formatter.format(value);
$scope.textInvalid = false;
$scope.lastValidValue = $scope.textValue;
}
$scope.pickerModel = { value: value };
}

View File

@@ -35,6 +35,7 @@ define(
while (arr.length < 60) {
arr.push(arr.length);
}
return {
hours: arr.slice(0, 24),
minutes: arr,
@@ -70,7 +71,10 @@ define(
interacted = false;
function generateTable() {
var m = moment.utc({ year: year, month: month }).day(0),
var m = moment.utc({
year: year,
month: month
}).day(0),
table = [],
row,
col;
@@ -142,9 +146,10 @@ define(
$scope.isSelected = function (cell) {
var date = $scope.date || {};
return cell.day === date.day &&
cell.month === date.month &&
cell.year === date.year;
return cell.day === date.day
&& cell.month === date.month
&& cell.year === date.year;
};
$scope.select = function (cell) {
@@ -156,9 +161,9 @@ define(
};
$scope.dateEquals = function (d1, d2) {
return d1.year === d2.year &&
d1.month === d2.month &&
d1.day === d2.day;
return d1.year === d2.year
&& d1.month === d2.month
&& d1.day === d2.day;
};
$scope.changeMonth = function (delta) {
@@ -167,10 +172,12 @@ define(
month = 0;
year += 1;
}
if (month < 0) {
month = 11;
year -= 1;
}
interacted = true;
updateScopeForMonth();
};
@@ -187,8 +194,8 @@ define(
// Ensure some useful default
$scope.ngModel[$scope.field] =
$scope.ngModel[$scope.field] === undefined ?
now() : $scope.ngModel[$scope.field];
$scope.ngModel[$scope.field] === undefined
? now() : $scope.ngModel[$scope.field];
$scope.$watch('ngModel[field]', updateFromModel);
$scope.$watchCollection('date', updateFromView);

View File

@@ -44,12 +44,12 @@ define(
currentParent,
parents = [];
currentParent = currentObj &&
currentObj.hasCapability('context') &&
currentObj.getCapability('context').getParent();
currentParent = currentObj
&& currentObj.hasCapability('context')
&& currentObj.getCapability('context').getParent();
while (currentParent && currentParent.getModel().type !== 'root' &&
currentParent.hasCapability('context')) {
while (currentParent && currentParent.getModel().type !== 'root'
&& currentParent.hasCapability('context')) {
// Record this object
parents.unshift(currentParent);
@@ -87,16 +87,16 @@ define(
// Gets the metadata for the selected object
function getMetadata() {
$scope.metadata = $scope.domainObject &&
$scope.domainObject.hasCapability('metadata') &&
$scope.domainObject.useCapability('metadata');
$scope.metadata = $scope.domainObject
&& $scope.domainObject.hasCapability('metadata')
&& $scope.domainObject.useCapability('metadata');
}
// Set scope variables when the selected object changes
$scope.$watch('domainObject', function () {
$scope.isLink = $scope.domainObject &&
$scope.domainObject.hasCapability('location') &&
$scope.domainObject.getCapability('location').isLink();
$scope.isLink = $scope.domainObject
&& $scope.domainObject.hasCapability('location')
&& $scope.domainObject.getCapability('location').isLink();
if ($scope.isLink) {
getPrimaryPath();
@@ -113,6 +113,7 @@ define(
var unlisten = mutation.listen(getMetadata);
$scope.$on('$destroy', unlisten);
}
return ObjectInspectorController;
}
);

View File

@@ -52,8 +52,8 @@ define(
// Check that a selection is of the valid type
function validateTreeSelection(selectedObject) {
var type = selectedObject &&
selectedObject.getCapability('type');
var type = selectedObject
&& selectedObject.getCapability('type');
// Delegate type-checking to the capability...
if (!type || !type.instanceOf($scope.structure.type)) {
@@ -72,6 +72,7 @@ define(
function getObject(id) {
return objects[id];
}
self.selectedObjects =
ids.filter(getObject).map(getObject);
}
@@ -99,9 +100,6 @@ define(
this.listModel = listModel;
}
// Set the value of the field being edited
SelectorController.prototype.setField = function (value) {
this.$scope.ngModel[this.$scope.field] = value;
@@ -112,7 +110,6 @@ define(
return this.$scope.ngModel[this.$scope.field] || [];
};
/**
* Get the root object to show in the left-hand tree.
* @returns {DomainObject} the root object
@@ -162,7 +159,6 @@ define(
return this.selectedObjects;
};
return SelectorController;
}
);

View File

@@ -136,13 +136,13 @@ define([
TimeRangeController.prototype.defaultBounds = function () {
var t = this.now();
return {
start: t - 24 * 3600 * 1000, // One day
end: t
};
};
TimeRangeController.prototype.updateViewFromModel = function (ngModel) {
ngModel = ngModel || {};
ngModel.outer = ngModel.outer || this.defaultBounds();
@@ -173,6 +173,7 @@ define([
TimeRangeController.prototype.toMillis = function (pixels) {
var span =
this.$scope.ngModel.outer.end - this.$scope.ngModel.outer.start;
return (pixels / this.$scope.spanWidth) * span;
};
@@ -209,9 +210,9 @@ define([
);
// Adjust opposite knob to maintain span
this.$scope.ngModel.inner[opposite] =
this.$scope.ngModel.inner[edge] +
this.initialDragValue[opposite] -
this.initialDragValue[edge];
this.$scope.ngModel.inner[edge]
+ this.initialDragValue[opposite]
- this.initialDragValue[edge];
this.updateViewFromModel(this.$scope.ngModel);
};
@@ -270,6 +271,7 @@ define([
self.$scope.formModel.start;
self.formStartChanged = false;
}
if (self.formEndChanged) {
self.$scope.ngModel.outer.end =
self.$scope.ngModel.inner.end =
@@ -298,13 +300,13 @@ define([
};
TimeRangeController.prototype.validateStart = function (startValue) {
return startValue <=
this.$scope.formModel.end - this.outerMinimumSpan;
return startValue
<= this.$scope.formModel.end - this.outerMinimumSpan;
};
TimeRangeController.prototype.validateEnd = function (endValue) {
return endValue >=
this.$scope.formModel.start + this.outerMinimumSpan;
return endValue
>= this.$scope.formModel.start + this.outerMinimumSpan;
};
return TimeRangeController;

View File

@@ -78,9 +78,9 @@ define(
// id at the current index for equality and perform
// a recursive step for subsequent ids in the paths,
// until we exceed path length or hit a mismatch.
return (index >= nodePath.length) ||
((navPath[index] === nodePath[index]) &&
checkPath(nodePath, navPath, index + 1));
return (index >= nodePath.length)
|| ((navPath[index] === nodePath[index])
&& checkPath(nodePath, navPath, index + 1));
}
// Consider the currently-navigated object and update
@@ -88,10 +88,10 @@ define(
function checkSelection() {
var nodeObject = $scope.domainObject,
navObject = selectedObject,
nodeContext = nodeObject &&
nodeObject.getCapability('context'),
navContext = navObject &&
navObject.getCapability('context'),
nodeContext = nodeObject
&& nodeObject.getCapability('context'),
navContext = navObject
&& navObject.getCapability('context'),
nodePath,
navPath;
@@ -109,8 +109,8 @@ define(
// Check to see if the node's path lies entirely
// within the navigation path; otherwise, navigation
// has happened in some other subtree.
if (navPath.length >= nodePath.length &&
checkPath(nodePath, navPath)) {
if (navPath.length >= nodePath.length
&& checkPath(nodePath, navPath)) {
// nodePath is along the navPath; if it's
// at the end of the path, highlight;
@@ -121,6 +121,7 @@ define(
if ($scope.toggle) {
$scope.toggle.setState(true);
}
self.trackExpansion();
}
@@ -156,6 +157,7 @@ define(
this.$scope.ngModel.selectedObject =
this.$scope.domainObject;
}
if ((this.$scope.parameters || {}).callback) {
this.$scope.parameters.callback(this.$scope.domainObject);
}

View File

@@ -80,6 +80,7 @@ define(
template: function (element, attrs) {
var key = attrs.key,
container = containerMap[key];
return container ? container.template : "";
}
};

View File

@@ -113,6 +113,7 @@ define(
// Don't show selection highlights, etc
event.preventDefault();
return false;
}
@@ -133,6 +134,7 @@ define(
// Don't show selection highlights, etc
event.preventDefault();
return false;
}

View File

@@ -61,21 +61,22 @@ define(
// Determine how long to wait before the next update
function currentInterval() {
return attrs.mctResizeInterval ?
scope.$eval(attrs.mctResizeInterval) :
DEFAULT_INTERVAL;
return attrs.mctResizeInterval
? scope.$eval(attrs.mctResizeInterval)
: DEFAULT_INTERVAL;
}
// Evaluate mct-resize with the current bounds
function fireEval(bounds) {
// Only update when bounds actually change
if (!lastBounds ||
lastBounds.width !== bounds.width ||
lastBounds.height !== bounds.height) {
if (!lastBounds
|| lastBounds.width !== bounds.width
|| lastBounds.height !== bounds.height) {
scope.$eval(attrs.mctResize, { bounds: bounds });
if (!linking) { // Avoid apply-in-a-digest
scope.$apply();
}
lastBounds = bounds;
}
}
@@ -86,6 +87,7 @@ define(
if (!active) {
return;
}
fireEval({
width: element[0].offsetWidth,
height: element[0].offsetHeight

View File

@@ -66,7 +66,6 @@ define(
});
});
}
return {

View File

@@ -102,17 +102,17 @@ define(
position,
splitterSize,
alias = $attrs.alias !== undefined ?
"mctSplitPane-" + $attrs.alias : undefined,
alias = $attrs.alias !== undefined
? "mctSplitPane-" + $attrs.alias : undefined,
//convert string to number from localStorage
userWidthPreference = $window.localStorage.getItem(alias) === null ?
undefined : Number($window.localStorage.getItem(alias));
userWidthPreference = $window.localStorage.getItem(alias) === null
? undefined : Number($window.localStorage.getItem(alias));
// Get relevant size (height or width) of DOM element
function getSize(domElement) {
return (anchor.orientation === 'vertical' ?
domElement.offsetWidth : domElement.offsetHeight);
return (anchor.orientation === 'vertical'
? domElement.offsetWidth : domElement.offsetHeight);
}
// Apply styles to child elements
@@ -146,9 +146,10 @@ define(
var children = $element.children();
// Check to make sure contents are well-formed
if (children.length !== 3 ||
children[1].nodeName.toLowerCase() !== 'mct-splitter') {
if (children.length !== 3
|| children[1].nodeName.toLowerCase() !== 'mct-splitter') {
$log.warn(CHILDREN_WARNING_MESSAGE);
return;
}
@@ -202,6 +203,7 @@ define(
$log.warn(ANCHOR_WARNING_MESSAGE);
anchorKey = DEFAULT_ANCHOR;
}
anchor = ANCHORS[anchorKey];
$scope.$watch($attrs.position, getSetPosition);
@@ -223,7 +225,6 @@ define(
$interval.cancel(activeInterval);
});
// Interface exposed by controller, for mct-splitter to user
return {
anchor: function () {
@@ -235,6 +236,7 @@ define(
}
setUserWidthPreference(newPosition);
return getSetPosition(newPosition);
},
startResizing: function () {
@@ -254,6 +256,7 @@ define(
controller: ['$scope', '$element', '$attrs', controller]
};
}
return MCTSplitPane;
}

View File

@@ -25,10 +25,10 @@ define(
function () {
// Pixel width to allocate for the splitter itself
var SPLITTER_TEMPLATE = "<div class='abs'" +
"mct-drag-down=\"splitter.startMove()\" " +
"mct-drag=\"splitter.move(delta)\" " +
"mct-drag-up=\"splitter.endMove()\"></div>";
var SPLITTER_TEMPLATE = "<div class='abs'"
+ "mct-drag-down=\"splitter.startMove()\" "
+ "mct-drag=\"splitter.move(delta)\" "
+ "mct-drag-up=\"splitter.endMove()\"></div>";
/**
* Implements `mct-splitter` directive.
@@ -52,11 +52,11 @@ define(
move: function (delta) {
var anchor = mctSplitPane.anchor(),
index = anchor.orientation === "vertical" ? 0 : 1,
pixelDelta = delta[index] *
(anchor.reversed ? -1 : 1);
pixelDelta = delta[index]
* (anchor.reversed ? -1 : 1);
// Update the position of this splitter
newPosition = initialPosition + pixelDelta;
newPosition = initialPosition + pixelDelta;
if (initialPosition !== newPosition) {
mctSplitPane.position(newPosition);

View File

@@ -31,6 +31,7 @@ define([
return true;
};
}
if (!scope.onSelection) {
scope.onSelection = function () {};
}
@@ -42,10 +43,13 @@ define([
if (currentSelection === domainObject) {
return;
}
if (!scope.allowSelection(domainObject)) {
treeView.value(currentSelection);
return;
}
currentSelection = domainObject;
scope.onSelection(domainObject);
scope.selectedObject = domainObject;

View File

@@ -25,17 +25,17 @@
*/
define(['zepto'], function ($) {
var OVERLAY_TEMPLATE = '' +
' <div class="abs blocker"></div>' +
' <div class="abs outer-holder">' +
' <a class="close icon-x-in-circle"></a>' +
' <div class="abs inner-holder l-flex-col">' +
' <div class="t-contents flex-elem holder grows"></div>' +
' <div class="bottom-bar flex-elem holder">' +
' <a class="t-done s-button major">Done</a>' +
' </div>' +
' </div>' +
' </div>';
var OVERLAY_TEMPLATE = ''
+ ' <div class="abs blocker"></div>'
+ ' <div class="abs outer-holder">'
+ ' <a class="close icon-x-in-circle"></a>'
+ ' <div class="abs inner-holder l-flex-col">'
+ ' <div class="t-contents flex-elem holder grows"></div>'
+ ' <div class="bottom-bar flex-elem holder">'
+ ' <a class="t-done s-button major">Done</a>'
+ ' </div>'
+ ' </div>'
+ ' </div>';
/*
* An Overlay Service when instantiated creates an overlay dialog.
@@ -91,7 +91,7 @@ define(['zepto'], function ($) {
this.overlayContainer = this.overlay.querySelector('.t-contents');
this.closeButton = this.overlay.querySelector('a.close');
this.closeButton = this.overlay.querySelector('a.close');
this.closeButton.addEventListener('click', this.toggleOverlay);
this.doneButton = this.overlay.querySelector('a.t-done');
@@ -171,13 +171,14 @@ define(['zepto'], function ($) {
};
function newButtonTemplate(classString, title) {
var NEW_BUTTON_TEMPLATE = '<a class="s-button labeled' + classString + '">' +
'<span class="title-label">' + title + '</span>' +
'</a>';
var NEW_BUTTON_TEMPLATE = '<a class="s-button labeled' + classString + '">'
+ '<span class="title-label">' + title + '</span>'
+ '</a>';
var button = document.createElement('div');
$(button).addClass('holder flex-elem');
button.innerHTML = NEW_BUTTON_TEMPLATE;
return button;
}

View File

@@ -102,7 +102,7 @@ define(
if (position[0] > margin[0]) {
styles.right = (winDim[0] - position[0] + offset[0]) + 'px';
} else {
styles.left = (position[0] + offset[0]) + 'px';
styles.left = (position[0] + offset[0]) + 'px';
}
if (position[1] > margin[1]) {

View File

@@ -47,8 +47,8 @@ define(
* @returns {string} URL for the domain object
*/
UrlService.prototype.urlForLocation = function (mode, domainObject) {
var context = domainObject &&
domainObject.getCapability('context'),
var context = domainObject
&& domainObject.getCapability('context'),
objectPath = context ? context.getPath() : [],
ids = objectPath.map(function (domainObj) {
return domainObj.getId();
@@ -80,10 +80,12 @@ define(
arr.push(key + '=' + search[key]);
}
}
var searchPath = "?" + arr.join('&'),
newTabPath =
"#" + this.urlForLocation(mode, domainObject) +
searchPath;
"#" + this.urlForLocation(mode, domainObject)
+ searchPath;
return newTabPath;
};

View File

@@ -25,7 +25,7 @@ define([
'../../res/templates/tree/toggle.html'
], function ($, toggleTemplate) {
function ToggleView(state) {
this.expanded = !!state;
this.expanded = Boolean(state);
this.callbacks = [];
this.el = $(toggleTemplate);
this.el.on('click', function () {
@@ -49,6 +49,7 @@ define([
ToggleView.prototype.observe = function (callback) {
this.callbacks.push(callback);
return function () {
this.callbacks = this.callbacks.filter(function (c) {
return c !== callback;

View File

@@ -32,11 +32,13 @@ define([
function isLink(domainObject) {
var location = domainObject.getCapability('location');
return location.isLink();
}
function getClass(domainObject) {
var type = domainObject.getCapability('type');
return type.getCssClass();
}

View File

@@ -41,6 +41,7 @@ define([
this.li.find('.c-tree__item-subtree').eq(0)
.append($(this.subtreeView.elements()));
}
$(this.subtreeView.elements()).removeClass('hidden');
} else if (this.subtreeView) {
$(this.subtreeView.elements()).addClass('hidden');
@@ -83,7 +84,7 @@ define([
this.activeObject = domainObject;
if (domainObject && domainObject.hasCapability('adapter')) {
var obj = domainObject.useCapability('adapter');
var hasComposition = this.openmct.composition.get(obj) !== undefined;
var hasComposition = this.openmct.composition.get(obj) !== undefined;
if (hasComposition) {
$(this.toggleView.elements()).addClass('is-enabled');
} else {
@@ -127,10 +128,10 @@ define([
}
this.onSelectionPath =
!!domainObject &&
!!this.activeObject &&
(activeIdPath.length <= selectedIdPath.length) &&
activeIdPath.every(function (id, index) {
Boolean(domainObject)
&& Boolean(this.activeObject)
&& (activeIdPath.length <= selectedIdPath.length)
&& activeIdPath.every(function (id, index) {
return selectedIdPath[index] === id;
});

View File

@@ -121,6 +121,7 @@ define([
TreeView.prototype.observe = function (callback) {
this.callbacks.push(callback);
return function () {
this.callbacks = this.callbacks.filter(function (c) {
return c !== callback;
@@ -136,6 +137,5 @@ define([
return this.ul;
};
return TreeView;
});

View File

@@ -52,6 +52,7 @@ define([
describe('when element exists', function () {
beforeEach(function () {
$document.querySelectorAll.and.returnValue([splashElement]);
return new SplashScreenManager([$document]);
});

View File

@@ -40,9 +40,18 @@ define(
};
testStyleSheets = [
{ stylesheetUrl: "d.css", bundle: testBundle },
{ stylesheetUrl: "e.css", bundle: testBundle },
{ stylesheetUrl: "f.css", bundle: testBundle }
{
stylesheetUrl: "d.css",
bundle: testBundle
},
{
stylesheetUrl: "e.css",
bundle: testBundle
},
{
stylesheetUrl: "f.css",
bundle: testBundle
}
];
mockPlainDocument =
@@ -105,7 +114,6 @@ define(
});
});
});
}
);

View File

@@ -35,6 +35,7 @@ define(
["perform", "getMetadata"]
);
action.getMetadata.and.returnValue(metadata);
return action;
}
@@ -62,14 +63,32 @@ define(
mockScope.parameters = { category: "test" };
mockActions.getActions.and.returnValue([
{ group: "a", someKey: 0 },
{ group: "a", someKey: 1 },
{ group: "b", someKey: 2 },
{ group: "a", someKey: 3 },
{ group: "b", someKey: 4 },
{
group: "a",
someKey: 0
},
{
group: "a",
someKey: 1
},
{
group: "b",
someKey: 2
},
{
group: "a",
someKey: 3
},
{
group: "b",
someKey: 4
},
{ someKey: 5 },
{ someKey: 6 },
{ group: "a", someKey: 7 },
{
group: "a",
someKey: 7
},
{ someKey: 8 }
].map(mockAction));

View File

@@ -87,8 +87,6 @@ define(
expect(mockDocument.off).toHaveBeenCalledWith("mouseup", callback);
});
});
}
);

View File

@@ -188,7 +188,6 @@ define(
});
});
}
);

View File

@@ -46,6 +46,7 @@ define(
['getId']
);
mockObject.getId.and.returnValue(id);
return mockObject;
}
@@ -89,7 +90,10 @@ define(
});
it("watches for changes in selection in left-hand tree", function () {
var testObject = { a: 123, b: 456 };
var testObject = {
a: 123,
b: 456
};
// This test is sensitive to ordering of watch calls
expect(mockScope.$watch.calls.count()).toEqual(1);
// Make sure we're watching the correct object

View File

@@ -106,7 +106,7 @@ define(
it("exposes end time validator", function () {
var testValue = 42000000;
mockScope.formModel = { start: testValue };
mockScope.formModel = { start: testValue };
expect(controller.validateEnd(testValue - 1))
.toBe(false);
expect(controller.validateEnd(testValue + 60 * 60 * 1000 + 1))
@@ -116,8 +116,14 @@ define(
describe("when changes are made via form entry", function () {
beforeEach(function () {
mockScope.ngModel = {
outer: { start: DAY * 2, end: DAY * 3 },
inner: { start: DAY * 2.25, end: DAY * 2.75 }
outer: {
start: DAY * 2,
end: DAY * 3
},
inner: {
start: DAY * 2.25,
end: DAY * 2.75
}
};
mockScope.formModel = {
start: DAY * 10000,

View File

@@ -159,7 +159,6 @@ define(
expect(controller.isSelected()).toBeFalsy();
});
it("does not expand a node if no context is available", function () {
var mockParentContext = jasmine.createSpyObj(
"parentContext",

View File

@@ -55,19 +55,40 @@ define(
it("maintains the current selection when views change", function () {
var views = [
{ key: "a", name: "View A" },
{ key: "b", name: "View B" },
{ key: "c", name: "View C" },
{ key: "d", name: "View D" }
{
key: "a",
name: "View A"
},
{
key: "b",
name: "View B"
},
{
key: "c",
name: "View C"
},
{
key: "d",
name: "View D"
}
];
mockScope.$watch.calls.mostRecent().args[1](views);
mockScope.ngModel.selected = views[1];
// Change the set of applicable views
mockScope.$watch.calls.mostRecent().args[1]([
{ key: "a", name: "View A" },
{ key: "b", name: "View B" },
{ key: "x", name: "View X" }
{
key: "a",
name: "View A"
},
{
key: "b",
name: "View B"
},
{
key: "x",
name: "View X"
}
]);
// "b" is still in there, should remain selected
@@ -76,19 +97,40 @@ define(
it("chooses a default if a selected view becomes inapplicable", function () {
var views = [
{ key: "a", name: "View A" },
{ key: "b", name: "View B" },
{ key: "c", name: "View C" },
{ key: "d", name: "View D" }
{
key: "a",
name: "View A"
},
{
key: "b",
name: "View B"
},
{
key: "c",
name: "View C"
},
{
key: "d",
name: "View D"
}
];
mockScope.$watch.calls.mostRecent().args[1](views);
mockScope.ngModel.selected = views[1];
// Change the set of applicable views
mockScope.$watch.calls.mostRecent().args[1]([
{ key: "a", name: "View A" },
{ key: "c", name: "View C" },
{ key: "x", name: "View X" }
{
key: "a",
name: "View A"
},
{
key: "c",
name: "View C"
},
{
key: "x",
name: "View X"
}
]);
// "b" is still in there, should remain selected

View File

@@ -27,12 +27,18 @@ define(
describe("The mct-container directive", function () {
var testContainers = [
{
bundle: { path: "a", resources: "b" },
bundle: {
path: "a",
resources: "b"
},
template: "<div>foo</div>",
key: "abc"
},
{
bundle: { path: "x", resources: "y" },
bundle: {
path: "x",
resources: "y"
},
template: "<span>bar</span>",
key: "xyz",
attributes: ["someAttr", "someOtherAttr"]

View File

@@ -87,7 +87,10 @@ define(
mockElement.on.calls.mostRecent().args[1](event);
expect(mockScope.$eval).toHaveBeenCalledWith(
testAttrs.mctDragDown,
{ delta: [0, 0], $event: event }
{
delta: [0, 0],
$event: event
}
);
});
@@ -118,7 +121,10 @@ define(
// Should have passed that delta to mct-drag expression
expect(mockScope.$eval).toHaveBeenCalledWith(
testAttrs.mctDrag,
{ delta: [10, 140], $event: event }
{
delta: [10, 140],
$event: event
}
);
});
@@ -145,7 +151,10 @@ define(
// initial position
expect(mockScope.$eval).toHaveBeenCalledWith(
testAttrs.mctDragUp,
{ delta: [-2, 11], $event: event }
{
delta: [-2, 11],
$event: event
}
);
// Should also have unregistered listeners
@@ -215,7 +224,10 @@ define(
mockElement.on.calls.mostRecent().args[1](event);
expect(mockScope.$eval).toHaveBeenCalledWith(
testAttrs.mctDragDown,
{ delta: [0, 0], $event: event }
{
delta: [0, 0],
$event: event
}
);
});
@@ -246,7 +258,10 @@ define(
// Should have passed that delta to mct-drag expression
expect(mockScope.$eval).toHaveBeenCalledWith(
testAttrs.mctDrag,
{ delta: [10, 140], $event: event }
{
delta: [10, 140],
$event: event
}
);
});
@@ -273,7 +288,10 @@ define(
// initial position
expect(mockScope.$eval).toHaveBeenCalledWith(
testAttrs.mctDragUp,
{ delta: [-2, 11], $event: event }
{
delta: [-2, 11],
$event: event
}
);
// Should also have unregistered listeners

View File

@@ -78,6 +78,7 @@ define(
mockCompile.and.callFake(function () {
var mockFn = jasmine.createSpy();
mockFn.and.returnValue(mockNewElement);
return mockFn;
});
mockElement.parent.and.returnValue([mockParentEl]);

View File

@@ -35,7 +35,10 @@ define(
mockTimeout = jasmine.createSpy("$timeout");
mockScope = jasmine.createSpyObj("$scope", ["$eval", "$on", "$apply"]);
testElement = { offsetWidth: 100, offsetHeight: 200 };
testElement = {
offsetWidth: 100,
offsetHeight: 200
};
testAttrs = { mctResize: "some-expr" };
mctResize = new MCTResize(mockTimeout);
@@ -55,7 +58,12 @@ define(
);
expect(mockScope.$eval).toHaveBeenCalledWith(
testAttrs.mctResize,
{ bounds: { width: 100, height: 200 } }
{
bounds: {
width: 100,
height: 200
}
}
);
});
@@ -69,7 +77,12 @@ define(
// Shouldn't know about this yet...
expect(mockScope.$eval).not.toHaveBeenCalledWith(
testAttrs.mctResize,
{ bounds: { width: 300, height: 350 } }
{
bounds: {
width: 300,
height: 350
}
}
);
// Fire the timeout
@@ -79,7 +92,12 @@ define(
// with the new width & height
expect(mockScope.$eval).toHaveBeenCalledWith(
testAttrs.mctResize,
{ bounds: { width: 300, height: 350 } }
{
bounds: {
width: 300,
height: 350
}
}
);
});

View File

@@ -27,7 +27,6 @@ define(
ATTRIBUTE = "testAttribute",
EXPRESSION = "some.expression";
// MCTScroll is the commonality between mct-scroll-x and
// mct-scroll-y; it gets the event property to watch and
// the attribute which contains the associated assignable

View File

@@ -51,7 +51,7 @@ define(
mockParsed.assign = jasmine.createSpy('assign');
mockParse.and.returnValue(mockParsed);
mockWindow.localStorage = {
mockWindow.localStorage = {
store: {},
setItem: function (key, value) {
this.store[key] = value;
@@ -114,13 +114,19 @@ define(
mockChildren.eq.and.callFake(function (i) {
return [mockFirstPane, mockSplitter, mockSecondPane][i];
});
mockFirstPane[0] = { offsetWidth: 123, offsetHeight: 456 };
mockFirstPane[0] = {
offsetWidth: 123,
offsetHeight: 456
};
mockSplitter[0] = {
nodeName: 'mct-splitter',
offsetWidth: 10,
offsetHeight: 456
};
mockSecondPane[0] = { offsetWidth: 10, offsetHeight: 456 };
mockSecondPane[0] = {
offsetWidth: 10,
offsetHeight: 456
};
mockChildren[0] = mockFirstPane[0];
mockChildren[1] = mockSplitter[0];
@@ -146,10 +152,10 @@ define(
it("exposes the current anchoring mode", function () {
expect(controller.anchor()).toEqual({
edge : 'left',
opposite : 'right',
dimension : 'width',
orientation : 'vertical'
edge: 'left',
opposite: 'right',
dimension: 'width',
orientation: 'vertical'
});
});

View File

@@ -98,7 +98,7 @@ define(
});
it("tell's the splitter when it is done resizing", function () {
mockScope.splitter.move([10,0]);
mockScope.splitter.move([10, 0]);
mockScope.splitter.endMove();
expect(mockSplitPane.endResizing).toHaveBeenCalledWith(testPosition + 10);
});

View File

@@ -40,6 +40,7 @@ define([
]);
mockDomainObject.getId.and.returnValue(id);
mockDomainObject.getModel.and.returnValue({});
return mockDomainObject;
}
@@ -126,8 +127,10 @@ define([
it("does trigger $apply from tree manipulation", function () {
if (/PhantomJS/g.test(window.navigator.userAgent)) {
console.log('Unable to run test in PhantomJS due to lack of support for event constructors');
return;
}
// White-boxy; we know this is the setter for the tree's value
var treeValueFn = TreeView.prototype.observe.calls.all()[0].args[0];

View File

@@ -20,7 +20,6 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(
["../../src/services/PopupService"],
function (PopupService) {
@@ -34,7 +33,10 @@ define(
beforeEach(function () {
mockDocument = jasmine.createSpyObj('$document', ['find']);
testWindow = { innerWidth: 1000, innerHeight: 800 };
testWindow = {
innerWidth: 1000,
innerHeight: 800
};
mockBody = jasmine.createSpyObj('body', ['append']);
mockElement = jasmine.createSpyObj('element', [
'css',

View File

@@ -20,7 +20,6 @@
* at runtime from the About dialog for additional information.
*****************************************************************************/
define(
["../../src/services/Popup"],
function (Popup) {
@@ -33,7 +32,10 @@ define(
beforeEach(function () {
mockElement =
jasmine.createSpyObj('element', ['css', 'remove']);
testStyles = { left: '12px', top: '14px' };
testStyles = {
left: '12px',
top: '14px'
};
popup = new Popup(mockElement, testStyles);
});

View File

@@ -53,7 +53,10 @@ define(
mockContext = jasmine.createSpyObj('context', ['getPath']);
testViews = [
{ key: 'abc' },
{ key: 'def', someKey: 'some value' },
{
key: 'def',
someKey: 'some value'
},
{ key: 'xyz' }
];
mockMode = "browse";

View File

@@ -49,7 +49,7 @@ define([
mockDomainObj.getId.and.returnValue(id);
mockDomainObj.getModel.and.returnValue(model);
mockDomainObj.hasCapability.and.callFake(function (c) {
return !!(capabilities[c]);
return Boolean(capabilities[c]);
});
mockDomainObj.getCapability.and.callFake(function (c) {
return capabilities[c];
@@ -57,6 +57,7 @@ define([
mockDomainObj.useCapability.and.callFake(function (c) {
return capabilities[c] && capabilities[c].invoke();
});
return mockDomainObj;
}
@@ -131,6 +132,7 @@ define([
.and.returnValue(Promise.resolve(mockComposition));
treeView.model(mockDomainObject);
return testCapabilities.composition.invoke();
});
@@ -149,6 +151,7 @@ define([
mockComposition.pop();
testCapabilities.mutation.listen
.calls.mostRecent().args[0](mockDomainObject.getModel());
return testCapabilities.composition.invoke();
});
@@ -232,6 +235,7 @@ define([
return testCapabilities.composition.invoke().then(function () {
treeView.value(mockGrandchild);
return newCapabilities.composition.invoke();
});
});