Use const/let in specs, not var
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
describe('DiffBuilder', function() {
|
||||
it('records the actual and expected objects', function() {
|
||||
var diffBuilder = jasmineUnderTest.DiffBuilder();
|
||||
const diffBuilder = jasmineUnderTest.DiffBuilder();
|
||||
diffBuilder.setRoots({ x: 'actual' }, { x: 'expected' });
|
||||
diffBuilder.recordMismatch();
|
||||
|
||||
@@ -10,7 +10,7 @@ describe('DiffBuilder', function() {
|
||||
});
|
||||
|
||||
it('prints the path at which the difference was found', function() {
|
||||
var diffBuilder = jasmineUnderTest.DiffBuilder();
|
||||
const diffBuilder = jasmineUnderTest.DiffBuilder();
|
||||
diffBuilder.setRoots({ foo: { x: 'actual' } }, { foo: { x: 'expected' } });
|
||||
|
||||
diffBuilder.withPath('foo', function() {
|
||||
@@ -23,7 +23,7 @@ describe('DiffBuilder', function() {
|
||||
});
|
||||
|
||||
it('prints multiple messages, separated by newlines', function() {
|
||||
var diffBuilder = jasmineUnderTest.DiffBuilder();
|
||||
const diffBuilder = jasmineUnderTest.DiffBuilder();
|
||||
diffBuilder.setRoots({ foo: 1, bar: 3 }, { foo: 2, bar: 4 });
|
||||
|
||||
diffBuilder.withPath('foo', function() {
|
||||
@@ -33,14 +33,14 @@ describe('DiffBuilder', function() {
|
||||
diffBuilder.recordMismatch();
|
||||
});
|
||||
|
||||
var message =
|
||||
const message =
|
||||
'Expected $.foo = 1 to equal 2.\n' + 'Expected $.bar = 3 to equal 4.';
|
||||
|
||||
expect(diffBuilder.getMessage()).toEqual(message);
|
||||
});
|
||||
|
||||
it('allows customization of the message', function() {
|
||||
var diffBuilder = jasmineUnderTest.DiffBuilder();
|
||||
const diffBuilder = jasmineUnderTest.DiffBuilder();
|
||||
diffBuilder.setRoots({ x: 'bar' }, { x: 'foo' });
|
||||
|
||||
function darthVaderFormatter(actual, expected, path) {
|
||||
@@ -65,7 +65,7 @@ describe('DiffBuilder', function() {
|
||||
});
|
||||
|
||||
it('uses the injected pretty-printer', function() {
|
||||
var prettyPrinter = function(val) {
|
||||
const prettyPrinter = function(val) {
|
||||
return '|' + val + '|';
|
||||
},
|
||||
diffBuilder = jasmineUnderTest.DiffBuilder({
|
||||
@@ -84,7 +84,7 @@ describe('DiffBuilder', function() {
|
||||
});
|
||||
|
||||
it('passes the injected pretty-printer to the diff formatter', function() {
|
||||
var diffFormatter = jasmine.createSpy('diffFormatter'),
|
||||
const diffFormatter = jasmine.createSpy('diffFormatter'),
|
||||
prettyPrinter = function() {},
|
||||
diffBuilder = jasmineUnderTest.DiffBuilder({
|
||||
prettyPrinter: prettyPrinter
|
||||
@@ -107,13 +107,13 @@ describe('DiffBuilder', function() {
|
||||
});
|
||||
|
||||
it('uses custom object formatters on leaf nodes', function() {
|
||||
var formatter = function(x) {
|
||||
const formatter = function(x) {
|
||||
if (typeof x === 'number') {
|
||||
return '[number:' + x + ']';
|
||||
}
|
||||
};
|
||||
const prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]);
|
||||
var diffBuilder = new jasmineUnderTest.DiffBuilder({
|
||||
const diffBuilder = new jasmineUnderTest.DiffBuilder({
|
||||
prettyPrinter: prettyPrinter
|
||||
});
|
||||
|
||||
@@ -126,16 +126,16 @@ describe('DiffBuilder', function() {
|
||||
});
|
||||
|
||||
it('uses custom object formatters on non leaf nodes', function() {
|
||||
var formatter = function(x) {
|
||||
const formatter = function(x) {
|
||||
if (x.hasOwnProperty('a')) {
|
||||
return '[thing with a=' + x.a + ', b=' + JSON.stringify(x.b) + ']';
|
||||
}
|
||||
};
|
||||
const prettyPrinter = jasmineUnderTest.makePrettyPrinter([formatter]);
|
||||
var diffBuilder = new jasmineUnderTest.DiffBuilder({
|
||||
const diffBuilder = new jasmineUnderTest.DiffBuilder({
|
||||
prettyPrinter: prettyPrinter
|
||||
});
|
||||
var expectedMsg =
|
||||
const expectedMsg =
|
||||
'Expected $[0].foo = [thing with a=1, b={"x":42}] to equal [thing with a=1, b={"x":43}].\n' +
|
||||
"Expected $[0].bar = 'yes' to equal 'no'.";
|
||||
|
||||
@@ -162,7 +162,7 @@ describe('DiffBuilder', function() {
|
||||
});
|
||||
|
||||
it('builds diffs involving asymmetric equality testers that implement valuesForDiff_ at the root', function() {
|
||||
var prettyPrinter = jasmineUnderTest.makePrettyPrinter([]),
|
||||
const prettyPrinter = jasmineUnderTest.makePrettyPrinter([]),
|
||||
diffBuilder = new jasmineUnderTest.DiffBuilder({
|
||||
prettyPrinter: prettyPrinter
|
||||
}),
|
||||
@@ -186,7 +186,7 @@ describe('DiffBuilder', function() {
|
||||
});
|
||||
|
||||
it('builds diffs involving asymmetric equality testers that implement valuesForDiff_ below the root', function() {
|
||||
var prettyPrinter = jasmineUnderTest.makePrettyPrinter([]),
|
||||
const prettyPrinter = jasmineUnderTest.makePrettyPrinter([]),
|
||||
diffBuilder = new jasmineUnderTest.DiffBuilder({
|
||||
prettyPrinter: prettyPrinter
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user