Use one declaration per statement
The old style of merging all of a function's variable declarations into a single statement made some sense back in the days of var, but there's no reason to keep doing it now that we use const and let.
This commit is contained in:
@@ -14,8 +14,8 @@
|
||||
*
|
||||
* Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
|
||||
*/
|
||||
const jasmine = jasmineRequire.core(jasmineRequire),
|
||||
global = jasmine.getGlobal();
|
||||
const jasmine = jasmineRequire.core(jasmineRequire);
|
||||
const global = jasmine.getGlobal();
|
||||
global.jasmine = jasmine;
|
||||
|
||||
/**
|
||||
|
||||
@@ -55,15 +55,15 @@ module.exports.noGlobals = function() {
|
||||
return jasmineInterface;
|
||||
};
|
||||
|
||||
const path = require('path'),
|
||||
fs = require('fs');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const rootPath = path.join(__dirname, 'jasmine-core'),
|
||||
bootFiles = ['boot0.js', 'boot1.js'],
|
||||
legacyBootFiles = ['boot.js'],
|
||||
cssFiles = [],
|
||||
jsFiles = [],
|
||||
jsFilesToSkip = ['jasmine.js'].concat(bootFiles, legacyBootFiles);
|
||||
const rootPath = path.join(__dirname, 'jasmine-core');
|
||||
const bootFiles = ['boot0.js', 'boot1.js'];
|
||||
const legacyBootFiles = ['boot.js'];
|
||||
const cssFiles = [];
|
||||
const jsFiles = [];
|
||||
const jsFilesToSkip = ['jasmine.js'].concat(bootFiles, legacyBootFiles);
|
||||
|
||||
fs.readdirSync(rootPath).forEach(function(file) {
|
||||
if (fs.statSync(path.join(rootPath, file)).isFile()) {
|
||||
|
||||
@@ -43,8 +43,8 @@ getJasmineRequireObj().JsApiReporter = function(j$) {
|
||||
return status;
|
||||
};
|
||||
|
||||
const suites = [],
|
||||
suites_hash = {};
|
||||
const suites = [];
|
||||
const suites_hash = {};
|
||||
|
||||
this.suiteStarted = function(result) {
|
||||
suites_hash[result.id] = result;
|
||||
|
||||
@@ -364,10 +364,12 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
}
|
||||
|
||||
const extractCustomPendingMessage = function(e) {
|
||||
const fullMessage = e.toString(),
|
||||
boilerplateStart = fullMessage.indexOf(Spec.pendingSpecExceptionMessage),
|
||||
boilerplateEnd =
|
||||
boilerplateStart + Spec.pendingSpecExceptionMessage.length;
|
||||
const fullMessage = e.toString();
|
||||
const boilerplateStart = fullMessage.indexOf(
|
||||
Spec.pendingSpecExceptionMessage
|
||||
);
|
||||
const boilerplateEnd =
|
||||
boilerplateStart + Spec.pendingSpecExceptionMessage.length;
|
||||
|
||||
return fullMessage.slice(boilerplateEnd);
|
||||
};
|
||||
|
||||
@@ -40,22 +40,22 @@ getJasmineRequireObj().Spy = function(j$) {
|
||||
};
|
||||
const { originalFn, customStrategies, defaultStrategyFn } = optionals || {};
|
||||
|
||||
const numArgs = typeof originalFn === 'function' ? originalFn.length : 0,
|
||||
wrapper = makeFunc(numArgs, function(context, args, invokeNew) {
|
||||
return spy(context, args, invokeNew);
|
||||
}),
|
||||
strategyDispatcher = new SpyStrategyDispatcher(
|
||||
{
|
||||
name: name,
|
||||
fn: originalFn,
|
||||
getSpy: function() {
|
||||
return wrapper;
|
||||
},
|
||||
customStrategies: customStrategies
|
||||
const numArgs = typeof originalFn === 'function' ? originalFn.length : 0;
|
||||
const wrapper = makeFunc(numArgs, function(context, args, invokeNew) {
|
||||
return spy(context, args, invokeNew);
|
||||
});
|
||||
const strategyDispatcher = new SpyStrategyDispatcher(
|
||||
{
|
||||
name: name,
|
||||
fn: originalFn,
|
||||
getSpy: function() {
|
||||
return wrapper;
|
||||
},
|
||||
matchersUtil
|
||||
),
|
||||
callTracker = new j$.private.CallTracker();
|
||||
customStrategies: customStrategies
|
||||
},
|
||||
matchersUtil
|
||||
);
|
||||
const callTracker = new j$.private.CallTracker();
|
||||
|
||||
function makeFunc(length, fn) {
|
||||
switch (length) {
|
||||
|
||||
@@ -200,10 +200,10 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
|
||||
);
|
||||
}
|
||||
|
||||
let pointer = obj,
|
||||
propsToSpyOn = [],
|
||||
properties,
|
||||
propertiesToSkip = [];
|
||||
let pointer = obj;
|
||||
let propsToSpyOn = [];
|
||||
let properties;
|
||||
let propertiesToSkip = [];
|
||||
|
||||
while (
|
||||
pointer &&
|
||||
|
||||
@@ -323,9 +323,9 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
||||
|
||||
function beforeAndAfterFns(targetSuite) {
|
||||
return function() {
|
||||
let befores = [],
|
||||
afters = [],
|
||||
suite = targetSuite;
|
||||
let befores = [];
|
||||
let afters = [];
|
||||
let suite = targetSuite;
|
||||
|
||||
while (suite) {
|
||||
befores = befores.concat(suite.beforeFns);
|
||||
|
||||
@@ -144,15 +144,15 @@ getJasmineRequireObj().TreeProcessor = function(j$) {
|
||||
|
||||
function segmentChildren(node, orderedChildren, stats, executableIndex) {
|
||||
let currentSegment = {
|
||||
index: 0,
|
||||
owner: node,
|
||||
nodes: [],
|
||||
min: startingMin(executableIndex),
|
||||
max: startingMax(executableIndex)
|
||||
},
|
||||
result = [currentSegment],
|
||||
lastMax = defaultMax,
|
||||
orderedChildSegments = orderChildSegments(orderedChildren, stats);
|
||||
index: 0,
|
||||
owner: node,
|
||||
nodes: [],
|
||||
min: startingMin(executableIndex),
|
||||
max: startingMax(executableIndex)
|
||||
};
|
||||
let result = [currentSegment];
|
||||
let lastMax = defaultMax;
|
||||
let orderedChildSegments = orderChildSegments(orderedChildren, stats);
|
||||
|
||||
function isSegmentBoundary(minIndex) {
|
||||
return (
|
||||
@@ -163,9 +163,9 @@ getJasmineRequireObj().TreeProcessor = function(j$) {
|
||||
}
|
||||
|
||||
for (let i = 0; i < orderedChildSegments.length; i++) {
|
||||
const childSegment = orderedChildSegments[i],
|
||||
maxIndex = childSegment.max,
|
||||
minIndex = childSegment.min;
|
||||
const childSegment = orderedChildSegments[i];
|
||||
const maxIndex = childSegment.max;
|
||||
const minIndex = childSegment.min;
|
||||
|
||||
if (isSegmentBoundary(minIndex)) {
|
||||
currentSegment = {
|
||||
@@ -188,12 +188,12 @@ getJasmineRequireObj().TreeProcessor = function(j$) {
|
||||
}
|
||||
|
||||
function orderChildSegments(children, stats) {
|
||||
const specifiedOrder = [],
|
||||
unspecifiedOrder = [];
|
||||
const specifiedOrder = [];
|
||||
const unspecifiedOrder = [];
|
||||
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
const child = children[i],
|
||||
segments = stats[child.id].segments;
|
||||
const child = children[i];
|
||||
const segments = stats[child.id].segments;
|
||||
|
||||
for (let j = 0; j < segments.length; j++) {
|
||||
const seg = segments[j];
|
||||
|
||||
@@ -76,14 +76,14 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
};
|
||||
|
||||
MatchersUtil.prototype.buildFailureMessage = function() {
|
||||
const args = Array.prototype.slice.call(arguments, 0),
|
||||
matcherName = args[0],
|
||||
isNot = args[1],
|
||||
actual = args[2],
|
||||
expected = args.slice(3),
|
||||
englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) {
|
||||
return ' ' + s.toLowerCase();
|
||||
});
|
||||
const args = Array.prototype.slice.call(arguments, 0);
|
||||
const matcherName = args[0];
|
||||
const isNot = args[1];
|
||||
const actual = args[2];
|
||||
const expected = args.slice(3);
|
||||
const englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) {
|
||||
return ' ' + s.toLowerCase();
|
||||
});
|
||||
|
||||
let message =
|
||||
'Expected ' +
|
||||
@@ -465,8 +465,8 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
} else {
|
||||
// Objects with different constructors are not equivalent, but `Object`s
|
||||
// or `Array`s from different frames are.
|
||||
const aCtor = a.constructor,
|
||||
bCtor = b.constructor;
|
||||
const aCtor = a.constructor;
|
||||
const bCtor = b.constructor;
|
||||
if (
|
||||
aCtor !== bCtor &&
|
||||
isFunction(aCtor) &&
|
||||
@@ -572,11 +572,11 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
|
||||
}
|
||||
|
||||
function objectKeysAreDifferentFormatter(pp, actual, expected, path) {
|
||||
const missingProperties = extraKeysAndValues(expected, actual),
|
||||
extraProperties = extraKeysAndValues(actual, expected),
|
||||
missingPropertiesMessage = formatKeyValuePairs(pp, missingProperties),
|
||||
extraPropertiesMessage = formatKeyValuePairs(pp, extraProperties),
|
||||
messages = [];
|
||||
const missingProperties = extraKeysAndValues(expected, actual);
|
||||
const extraProperties = extraKeysAndValues(actual, expected);
|
||||
const missingPropertiesMessage = formatKeyValuePairs(pp, missingProperties);
|
||||
const extraPropertiesMessage = formatKeyValuePairs(pp, extraProperties);
|
||||
const messages = [];
|
||||
|
||||
if (!path.depth()) {
|
||||
path = 'object';
|
||||
|
||||
@@ -2,15 +2,15 @@ getJasmineRequireObj().requireAsyncMatchers = function(jRequire, j$) {
|
||||
'use strict';
|
||||
|
||||
const availableMatchers = [
|
||||
'toBePending',
|
||||
'toBeResolved',
|
||||
'toBeRejected',
|
||||
'toBeResolvedTo',
|
||||
'toBeRejectedWith',
|
||||
'toBeRejectedWithError',
|
||||
'toBeRejectedWithMatching'
|
||||
],
|
||||
matchers = {};
|
||||
'toBePending',
|
||||
'toBeResolved',
|
||||
'toBeRejected',
|
||||
'toBeResolvedTo',
|
||||
'toBeRejectedWith',
|
||||
'toBeRejectedWithError',
|
||||
'toBeRejectedWithMatching'
|
||||
];
|
||||
const matchers = {};
|
||||
|
||||
for (const name of availableMatchers) {
|
||||
matchers[name] = jRequire[name](j$);
|
||||
|
||||
@@ -2,43 +2,43 @@ getJasmineRequireObj().requireMatchers = function(jRequire, j$) {
|
||||
'use strict';
|
||||
|
||||
const availableMatchers = [
|
||||
'nothing',
|
||||
'toBe',
|
||||
'toBeCloseTo',
|
||||
'toBeDefined',
|
||||
'toBeInstanceOf',
|
||||
'toBeFalse',
|
||||
'toBeFalsy',
|
||||
'toBeGreaterThan',
|
||||
'toBeGreaterThanOrEqual',
|
||||
'toBeLessThan',
|
||||
'toBeLessThanOrEqual',
|
||||
'toBeNaN',
|
||||
'toBeNegativeInfinity',
|
||||
'toBeNull',
|
||||
'toBePositiveInfinity',
|
||||
'toBeTrue',
|
||||
'toBeTruthy',
|
||||
'toBeUndefined',
|
||||
'toBeNullish',
|
||||
'toContain',
|
||||
'toEqual',
|
||||
'toHaveSize',
|
||||
'toHaveBeenCalled',
|
||||
'toHaveBeenCalledBefore',
|
||||
'toHaveBeenCalledOnceWith',
|
||||
'toHaveBeenCalledTimes',
|
||||
'toHaveBeenCalledWith',
|
||||
'toHaveClass',
|
||||
'toHaveClasses',
|
||||
'toHaveSpyInteractions',
|
||||
'toHaveNoOtherSpyInteractions',
|
||||
'toMatch',
|
||||
'toThrow',
|
||||
'toThrowError',
|
||||
'toThrowMatching'
|
||||
],
|
||||
matchers = {};
|
||||
'nothing',
|
||||
'toBe',
|
||||
'toBeCloseTo',
|
||||
'toBeDefined',
|
||||
'toBeInstanceOf',
|
||||
'toBeFalse',
|
||||
'toBeFalsy',
|
||||
'toBeGreaterThan',
|
||||
'toBeGreaterThanOrEqual',
|
||||
'toBeLessThan',
|
||||
'toBeLessThanOrEqual',
|
||||
'toBeNaN',
|
||||
'toBeNegativeInfinity',
|
||||
'toBeNull',
|
||||
'toBePositiveInfinity',
|
||||
'toBeTrue',
|
||||
'toBeTruthy',
|
||||
'toBeUndefined',
|
||||
'toBeNullish',
|
||||
'toContain',
|
||||
'toEqual',
|
||||
'toHaveSize',
|
||||
'toHaveBeenCalled',
|
||||
'toHaveBeenCalledBefore',
|
||||
'toHaveBeenCalledOnceWith',
|
||||
'toHaveBeenCalledTimes',
|
||||
'toHaveBeenCalledWith',
|
||||
'toHaveClass',
|
||||
'toHaveClasses',
|
||||
'toHaveSpyInteractions',
|
||||
'toHaveNoOtherSpyInteractions',
|
||||
'toMatch',
|
||||
'toThrow',
|
||||
'toThrowError',
|
||||
'toThrowMatching'
|
||||
];
|
||||
const matchers = {};
|
||||
|
||||
for (const name of availableMatchers) {
|
||||
matchers[name] = jRequire[name](j$);
|
||||
|
||||
@@ -14,11 +14,11 @@ getJasmineRequireObj().toEqual = function(j$) {
|
||||
return {
|
||||
compare: function(actual, expected) {
|
||||
const result = {
|
||||
pass: false
|
||||
},
|
||||
diffBuilder = new j$.private.DiffBuilder({
|
||||
prettyPrinter: matchersUtil.pp
|
||||
});
|
||||
pass: false
|
||||
};
|
||||
const diffBuilder = new j$.private.DiffBuilder({
|
||||
prettyPrinter: matchersUtil.pp
|
||||
});
|
||||
|
||||
result.pass = matchersUtil.equals(actual, expected, diffBuilder);
|
||||
|
||||
|
||||
@@ -18,9 +18,9 @@ getJasmineRequireObj().toHaveBeenCalledOnceWith = function(j$) {
|
||||
function toHaveBeenCalledOnceWith(matchersUtil) {
|
||||
return {
|
||||
compare: function() {
|
||||
const args = Array.prototype.slice.call(arguments, 0),
|
||||
actual = args[0],
|
||||
expectedArgs = args.slice(1);
|
||||
const args = Array.prototype.slice.call(arguments, 0);
|
||||
const actual = args[0];
|
||||
const expectedArgs = args.slice(1);
|
||||
|
||||
if (!j$.isSpy(actual)) {
|
||||
throw new Error(
|
||||
|
||||
@@ -26,8 +26,8 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) {
|
||||
);
|
||||
}
|
||||
|
||||
const args = Array.prototype.slice.call(arguments, 0),
|
||||
result = { pass: false };
|
||||
const args = Array.prototype.slice.call(arguments, 0);
|
||||
const result = { pass: false };
|
||||
|
||||
if (!j$.private.isNumber(expected)) {
|
||||
throw new Error(
|
||||
|
||||
@@ -18,10 +18,10 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
|
||||
function toHaveBeenCalledWith(matchersUtil) {
|
||||
return {
|
||||
compare: function() {
|
||||
const args = Array.prototype.slice.call(arguments, 0),
|
||||
actual = args[0],
|
||||
expectedArgs = args.slice(1),
|
||||
result = { pass: false };
|
||||
const args = Array.prototype.slice.call(arguments, 0);
|
||||
const actual = args[0];
|
||||
const expectedArgs = args.slice(1);
|
||||
const result = { pass: false };
|
||||
|
||||
if (!j$.isSpy(actual)) {
|
||||
throw new Error(
|
||||
|
||||
@@ -20,8 +20,8 @@ getJasmineRequireObj().util = function(j$) {
|
||||
|
||||
util.cloneArgs = function(args) {
|
||||
return Array.from(args).map(function(arg) {
|
||||
const str = Object.prototype.toString.apply(arg),
|
||||
primitives = /^\[object (Boolean|String|RegExp|Number)/;
|
||||
const str = Object.prototype.toString.apply(arg);
|
||||
const primitives = /^\[object (Boolean|String|RegExp|Number)/;
|
||||
|
||||
// All falsey values are either primitives, `null`, or `undefined.
|
||||
if (!arg || str.match(primitives)) {
|
||||
@@ -35,8 +35,8 @@ getJasmineRequireObj().util = function(j$) {
|
||||
};
|
||||
|
||||
util.getPropertyDescriptor = function(obj, methodName) {
|
||||
let descriptor,
|
||||
proto = obj;
|
||||
let descriptor;
|
||||
let proto = obj;
|
||||
|
||||
do {
|
||||
descriptor = Object.getOwnPropertyDescriptor(proto, methodName);
|
||||
|
||||
@@ -138,9 +138,9 @@ jasmineRequire.Banner = function(j$) {
|
||||
};
|
||||
}
|
||||
|
||||
const optionsTrigger = optionsMenuDom.querySelector('.jasmine-trigger'),
|
||||
optionsPayload = optionsMenuDom.querySelector('.jasmine-payload'),
|
||||
isOpen = /\bjasmine-open\b/;
|
||||
const optionsTrigger = optionsMenuDom.querySelector('.jasmine-trigger');
|
||||
const optionsPayload = optionsMenuDom.querySelector('.jasmine-payload');
|
||||
const isOpen = /\bjasmine-open\b/;
|
||||
|
||||
optionsTrigger.onclick = function() {
|
||||
if (isOpen.test(optionsPayload.className)) {
|
||||
|
||||
Reference in New Issue
Block a user