Skip to content

Commit f9b0bae

Browse files
IvanGoncharovmjmahone
authored andcommitted
Add simple test for instanceOf. (#1370)
1 parent ae23c90 commit f9b0bae

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import { expect } from 'chai';
9+
import { describe, it } from 'mocha';
10+
import instanceOf from '../instanceOf';
11+
12+
describe('instanceOf', () => {
13+
it('fails with descriptive error message', () => {
14+
function getFoo() {
15+
class Foo {}
16+
return Foo;
17+
}
18+
const Foo1 = getFoo();
19+
const Foo2 = getFoo();
20+
21+
expect(() => instanceOf(new Foo1(), Foo2)).to.throw(
22+
/^Cannot use Foo "\[object Object\]" from another module or realm./m,
23+
);
24+
expect(() => instanceOf(new Foo2(), Foo1)).to.throw(
25+
/^Cannot use Foo "\[object Object\]" from another module or realm./m,
26+
);
27+
});
28+
});

0 commit comments

Comments
 (0)