Migrate all remaining fixtures to jest expect
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// JSON is wrapped because it starts with an uppercase letter, but it
|
||||
// should not be possible to extend it anyway.
|
||||
|
||||
assert.throws(() => class BetterJSON extends JSON {});
|
||||
expect(() => class BetterJSON extends JSON {}).toThrow();
|
||||
|
||||
@@ -11,12 +11,15 @@ class List extends Array {
|
||||
}
|
||||
}
|
||||
|
||||
assert.ok(new List(1) instanceof List, 'new List is an instanceof List');
|
||||
assert.ok(new List(2) instanceof Array, 'new List is an instanceof Array');
|
||||
expect(new List(1) instanceof List).toBe(true);
|
||||
expect(new List(2) instanceof Array).toBe(true);
|
||||
|
||||
var l = new List(3);
|
||||
assert.ok(l.length === 1 && l[0] === 3, 'constructor pushes an entry');
|
||||
assert.ok(l.push(4) === l && l.length === 2 && l.join() === '3,4', 'method override works');
|
||||
expect(l).toHaveLength(1);
|
||||
expect(l[0]).toBe(3);
|
||||
expect(l.push(4)).toBe(l);
|
||||
expect(l).toHaveLength(2);
|
||||
expect(l.join()).toBe('3,4');
|
||||
|
||||
class SecondLevel extends List {
|
||||
method() {
|
||||
@@ -24,11 +27,14 @@ class SecondLevel extends List {
|
||||
}
|
||||
}
|
||||
|
||||
assert.ok(new SecondLevel(1) instanceof SecondLevel, 'new SecondLevel is an instanceof SecondLevel');
|
||||
assert.ok(new SecondLevel(2) instanceof List, 'new SecondLevel is an instanceof List');
|
||||
assert.ok(new SecondLevel(3) instanceof Array, 'new SecondLevel is an instanceof Array');
|
||||
expect(new SecondLevel(1) instanceof SecondLevel).toBe(true);
|
||||
expect(new SecondLevel(2) instanceof List).toBe(true);
|
||||
expect(new SecondLevel(3) instanceof Array).toBe(true);
|
||||
|
||||
var s = new SecondLevel(4);
|
||||
assert.ok(s.length === 1 && s[0] === 4, 'constructor pushes an entry');
|
||||
assert.ok(s.push(5) === s && s.length === 2 && s.join() === '4,5', 'inherited override works');
|
||||
assert.ok(s.method() === s, 'new method works');
|
||||
expect(s).toHaveLength(1);
|
||||
expect(s[0]).toBe(4);
|
||||
expect(s.push(5)).toBe(s);
|
||||
expect(s).toHaveLength(2);
|
||||
expect(s.join()).toBe('4,5');
|
||||
expect(s.method()).toBe(s);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class List extends Array {}
|
||||
|
||||
assert.ok(new List instanceof List);
|
||||
assert.ok(new List instanceof Array);
|
||||
expect(new List instanceof List).toBe(true);
|
||||
expect(new List instanceof Array).toBe(true);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class List extends Array {}
|
||||
|
||||
assert.ok(new List instanceof List);
|
||||
assert.ok(new List instanceof Array);
|
||||
expect(new List instanceof List).toBe(true);
|
||||
expect(new List instanceof Array).toBe(true);
|
||||
|
||||
@@ -6,4 +6,4 @@ class Foo extends Bar {
|
||||
}
|
||||
}
|
||||
|
||||
assert.throws(() => new Foo(), /this hasn't been initialised/);
|
||||
expect(() => new Foo()).toThrow(ReferenceError, "this hasn't been initialised");
|
||||
|
||||
@@ -5,7 +5,7 @@ class Foo {
|
||||
}
|
||||
}
|
||||
|
||||
assert.equal(new Foo().x, 1);
|
||||
expect(new Foo().x).toBe(1);
|
||||
|
||||
class Bar extends Foo {
|
||||
constructor() {
|
||||
@@ -14,17 +14,17 @@ class Bar extends Foo {
|
||||
}
|
||||
}
|
||||
|
||||
assert.equal(new Bar().x, 1);
|
||||
expect(new Bar().x).toBe(1);
|
||||
|
||||
class Bar2 extends Foo {
|
||||
constructor() {
|
||||
super();
|
||||
assert.equal(this.x, 1);
|
||||
expect(this.x).toBe(1);
|
||||
return { x: 2 };
|
||||
}
|
||||
}
|
||||
|
||||
assert.equal(new Bar2().x, 2);
|
||||
expect(new Bar2().x).toBe(2);
|
||||
|
||||
|
||||
let singleton;
|
||||
@@ -38,7 +38,7 @@ class Sub extends Foo {
|
||||
}
|
||||
|
||||
let instance = new Sub;
|
||||
assert.equal(instance, singleton);
|
||||
expect(instance).toBe(singleton);
|
||||
|
||||
instance = new Sub;
|
||||
assert.equal(instance, singleton);
|
||||
expect(instance).toBe(singleton);
|
||||
|
||||
@@ -14,4 +14,4 @@ class Bar extends Foo {
|
||||
|
||||
let i = new Bar();
|
||||
|
||||
assert.equal(i[sym](), 3);
|
||||
expect(i[sym]()).toBe(3);
|
||||
|
||||
@@ -6,4 +6,4 @@ class Foo extends Bar {
|
||||
}
|
||||
}
|
||||
|
||||
assert.throws(() => new Foo(), /this hasn't been initialised/);
|
||||
expect(() => new Foo()).toThrow("this hasn't been initialised");
|
||||
|
||||
@@ -6,4 +6,4 @@ class Foo extends Bar {
|
||||
}
|
||||
}
|
||||
|
||||
assert.throws(() => new Foo(), /this hasn't been initialised/);
|
||||
expect(() => new Foo()).toThrow("this hasn't been initialised");
|
||||
|
||||
@@ -6,4 +6,4 @@ class Foo extends Bar {
|
||||
}
|
||||
}
|
||||
|
||||
assert.throws(() => new Foo(), /this hasn't been initialised/);
|
||||
expect(() => new Foo()).toThrow("this hasn't been initialised");
|
||||
|
||||
@@ -5,7 +5,7 @@ class Foo {
|
||||
}
|
||||
}
|
||||
|
||||
assert.equal(new Foo().x, 1);
|
||||
expect(new Foo().x).toBe(1);
|
||||
|
||||
class Bar extends Foo {
|
||||
constructor() {
|
||||
@@ -14,17 +14,17 @@ class Bar extends Foo {
|
||||
}
|
||||
}
|
||||
|
||||
assert.equal(new Bar().x, 1);
|
||||
expect(new Bar().x).toBe(1);
|
||||
|
||||
class Bar2 extends Foo {
|
||||
constructor() {
|
||||
super();
|
||||
assert.equal(this.x, 1);
|
||||
expect(this.x).toBe(1);
|
||||
return { x: 2 };
|
||||
}
|
||||
}
|
||||
|
||||
assert.equal(new Bar2().x, 2);
|
||||
expect(new Bar2().x).toBe(2);
|
||||
|
||||
|
||||
let singleton;
|
||||
@@ -38,10 +38,10 @@ class Sub extends Foo {
|
||||
}
|
||||
|
||||
let instance = new Sub;
|
||||
assert.equal(instance, singleton);
|
||||
expect(instance).toBe(singleton);
|
||||
|
||||
instance = new Sub;
|
||||
assert.equal(instance, singleton);
|
||||
expect(instance).toBe(singleton);
|
||||
|
||||
class Null extends Foo {
|
||||
constructor() {
|
||||
@@ -53,6 +53,6 @@ class Null extends Foo {
|
||||
}
|
||||
}
|
||||
|
||||
assert.throws(() => {
|
||||
expect(() => {
|
||||
new Null();
|
||||
}, "this");
|
||||
}).toThrow("this");
|
||||
|
||||
@@ -6,4 +6,4 @@ class Foo extends Bar {
|
||||
}
|
||||
}
|
||||
|
||||
assert.throws(() => new Foo(), /this hasn't been initialised/);
|
||||
expect(() => new Foo()).toThrow("this hasn't been initialised");
|
||||
|
||||
@@ -7,4 +7,4 @@ class Foo extends Bar {
|
||||
}
|
||||
}
|
||||
|
||||
assert.throws(() => new Foo(), /this hasn't been initialised/);
|
||||
expect(() => new Foo()).toThrow("this hasn't been initialised");
|
||||
|
||||
@@ -10,4 +10,4 @@ class Foo extends Bar {
|
||||
}
|
||||
}
|
||||
|
||||
assert.throws(() => new Foo(), /this hasn't been initialised/);
|
||||
expect(() => new Foo()).toThrow("this hasn't been initialised");
|
||||
|
||||
@@ -17,4 +17,4 @@ class B extends A {
|
||||
}
|
||||
|
||||
new B();
|
||||
assert.equal(called, true);
|
||||
expect(called).toBe(true);
|
||||
|
||||
@@ -6,4 +6,4 @@ class Foo extends Bar {
|
||||
}
|
||||
}
|
||||
|
||||
assert.throws(() => new Foo(), /this hasn't been initialised/);
|
||||
expect(() => new Foo()).toThrow("this hasn't been initialised");
|
||||
|
||||
@@ -8,4 +8,4 @@ class Foo extends Bar {
|
||||
}
|
||||
}
|
||||
|
||||
assert.throws(() => new Foo(), /this hasn't been initialised/);
|
||||
expect(() => new Foo()).toThrow("this hasn't been initialised");
|
||||
|
||||
@@ -6,4 +6,4 @@ class Foo extends Bar {
|
||||
}
|
||||
}
|
||||
|
||||
assert.throws(() => new Foo(), /this hasn't been initialised/);
|
||||
expect(() => new Foo()).toThrow("this hasn't been initialised");
|
||||
|
||||
@@ -7,4 +7,4 @@ class Foo extends Bar {
|
||||
}
|
||||
}
|
||||
|
||||
assert.throws(() => new Foo());
|
||||
expect(() => new Foo()).toThrow();
|
||||
|
||||
Reference in New Issue
Block a user