Use expect's instanceOf and toHaveProperty methods

This commit is contained in:
Deven Bansod
2018-03-27 21:59:38 +05:30
parent c9b99af5a6
commit b09c729675
51 changed files with 101 additions and 124 deletions

View File

@@ -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 {}

View File

@@ -5,5 +5,5 @@ class Foo {
}
const f = new Foo;
expect(f instanceof Foo).toBeTruthy();
expect(f).toBeInstanceOf(Foo);
expect(typeof f).toBe("object");

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);