Migrate all remaining fixtures to jest expect
This commit is contained in:
@@ -16,4 +16,4 @@ function sum(
|
||||
return acc;
|
||||
}
|
||||
|
||||
assert.equal(sum({arr:[1,2]}), 3);
|
||||
expect(sum({arr:[1,2]})).toBe(3);
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
function f(a, b = a, c = b) { return c; }
|
||||
|
||||
assert.equal(3, f(3));
|
||||
expect(3).toBe(f(3));
|
||||
|
||||
@@ -2,8 +2,8 @@ const bar = true;
|
||||
|
||||
function foo(a = bar, ...b) {
|
||||
const bar = false;
|
||||
assert.equal(b[0], 2);
|
||||
assert.equal(b[1], 3);
|
||||
expect(b[0]).toBe(2);
|
||||
expect(b[1]).toBe(3);
|
||||
}
|
||||
|
||||
foo(1, 2, 3);
|
||||
|
||||
@@ -5,5 +5,5 @@ class Ref {
|
||||
}
|
||||
}
|
||||
|
||||
assert.equal(1, new Ref().id)
|
||||
assert.equal(2, new Ref().id)
|
||||
expect(new Ref().id).toBe(1);
|
||||
expect(new Ref().id).toBe(2);
|
||||
|
||||
@@ -4,4 +4,4 @@ class Ref {
|
||||
}
|
||||
}
|
||||
|
||||
assert.equal(Ref, new Ref().ref)
|
||||
expect(new Ref().ref).toBe(Ref);
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
const a = 1;
|
||||
function rest(b = a, ...a) {
|
||||
assert.equal(b, 1);
|
||||
expect(b).toBe(1);
|
||||
}
|
||||
rest(undefined, 2)
|
||||
|
||||
function rest2(b = a, ...a) {
|
||||
assert.equal(a[0], 2);
|
||||
expect(a[0]).toBe(2);
|
||||
}
|
||||
rest2(undefined, 2)
|
||||
|
||||
function rest3(b = a, ...a) {
|
||||
assert.equal(a.length, 1);
|
||||
expect(a).toHaveLength(1);
|
||||
}
|
||||
rest3(undefined, 2)
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
const a = 1;
|
||||
function rest(b = a, ...a) {
|
||||
assert.equal(b, 1);
|
||||
expect(b).toBe(1);
|
||||
}
|
||||
rest(undefined, 2)
|
||||
|
||||
function rest2(b = a, ...a) {
|
||||
assert.equal(a[0], 2);
|
||||
expect(a[0]).toBe(2);
|
||||
}
|
||||
rest2(undefined, 2)
|
||||
|
||||
function rest3(b = a, ...a) {
|
||||
assert.equal(a.length, 1);
|
||||
expect(a).toHaveLength(1);
|
||||
}
|
||||
rest3(undefined, 2)
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
var a = 1;
|
||||
|
||||
function rest() {
|
||||
var b = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : a;
|
||||
expect(b).toBe(1);
|
||||
}
|
||||
|
||||
rest(undefined, 2);
|
||||
|
||||
function rest2() {
|
||||
var b = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : a;
|
||||
expect(arguments.length <= 1 ? undefined : arguments[1]).toBe(2);
|
||||
}
|
||||
|
||||
rest2(undefined, 2);
|
||||
|
||||
function rest3() {
|
||||
var b = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : a;
|
||||
expect(arguments.length <= 1 ? 0 : arguments.length - 1).toBe(1);
|
||||
}
|
||||
|
||||
rest3(undefined, 2);
|
||||
@@ -2,21 +2,26 @@ var a = 1;
|
||||
|
||||
function rest() {
|
||||
var b = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : a;
|
||||
assert.equal(b, 1);
|
||||
expect(b).toBe(1);
|
||||
}
|
||||
|
||||
rest(undefined, 2);
|
||||
|
||||
function rest2() {
|
||||
var b = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : a;
|
||||
assert.equal(arguments.length <= 1 ? undefined : arguments[1], 2);
|
||||
expect(arguments.length <= 1 ? undefined : arguments[1]).toBe(2);
|
||||
}
|
||||
|
||||
rest2(undefined, 2);
|
||||
|
||||
function rest3() {
|
||||
var b = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : a;
|
||||
assert.equal(arguments.length <= 1 ? 0 : arguments.length - 1, 1);
|
||||
|
||||
for (var _len = arguments.length, a = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||||
a[_key - 1] = arguments[_key];
|
||||
}
|
||||
|
||||
expect(a).toHaveLength(1);
|
||||
}
|
||||
|
||||
rest3(undefined, 2);
|
||||
|
||||
@@ -4,9 +4,9 @@ function f1(a, ...rest) {
|
||||
let d = rest[rest.length - 1];
|
||||
return [a, b, c, d];
|
||||
}
|
||||
assert.deepEqual(f1(1, 2), [1, undefined, undefined, 2])
|
||||
expect(f1(1, 2)).toEqual([1, undefined, undefined, 2]);
|
||||
|
||||
function f2(a, ...rest) {
|
||||
return rest[-1];
|
||||
}
|
||||
assert.equal(f2(1, 2), undefined)
|
||||
expect(f2(1, 2)).toBeUndefined();
|
||||
|
||||
@@ -2,7 +2,7 @@ var length = function (a, b, ...items) {
|
||||
return items.length;
|
||||
};
|
||||
|
||||
assert.equal(length(), 0);
|
||||
assert.equal(length(1), 0);
|
||||
assert.equal(length(1, 2), 0);
|
||||
assert.equal(length(1, 2, 3), 1);
|
||||
expect(length()).toBe(0);
|
||||
expect(length(1)).toBe(0);
|
||||
expect(length(1, 2)).toBe(0);
|
||||
expect(length(1, 2, 3)).toBe(1);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
function t([,,a] = [1,2,3]) { return a }
|
||||
|
||||
assert.equal(t(), 3);
|
||||
assert.equal(t([4,5,6]), 6);
|
||||
expect(t()).toBe(3);
|
||||
expect(t([4,5,6])).toBe(6);
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
function f(a, b = a, c = b) { return c; }
|
||||
|
||||
assert.equal(3, f(3));
|
||||
expect(f(3)).toBe(3);
|
||||
|
||||
@@ -2,8 +2,8 @@ const bar = true;
|
||||
|
||||
function foo(a = bar, ...b) {
|
||||
const bar = false;
|
||||
assert.equal(b[0], 2);
|
||||
assert.equal(b[1], 3);
|
||||
expect(b[0]).toBe(2);
|
||||
expect(b[1]).toBe(3);
|
||||
}
|
||||
|
||||
foo(1, 2, 3);
|
||||
|
||||
@@ -5,5 +5,5 @@ class Ref {
|
||||
}
|
||||
}
|
||||
|
||||
assert.equal(1, new Ref().id)
|
||||
assert.equal(2, new Ref().id)
|
||||
expect(new Ref().id).toBe(1);
|
||||
expect(new Ref().id).toBe(2);
|
||||
|
||||
@@ -4,4 +4,4 @@ class Ref {
|
||||
}
|
||||
}
|
||||
|
||||
assert.equal(Ref, new Ref().ref)
|
||||
expect(new Ref().ref).toBe(Ref);
|
||||
|
||||
@@ -16,4 +16,4 @@ function sum(
|
||||
return acc;
|
||||
}
|
||||
|
||||
assert.equal(sum({arr:[1,2]}), 3);
|
||||
expect(sum({arr:[1,2]})).toBe(3);
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
const a = 1;
|
||||
function rest(b = a, ...a) {
|
||||
assert.equal(b, 1);
|
||||
expect(b).toBe(1);
|
||||
}
|
||||
rest(undefined, 2)
|
||||
|
||||
function rest2(b = a, ...a) {
|
||||
assert.equal(a[0], 2);
|
||||
expect(a[0]).toBe(2);
|
||||
}
|
||||
rest2(undefined, 2)
|
||||
|
||||
function rest3(b = a, ...a) {
|
||||
assert.equal(a.length, 1);
|
||||
expect(a).toHaveLength(1);
|
||||
}
|
||||
rest3(undefined, 2)
|
||||
|
||||
@@ -2,4 +2,4 @@ function t(undefined = 17, a = 3) {
|
||||
return a;
|
||||
}
|
||||
|
||||
assert.equal(t(), 3);
|
||||
expect(t()).toBe(3);
|
||||
|
||||
Reference in New Issue
Block a user