Skip to content

Commit

Permalink
Fix browser tests by switching back to var
Browse files Browse the repository at this point in the history
  • Loading branch information
papandreou committed Nov 19, 2020
1 parent bcd2a12 commit 3f01198
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 30 deletions.
28 changes: 16 additions & 12 deletions test/api/inspect.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,18 +337,20 @@ describe('inspect', () => {

it('should output the body of a function', () => {
expect(
/* eslint-disable no-var */
function () {
let foo = 'bar';
const quux = 'baz';
var foo = 'bar';
var quux = 'baz';
while (foo) {
foo = foo.substr(0, foo.length - 1);
}
return quux;
},
/* eslint-enable no-var */
'to inspect as',
'function () {\n' +
" let foo = 'bar';\n" +
" const quux = 'baz';\n" +
" var foo = 'bar';\n" +
" var quux = 'baz';\n" +
' while (foo) {\n' +
' foo = foo.substr(0, foo.length - 1);\n' +
' }\n' +
Expand Down Expand Up @@ -408,23 +410,23 @@ describe('inspect', () => {
});
}

/* eslint-disable no-multi-str */
/* eslint-disable no-multi-str, no-var */
function multilineStringLiteral() {
let foo = 'bar';
const quux = 'baz\
var foo = 'bar';
var quux = 'baz\
blah';
foo = foo + quux;
return foo;
}
/* eslint-enable no-multi-str */
/* eslint-enable no-multi-str, no-var */

it('should bail out of removing the indentation of functions that use multiline string literals', () => {
expect(
multilineStringLiteral,
'to inspect as',
'function multilineStringLiteral() {\n' +
" let foo = 'bar';\n" +
" const quux = 'baz\\\n" +
" var foo = 'bar';\n" +
" var quux = 'baz\\\n" +
" blah';\n" +
' foo = foo + quux;\n' +
' return foo;\n' +
Expand All @@ -435,9 +437,11 @@ describe('inspect', () => {
it('should bail out of removing the indentation of one-liner functions', () => {
expect(
// prettier-ignore
function() { const foo = 123;return foo; },
/* eslint-disable no-var */
function() { var foo = 123;return foo; },
/* eslint-enable no-var */
'to inspect as',
'function () { const foo = 123;return foo; }'
'function () { var foo = 123;return foo; }'
);
});

Expand Down
6 changes: 4 additions & 2 deletions test/assertions/to-be-rejected-with-error-satisfying.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,15 @@ describe('to be rejected with error satisfying assertion', () => {
// prettier-ignore
function () {
return expect(
/* eslint-disable no-var */
function() {
return expect.promise(function () {
const error = new Error('foobar');
var error = new Error('foobar');
error.data = { foo: 'bar' };
throw error;
});
},
/* eslint-enable no-var */
'to be rejected with error exhaustively satisfying',
new Error('foobar')
);
Expand All @@ -216,7 +218,7 @@ describe('to be rejected with error satisfying assertion', () => {
'expected\n' +
'function () {\n' +
' return expect.promise(function () {\n' +
" const error = new Error('foobar');\n" +
" var error = new Error('foobar');\n" +
" error.data = { foo: 'bar' };\n" +
' throw error;\n' +
' });\n' +
Expand Down
32 changes: 16 additions & 16 deletions test/types/function-type.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,49 +45,49 @@ describe('function type', () => {
});

it('should inspect a one-line function correctly', () => {
/* eslint-disable no-unused-vars */
/* eslint-disable no-unused-vars, no-var */
expect(
// prettier-ignore
function() { const a = 123;console.log(a); },
function() { var a = 123;console.log(a); },
'to inspect as',
'function () { const a = 123;console.log(a); }'
'function () { var a = 123;console.log(a); }'
);
/* eslint-enable no-unused-vars */
/* eslint-enable no-unused-vars, no-var */
});

it('should inspect a short one-line function with leading and trailing newline correctly', () => {
/* eslint-disable no-unused-vars */
/* eslint-disable no-unused-vars, no-var */
expect(
// prettier-ignore
function() {
const a = 123;console.log(a); },
var a = 123;console.log(a); },
'to inspect as',
'function () { const a = 123;console.log(a); }'
'function () { var a = 123;console.log(a); }'
);
/* eslint-enable no-unused-vars */
/* eslint-enable no-unused-vars, no-var */
});

it('should inspect a long one-line function with leading and trailing newline correctly', () => {
/* eslint-disable no-unused-vars */
/* eslint-disable no-unused-vars, no-var */
expect(
// prettier-ignore
function() {
const a = 123 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2;console.log(a);
var a = 123 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2;console.log(a);
},
'to inspect as',
'function () {\n' +
' const a = 123 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2;console.log(a);\n' +
' var a = 123 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2 * 2;console.log(a);\n' +
'}'
);
/* eslint-enable no-unused-vars */
/* eslint-enable no-unused-vars, no-var */
});

/* eslint-disable no-unused-vars */
/* eslint-disable no-unused-vars, no-var */
function twoLinesWithComment() {
const a = 123;
var a = 123;
console.log(a); // foo
}
/* eslint-enable no-unused-vars */
/* eslint-enable no-unused-vars, no-var */

it('should inspect a short two-line function with leading and trailing newline correctly and a C++-style comment correctly', () => {
/* eslint-disable no-unused-vars */
Expand All @@ -96,7 +96,7 @@ describe('function type', () => {
twoLinesWithComment,
'to inspect as',
'function twoLinesWithComment() {\n' +
' const a = 123;\n console.log(a); // foo\n' +
' var a = 123;\n console.log(a); // foo\n' +
'}'
);
/* eslint-enable no-unused-vars */
Expand Down

0 comments on commit 3f01198

Please sign in to comment.