-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: support isFragment * feat: add unit test * feat: CR fixed --------- Co-authored-by: bobihuang <[email protected]> Co-authored-by: Jovi De Croock <[email protected]>
- Loading branch information
1 parent
c294e8b
commit d8f2fb3
Showing
3 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { createElement as preactCreateElement, Fragment } from 'preact'; | ||
import React, { isFragment } from 'preact/compat'; | ||
|
||
describe('isFragment', () => { | ||
it('should check return false for invalid arguments', () => { | ||
expect(isFragment(null)).to.equal(false); | ||
expect(isFragment(false)).to.equal(false); | ||
expect(isFragment(true)).to.equal(false); | ||
expect(isFragment('foo')).to.equal(false); | ||
expect(isFragment(123)).to.equal(false); | ||
expect(isFragment([])).to.equal(false); | ||
expect(isFragment({})).to.equal(false); | ||
}); | ||
|
||
it('should detect a preact vnode', () => { | ||
expect(isFragment(preactCreateElement(Fragment, {}))).to.equal(true); | ||
}); | ||
|
||
it('should detect a compat vnode', () => { | ||
expect(isFragment(React.createElement(Fragment, {}))).to.equal(true); | ||
}); | ||
}); |