@@ -4,6 +4,41 @@ import { describe, it } from 'mocha';
4
4
import { instanceOf } from '../instanceOf' ;
5
5
6
6
describe ( 'instanceOf' , ( ) => {
7
+ it ( 'do not throw on values without prototype' , ( ) => {
8
+ class Foo {
9
+ // $FlowFixMe[unsupported-syntax]
10
+ get [ Symbol . toStringTag ] ( ) {
11
+ return 'Foo' ;
12
+ }
13
+ }
14
+
15
+ expect ( instanceOf ( true , Foo ) ) . to . equal ( false ) ;
16
+ expect ( instanceOf ( null , Foo ) ) . to . equal ( false ) ;
17
+ expect ( instanceOf ( Object . create ( null ) , Foo ) ) . to . equal ( false ) ;
18
+ } ) ;
19
+
20
+ it ( 'detect name clashes with older versions of this lib' , ( ) => {
21
+ function oldVersion ( ) {
22
+ class Foo { }
23
+ return Foo ;
24
+ }
25
+
26
+ function newVersion ( ) {
27
+ class Foo {
28
+ // $FlowFixMe[unsupported-syntax]
29
+ get [ Symbol . toStringTag ] ( ) {
30
+ return 'Foo' ;
31
+ }
32
+ }
33
+ return Foo ;
34
+ }
35
+
36
+ const NewClass = newVersion ( ) ;
37
+ const OldClass = oldVersion ( ) ;
38
+ expect ( instanceOf ( new NewClass ( ) , NewClass ) ) . to . equal ( true ) ;
39
+ expect ( ( ) => instanceOf ( new OldClass ( ) , NewClass ) ) . to . throw ( ) ;
40
+ } ) ;
41
+
7
42
it ( 'allows instances to have share the same constructor name' , ( ) => {
8
43
function getMinifiedClass ( tag : string ) {
9
44
class SomeNameAfterMinification {
0 commit comments