Use expect's instanceOf and toHaveProperty methods
This commit is contained in:
@@ -12,8 +12,8 @@ expect(C.b()).toBe('B.b');
|
||||
|
||||
class D extends Object {}
|
||||
|
||||
expect(D instanceof Object).toBeTruthy();
|
||||
expect(D.prototype instanceof Object).toBeTruthy();
|
||||
expect(D).toBeInstanceOf(Object);
|
||||
expect(D.prototype).toBeInstanceOf(Object);
|
||||
expect(D.keys).toBe(Object.keys);
|
||||
|
||||
class E {}
|
||||
|
||||
@@ -5,5 +5,5 @@ class Foo {
|
||||
}
|
||||
|
||||
const f = new Foo;
|
||||
expect(f instanceof Foo).toBeTruthy();
|
||||
expect(f).toBeInstanceOf(Foo);
|
||||
expect(typeof f).toBe("object");
|
||||
|
||||
@@ -11,8 +11,8 @@ class List extends Array {
|
||||
}
|
||||
}
|
||||
|
||||
expect(new List(1) instanceof List).toBe(true);
|
||||
expect(new List(2) instanceof Array).toBe(true);
|
||||
expect(new List(1)).toBeInstanceOf(List);
|
||||
expect(new List(2)).toBeInstanceOf(Array);
|
||||
|
||||
var l = new List(3);
|
||||
expect(l).toHaveLength(1);
|
||||
@@ -27,9 +27,9 @@ class SecondLevel extends List {
|
||||
}
|
||||
}
|
||||
|
||||
expect(new SecondLevel(1) instanceof SecondLevel).toBe(true);
|
||||
expect(new SecondLevel(2) instanceof List).toBe(true);
|
||||
expect(new SecondLevel(3) instanceof Array).toBe(true);
|
||||
expect(new SecondLevel(1)).toBeInstanceOf(SecondLevel);
|
||||
expect(new SecondLevel(2)).toBeInstanceOf(List);
|
||||
expect(new SecondLevel(3)).toBeInstanceOf(Array);
|
||||
|
||||
var s = new SecondLevel(4);
|
||||
expect(s).toHaveLength(1);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class List extends Array {}
|
||||
|
||||
expect(new List instanceof List).toBe(true);
|
||||
expect(new List instanceof Array).toBe(true);
|
||||
expect(new List).toBeInstanceOf(List);
|
||||
expect(new List).toBeInstanceOf(Array);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class List extends Array {}
|
||||
|
||||
expect(new List instanceof List).toBe(true);
|
||||
expect(new List instanceof Array).toBe(true);
|
||||
expect(new List).toBeInstanceOf(List);
|
||||
expect(new List).toBeInstanceOf(Array);
|
||||
|
||||
Reference in New Issue
Block a user