-
-
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.
Add support for babel jsx/jsxs/jsxDEV
- Loading branch information
1 parent
0aaa855
commit 25ba0f1
Showing
4 changed files
with
91 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
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,38 @@ | ||
import { jsx } from 'preact'; | ||
import { setupScratch, teardown } from '../_util/helpers'; | ||
|
||
describe('Babel jsx/jsxDEV', () => { | ||
let scratch; | ||
|
||
beforeEach(() => { | ||
scratch = setupScratch(); | ||
}); | ||
|
||
afterEach(() => { | ||
teardown(scratch); | ||
}); | ||
|
||
it('should keep ref in props', () => { | ||
const ref = () => null; | ||
const vnode = jsx('div', { ref }); | ||
expect(vnode.props.ref).to.equal(ref); | ||
expect(vnode.ref).to.equal(ref); | ||
}); | ||
|
||
it('should add keys', () => { | ||
const vnode = jsx('div', null, 'foo'); | ||
expect(vnode.props.key).to.equal(undefined); | ||
expect(vnode.key).to.equal('foo'); | ||
}); | ||
|
||
it('should support source and self', () => { | ||
const self = 'foo'; | ||
const source = { | ||
fileName: '/foo.js', | ||
lineNumber: 2 | ||
}; | ||
const vnode = jsx('div', null, 'foo', false, source, self); | ||
expect(vnode.__source).to.equal(source); | ||
expect(vnode.__self).to.equal(self); | ||
}); | ||
}); |