-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.test.js
31 lines (27 loc) · 1.04 KB
/
index.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const { transform } = require('babel-core')
const conf = { plugins: ['syntax-jsx', './index.js'] }
const confWithOptions = {
plugins: [
'syntax-jsx',
['./index.js', { attributes: ['data-custom-test-attr'] }]
]
}
describe('babel-plugin-remove-test-ids', () => {
it('should remove the [data-test-id] attribute if present', () => {
const jsx = '<Component data-test-id="test">Hello!</Component>;'
const expected = '<Component>Hello!</Component>;'
const { code } = transform(jsx, conf)
expect(code).toEqual(expected)
})
it('should remove a custom test attribute', () => {
const jsx = '<Component data-custom-test-attr="test">Hello!</Component>;'
const expected = '<Component>Hello!</Component>;'
const { code } = transform(jsx, confWithOptions)
expect(code).toEqual(expected)
})
it('should do nothing if [data-test-id] attribute is not present', () => {
const jsx = '<Component content="something">Hello again!</Component>;'
const { code } = transform(jsx, conf)
expect(code).toEqual(jsx)
})
})