1 | import test from 'ava'
|
2 | import * as path from 'path'
|
3 | import { readFile, writeFile } from 'fs'
|
4 | import { transformFile } from 'babel-core'
|
5 | import pify from 'pify'
|
6 | import yoyoify from '../'
|
7 |
|
8 | const transformFixture = pify(transformFile)
|
9 | const readExpected = pify(readFile)
|
10 | const writeActual = pify(writeFile)
|
11 |
|
12 | function testFixture (name) {
|
13 | test(name, (t) => {
|
14 | const actual = transformFixture(path.join(__dirname, 'fixtures', `${name}.js`), {
|
15 | plugins: [yoyoify]
|
16 | })
|
17 | const expected = readExpected(path.join(__dirname, 'fixtures', `${name}.expected.js`), 'utf8')
|
18 |
|
19 | return actual.then(({ code }) =>
|
20 | expected.then((expectedSrc) => {
|
21 | t.is(code.trim(), expectedSrc.trim())
|
22 |
|
23 | return writeActual(path.join(__dirname, 'fixtures', `${name}.actual.js`), code)
|
24 | }))
|
25 | })
|
26 | }
|
27 |
|
28 | testFixture('simple')
|
29 | testFixture('this')
|
30 | testFixture('variableNames')
|
31 | testFixture('nesting')
|
32 | testFixture('elementsChildren')
|
33 | testFixture('combinedAttr')
|
34 | testFixture('events')
|
35 | testFixture('onload')
|
36 | testFixture('orderOfOperations')
|