Use const/let in specs, not var
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
describe('TreeProcessor', function() {
|
||||
var nodeNumber = 0,
|
||||
let nodeNumber = 0,
|
||||
leafNumber = 0;
|
||||
|
||||
function Node(attrs) {
|
||||
@@ -27,7 +27,7 @@ describe('TreeProcessor', function() {
|
||||
}
|
||||
|
||||
it('processes a single leaf', function() {
|
||||
var leaf = new Leaf(),
|
||||
const leaf = new Leaf(),
|
||||
processor = new jasmineUnderTest.TreeProcessor({
|
||||
tree: leaf,
|
||||
runnableIds: [leaf.id]
|
||||
@@ -44,7 +44,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('processes a single pending leaf', function() {
|
||||
var leaf = new Leaf({ markedPending: true }),
|
||||
const leaf = new Leaf({ markedPending: true }),
|
||||
processor = new jasmineUnderTest.TreeProcessor({
|
||||
tree: leaf,
|
||||
runnableIds: [leaf.id]
|
||||
@@ -61,7 +61,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('processes a single non-specified leaf', function() {
|
||||
var leaf = new Leaf(),
|
||||
const leaf = new Leaf(),
|
||||
processor = new jasmineUnderTest.TreeProcessor({
|
||||
tree: leaf,
|
||||
runnableIds: []
|
||||
@@ -78,7 +78,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('processes a single excluded leaf', function() {
|
||||
var leaf = new Leaf(),
|
||||
const leaf = new Leaf(),
|
||||
processor = new jasmineUnderTest.TreeProcessor({
|
||||
tree: leaf,
|
||||
runnableIds: [leaf.id],
|
||||
@@ -98,7 +98,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('processes a tree with a single leaf with the root specified', function() {
|
||||
var leaf = new Leaf(),
|
||||
const leaf = new Leaf(),
|
||||
parent = new Node({ children: [leaf] }),
|
||||
processor = new jasmineUnderTest.TreeProcessor({
|
||||
tree: parent,
|
||||
@@ -122,7 +122,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('processes a tree with a single pending leaf, with the root specified', function() {
|
||||
var leaf = new Leaf({ markedPending: true }),
|
||||
const leaf = new Leaf({ markedPending: true }),
|
||||
parent = new Node({ children: [leaf] }),
|
||||
processor = new jasmineUnderTest.TreeProcessor({
|
||||
tree: parent,
|
||||
@@ -146,7 +146,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('processes a complicated tree with the root specified', function() {
|
||||
var pendingLeaf = new Leaf({ markedPending: true }),
|
||||
const pendingLeaf = new Leaf({ markedPending: true }),
|
||||
executableLeaf = new Leaf({ markedPending: false }),
|
||||
parent = new Node({ children: [pendingLeaf, executableLeaf] }),
|
||||
childless = new Node(),
|
||||
@@ -218,7 +218,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('marks the run order invalid if it would re-enter a node that does not allow re-entry', function() {
|
||||
var leaf1 = new Leaf(),
|
||||
const leaf1 = new Leaf(),
|
||||
leaf2 = new Leaf(),
|
||||
leaf3 = new Leaf(),
|
||||
reentered = new Node({ noReenter: true, children: [leaf1, leaf2] }),
|
||||
@@ -233,7 +233,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('marks the run order valid if a node being re-entered allows re-entry', function() {
|
||||
var leaf1 = new Leaf(),
|
||||
const leaf1 = new Leaf(),
|
||||
leaf2 = new Leaf(),
|
||||
leaf3 = new Leaf(),
|
||||
reentered = new Node({ children: [leaf1, leaf2] }),
|
||||
@@ -248,7 +248,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it("marks the run order valid if a node which can't be re-entered is only entered once", function() {
|
||||
var leaf1 = new Leaf(),
|
||||
const leaf1 = new Leaf(),
|
||||
leaf2 = new Leaf(),
|
||||
leaf3 = new Leaf(),
|
||||
noReentry = new Node({ noReenter: true }),
|
||||
@@ -263,7 +263,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it("marks the run order valid if a node which can't be re-entered is run directly", function() {
|
||||
var noReentry = new Node({ noReenter: true }),
|
||||
const noReentry = new Node({ noReenter: true }),
|
||||
root = new Node({ children: [noReentry] }),
|
||||
processor = new jasmineUnderTest.TreeProcessor({
|
||||
tree: root,
|
||||
@@ -275,7 +275,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('runs a single leaf', function() {
|
||||
var leaf = new Leaf(),
|
||||
const leaf = new Leaf(),
|
||||
node = new Node({ children: [leaf], userContext: { root: 'context' } }),
|
||||
queueRunner = jasmine.createSpy('queueRunner'),
|
||||
processor = new jasmineUnderTest.TreeProcessor({
|
||||
@@ -301,7 +301,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('runs a node with no children', function() {
|
||||
var node = new Node({ userContext: { node: 'context' } }),
|
||||
const node = new Node({ userContext: { node: 'context' } }),
|
||||
root = new Node({ children: [node], userContext: { root: 'context' } }),
|
||||
nodeStart = jasmine.createSpy('nodeStart'),
|
||||
nodeComplete = jasmine.createSpy('nodeComplete'),
|
||||
@@ -351,7 +351,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('runs a node with children', function() {
|
||||
var leaf1 = new Leaf(),
|
||||
const leaf1 = new Leaf(),
|
||||
leaf2 = new Leaf(),
|
||||
node = new Node({ children: [leaf1, leaf2] }),
|
||||
root = new Node({ children: [node] }),
|
||||
@@ -365,7 +365,7 @@ describe('TreeProcessor', function() {
|
||||
nodeDone = jasmine.createSpy('nodeDone');
|
||||
|
||||
processor.execute(treeComplete);
|
||||
var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
let queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
queueableFns[0].fn(nodeDone);
|
||||
|
||||
queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
@@ -379,7 +379,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('cascades errors up the tree', function() {
|
||||
var leaf = new Leaf(),
|
||||
const leaf = new Leaf(),
|
||||
node = new Node({ children: [leaf] }),
|
||||
root = new Node({ children: [node] }),
|
||||
queueRunner = jasmine.createSpy('queueRunner'),
|
||||
@@ -394,7 +394,7 @@ describe('TreeProcessor', function() {
|
||||
nodeDone = jasmine.createSpy('nodeDone');
|
||||
|
||||
processor.execute(treeComplete);
|
||||
var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
let queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
queueableFns[0].fn(nodeDone);
|
||||
|
||||
queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
@@ -410,7 +410,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('runs an excluded node with leaf', function() {
|
||||
var leaf1 = new Leaf(),
|
||||
const leaf1 = new Leaf(),
|
||||
node = new Node({ children: [leaf1] }),
|
||||
root = new Node({ children: [node] }),
|
||||
queueRunner = jasmine.createSpy('queueRunner'),
|
||||
@@ -427,7 +427,7 @@ describe('TreeProcessor', function() {
|
||||
nodeDone = jasmine.createSpy('nodeDone');
|
||||
|
||||
processor.execute(treeComplete);
|
||||
var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
let queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
queueableFns[0].fn(nodeDone);
|
||||
|
||||
queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
@@ -450,7 +450,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('should execute node with correct arguments when failSpecWithNoExpectations option is set', function() {
|
||||
var leaf = new Leaf(),
|
||||
const leaf = new Leaf(),
|
||||
node = new Node({ children: [leaf] }),
|
||||
root = new Node({ children: [node] }),
|
||||
queueRunner = jasmine.createSpy('queueRunner'),
|
||||
@@ -468,7 +468,7 @@ describe('TreeProcessor', function() {
|
||||
nodeDone = jasmine.createSpy('nodeDone');
|
||||
|
||||
processor.execute(treeComplete);
|
||||
var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
let queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
queueableFns[0].fn(nodeDone);
|
||||
|
||||
queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
@@ -479,7 +479,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('runs beforeAlls for a node with children', function() {
|
||||
var leaf = new Leaf(),
|
||||
const leaf = new Leaf(),
|
||||
node = new Node({
|
||||
children: [leaf],
|
||||
beforeAllFns: [
|
||||
@@ -498,7 +498,7 @@ describe('TreeProcessor', function() {
|
||||
nodeDone = jasmine.createSpy('nodeDone');
|
||||
|
||||
processor.execute(treeComplete);
|
||||
var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
let queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
queueableFns[0].fn(nodeDone);
|
||||
|
||||
queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
@@ -512,7 +512,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('runs afterAlls for a node with children', function() {
|
||||
var leaf = new Leaf(),
|
||||
const leaf = new Leaf(),
|
||||
afterAllFns = [{ fn: 'afterAll1' }, { fn: 'afterAll2' }],
|
||||
node = new Node({
|
||||
children: [leaf],
|
||||
@@ -529,7 +529,7 @@ describe('TreeProcessor', function() {
|
||||
nodeDone = jasmine.createSpy('nodeDone');
|
||||
|
||||
processor.execute(treeComplete);
|
||||
var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
let queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
queueableFns[0].fn(nodeDone);
|
||||
|
||||
queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
@@ -543,7 +543,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('does not run beforeAlls or afterAlls for a node with no children', function() {
|
||||
var node = new Node({
|
||||
const node = new Node({
|
||||
beforeAllFns: [{ fn: 'before' }],
|
||||
afterAllFns: [{ fn: 'after' }]
|
||||
}),
|
||||
@@ -558,7 +558,7 @@ describe('TreeProcessor', function() {
|
||||
nodeDone = jasmine.createSpy('nodeDone');
|
||||
|
||||
processor.execute(treeComplete);
|
||||
var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
let queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
queueableFns[0].fn(nodeDone);
|
||||
|
||||
queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
@@ -567,7 +567,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('does not run beforeAlls or afterAlls for a node with only pending children', function() {
|
||||
var leaf = new Leaf({ markedPending: true }),
|
||||
const leaf = new Leaf({ markedPending: true }),
|
||||
node = new Node({
|
||||
children: [leaf],
|
||||
beforeAllFns: [{ fn: 'before' }],
|
||||
@@ -585,7 +585,7 @@ describe('TreeProcessor', function() {
|
||||
nodeDone = jasmine.createSpy('nodeDone');
|
||||
|
||||
processor.execute(treeComplete);
|
||||
var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
let queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
queueableFns[0].fn(nodeDone);
|
||||
|
||||
queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
@@ -597,7 +597,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('runs leaves in the order specified', function() {
|
||||
var leaf1 = new Leaf(),
|
||||
const leaf1 = new Leaf(),
|
||||
leaf2 = new Leaf(),
|
||||
root = new Node({ children: [leaf1, leaf2] }),
|
||||
queueRunner = jasmine.createSpy('queueRunner'),
|
||||
@@ -609,7 +609,7 @@ describe('TreeProcessor', function() {
|
||||
treeComplete = jasmine.createSpy('treeComplete');
|
||||
|
||||
processor.execute(treeComplete);
|
||||
var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
const queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
queueableFns[0].fn();
|
||||
|
||||
expect(leaf1.execute).not.toHaveBeenCalled();
|
||||
@@ -621,7 +621,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('runs specified leaves before non-specified leaves within a parent node', function() {
|
||||
var specified = new Leaf(),
|
||||
const specified = new Leaf(),
|
||||
nonSpecified = new Leaf(),
|
||||
root = new Node({ children: [nonSpecified, specified] }),
|
||||
queueRunner = jasmine.createSpy('queueRunner'),
|
||||
@@ -633,7 +633,7 @@ describe('TreeProcessor', function() {
|
||||
treeComplete = jasmine.createSpy('treeComplete');
|
||||
|
||||
processor.execute(treeComplete);
|
||||
var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
const queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
queueableFns[0].fn();
|
||||
|
||||
expect(nonSpecified.execute).not.toHaveBeenCalled();
|
||||
@@ -645,7 +645,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('runs nodes and leaves with a specified order', function() {
|
||||
var specifiedLeaf = new Leaf(),
|
||||
const specifiedLeaf = new Leaf(),
|
||||
childLeaf = new Leaf(),
|
||||
specifiedNode = new Node({ children: [childLeaf] }),
|
||||
root = new Node({ children: [specifiedLeaf, specifiedNode] }),
|
||||
@@ -657,11 +657,12 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
processor.execute();
|
||||
var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
const queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
queueableFns[0].fn();
|
||||
|
||||
expect(specifiedLeaf.execute).not.toHaveBeenCalled();
|
||||
var nodeQueueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
const nodeQueueableFns = queueRunner.calls.mostRecent().args[0]
|
||||
.queueableFns;
|
||||
nodeQueueableFns[1].fn();
|
||||
|
||||
expect(childLeaf.execute).toHaveBeenCalled();
|
||||
@@ -672,7 +673,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('runs a node multiple times if the order specified leaves and re-enters it', function() {
|
||||
var leaf1 = new Leaf(),
|
||||
const leaf1 = new Leaf(),
|
||||
leaf2 = new Leaf(),
|
||||
leaf3 = new Leaf(),
|
||||
leaf4 = new Leaf(),
|
||||
@@ -687,7 +688,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
processor.execute();
|
||||
var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
const queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
expect(queueableFns.length).toBe(5);
|
||||
|
||||
queueableFns[0].fn();
|
||||
@@ -715,7 +716,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('runs a parent of a node with segments correctly', function() {
|
||||
var leaf1 = new Leaf(),
|
||||
const leaf1 = new Leaf(),
|
||||
leaf2 = new Leaf(),
|
||||
leaf3 = new Leaf(),
|
||||
leaf4 = new Leaf(),
|
||||
@@ -731,7 +732,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
processor.execute();
|
||||
var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
const queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
expect(queueableFns.length).toBe(5);
|
||||
|
||||
queueableFns[0].fn();
|
||||
@@ -772,7 +773,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('runs nodes in the order they were declared', function() {
|
||||
var leaf1 = new Leaf(),
|
||||
const leaf1 = new Leaf(),
|
||||
leaf2 = new Leaf(),
|
||||
leaf3 = new Leaf(),
|
||||
parent = new Node({ children: [leaf2, leaf3] }),
|
||||
@@ -785,7 +786,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
processor.execute();
|
||||
var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
const queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
expect(queueableFns.length).toBe(2);
|
||||
|
||||
queueableFns[0].fn();
|
||||
@@ -793,7 +794,7 @@ describe('TreeProcessor', function() {
|
||||
|
||||
queueableFns[1].fn();
|
||||
|
||||
var childFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
const childFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
expect(childFns.length).toBe(3);
|
||||
childFns[1].fn();
|
||||
expect(leaf2.execute).toHaveBeenCalled();
|
||||
@@ -803,7 +804,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('runs large segments of nodes in the order they were declared', function() {
|
||||
var leaf1 = new Leaf(),
|
||||
const leaf1 = new Leaf(),
|
||||
leaf2 = new Leaf(),
|
||||
leaf3 = new Leaf(),
|
||||
leaf4 = new Leaf(),
|
||||
@@ -837,7 +838,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
processor.execute();
|
||||
var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
const queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
expect(queueableFns.length).toBe(11);
|
||||
|
||||
queueableFns[0].fn();
|
||||
@@ -875,7 +876,7 @@ describe('TreeProcessor', function() {
|
||||
});
|
||||
|
||||
it('runs nodes in a custom order when orderChildren is overridden', function() {
|
||||
var leaf1 = new Leaf(),
|
||||
const leaf1 = new Leaf(),
|
||||
leaf2 = new Leaf(),
|
||||
leaf3 = new Leaf(),
|
||||
leaf4 = new Leaf(),
|
||||
@@ -907,13 +908,13 @@ describe('TreeProcessor', function() {
|
||||
runnableIds: [root.id],
|
||||
queueRunnerFactory: queueRunner,
|
||||
orderChildren: function(node) {
|
||||
var children = node.children.slice();
|
||||
const children = node.children.slice();
|
||||
return children.reverse();
|
||||
}
|
||||
});
|
||||
|
||||
processor.execute();
|
||||
var queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
const queueableFns = queueRunner.calls.mostRecent().args[0].queueableFns;
|
||||
expect(queueableFns.length).toBe(11);
|
||||
|
||||
queueableFns[0].fn();
|
||||
|
||||
Reference in New Issue
Block a user