Skip to content

Commit 1e21a95

Browse files
committed
Port tests to ESM
1 parent 8a01a37 commit 1e21a95

23 files changed

Lines changed: 98 additions & 121 deletions

test/base.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
'use strict'
2-
const test = require('ava')
3-
const path = require('path')
1+
import test from 'ava'
2+
import path from 'path'
43

5-
const cli = require('./helpers/cli.js')
6-
const tmp = require('./helpers/tmp.js')
7-
const read = require('./helpers/read.js')
4+
import cli from './helpers/cli.js'
5+
import tmp from './helpers/tmp.js'
6+
import read from './helpers/read.js'
87

98
test('--base --dir works', async (t) => {
109
const dir = tmp()

test/cli.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
'use strict'
2-
const test = require('ava')
1+
import test from 'ava'
32

4-
const cli = require('./helpers/cli.js')
5-
const tmp = require('./helpers/tmp.js')
6-
const read = require('./helpers/read.js')
3+
import cli from './helpers/cli.js'
4+
import tmp from './helpers/tmp.js'
5+
import read from './helpers/read.js'
76

87
test('works with defaults', async (t) => {
98
const output = tmp('output.css')

test/config.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
'use strict'
2-
const test = require('ava')
3-
const path = require('path')
1+
import test from 'ava'
2+
import path from 'path'
43

5-
const ENV = require('./helpers/env.js')
4+
import ENV from './helpers/env.js'
65

7-
const cli = require('./helpers/cli.js')
8-
const read = require('./helpers/read.js')
6+
import cli from './helpers/cli.js'
7+
import read from './helpers/read.js'
98

109
test('supports common config', async (t) => {
1110
const env = `module.exports = {

test/dir.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
'use strict'
2-
const test = require('ava')
3-
const path = require('path')
1+
import test from 'ava'
2+
import path from 'path'
43

5-
const cli = require('./helpers/cli.js')
6-
const tmp = require('./helpers/tmp.js')
7-
const read = require('./helpers/read.js')
4+
import cli from './helpers/cli.js'
5+
import tmp from './helpers/tmp.js'
6+
import read from './helpers/read.js'
87

98
test('--dir works', async (t) => {
109
const dir = tmp()

test/error.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
'use strict'
2-
const test = require('ava')
1+
import test from 'ava'
32

4-
const tmp = require('./helpers/tmp.js')
5-
const cli = require('./helpers/cli.js')
3+
import tmp from './helpers/tmp.js'
4+
import cli from './helpers/cli.js'
65

76
test('multiple input files && --output', (t) => {
87
return cli(['test/fixtures/*.css', '-o', tmp()]).then(({ error, code }) => {

test/ext.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
'use strict'
2-
const test = require('ava')
1+
import test from 'ava'
32

4-
const fs = require('fs-extra')
5-
const path = require('path')
3+
import fs from 'fs-extra'
4+
import path from 'path'
65

7-
const cli = require('./helpers/cli.js')
8-
const tmp = require('./helpers/tmp.js')
6+
import cli from './helpers/cli.js'
7+
import tmp from './helpers/tmp.js'
98

109
test('--ext works', async (t) => {
1110
const dir = tmp()

test/fixtures/_bad-plugin.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
'use strict'
21
throw new Error('This fails')

test/glob.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
'use strict'
2-
const test = require('ava')
3-
const path = require('path')
1+
import test from 'ava'
2+
import path from 'path'
43

5-
const cli = require('./helpers/cli.js')
6-
const tmp = require('./helpers/tmp.js')
7-
const read = require('./helpers/read.js')
4+
import cli from './helpers/cli.js'
5+
import tmp from './helpers/tmp.js'
6+
import read from './helpers/read.js'
87

98
test('works with glob patterns', async (t) => {
109
const output = tmp()

test/helpers/clean.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
'use strict'
2-
const fs = require('fs-extra')
1+
import fs from 'fs-extra'
32

43
Promise.all([
54
fs.emptyDir('./test/fixtures/.tmp/'),

test/helpers/cli.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
'use strict'
2-
const path = require('path')
3-
const { exec } = require('child_process')
1+
import path from 'path'
2+
import { exec } from 'child_process'
43

5-
module.exports = function (args, cwd) {
4+
export default function (args, cwd) {
65
return new Promise((resolve) => {
76
exec(
87
`node ${path.resolve('index.js')} ${args.join(' ')}`,

0 commit comments

Comments
 (0)