This repository was archived by the owner on Nov 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.test.js
More file actions
51 lines (45 loc) · 1.33 KB
/
index.test.js
File metadata and controls
51 lines (45 loc) · 1.33 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import components from '.'
import path from 'path'
import fs from 'mz/fs'
import reshape from 'reshape'
import expressions from 'reshape-expressions'
const fixture = async name => {
const root = path.join(__dirname, 'fixtures', name)
const filename = path.join(root, 'input.html')
const input = (await fs.readFile(filename)).toString()
return reshape({
plugins: [components({ root }), expressions()]
})
.process(input)
.then(result => result.output({ foo: 'caleb' }))
}
test('uses component from other file', async () => {
expect(await fixture('component')).toMatchSnapshot()
})
test('passes locals into component file', async () => {
expect(await fixture('locals')).toMatchSnapshot()
})
describe('import element', () => {
test('should throw if "src" attribute is missing', () => {
return expect(fixture('no-src')).rejects.toHaveProperty(
'message',
`import tag is missing a "src" attribute
From Plugin: reshape-components
Location: [no filename]:1:1
> 1 | <Import as="FooBar"/>
| ^
`
)
})
test('should throw if "as" attribute is missing', () => {
return expect(fixture('no-as')).rejects.toHaveProperty(
'message',
`import tag is missing a "as" attribute
From Plugin: reshape-components
Location: [no filename]:1:1
> 1 | <Import src="./foobar.html"/>
| ^
`
)
})
})