Skip to content

Commit b828557

Browse files
greenkeeper[bot]pvdlg
authored andcommitted
chore(package): update ava to version 3.1.0
1 parent b73f9de commit b828557

6 files changed

Lines changed: 50 additions & 47 deletions

File tree

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
"version": "0.0.0-development",
55
"author": "Pierre Vanduynslager (https://github.com/pvdlg)",
66
"ava": {
7-
"helpers": [
8-
"test/helpers/**/*"
9-
],
107
"files": [
118
"test/*.test.js"
129
]
@@ -23,7 +20,7 @@
2320
},
2421
"devDependencies": {
2522
"@metahub/karma-jasmine-jquery": "^3.0.0",
26-
"ava": "^2.4.0",
23+
"ava": "^3.1.0",
2724
"@babel/core": "^7.0.0",
2825
"@babel/preset-env": "^7.0.0",
2926
"codecov": "^3.0.0",

test/helpers/karma.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import pEvent from 'p-event';
2-
import {Server, constants} from 'karma';
3-
import karmaPreprocessor from '../..';
4-
import {mockFactory} from './mock';
1+
const pEvent = require('p-event');
2+
const {Server, constants} = require('karma');
3+
const karmaPreprocessor = require('../..');
4+
const {mockFactory} = require('./mock');
55

66
/**
77
* Base Karma configuration tu run preprocessor.
@@ -44,7 +44,7 @@ const KARMA_CONFIG = {
4444
* @param {Object} [config] configuration to pass to the preprocessor.
4545
* @return {Promise<KarmaOutput>} A `Promise` that resolve to the Karma execution results.
4646
*/
47-
export async function run(files, config) {
47+
async function run(files, config) {
4848
const server = createServer(files, config, false, karmaPreprocessor);
4949

5050
server.start();
@@ -64,7 +64,7 @@ export async function run(files, config) {
6464
* @param {Object} [config] configuration to pass to the preprocessor.
6565
* @return {Server} The started Karma Server.
6666
*/
67-
export async function watch(files, config) {
67+
async function watch(files, config) {
6868
const {factory, watcher} = mockFactory(true);
6969
const server = createServer(files, config, true, factory);
7070

@@ -103,7 +103,7 @@ function createServer(files, config, autoWatch, processorFactory) {
103103
* @param {Server} server A Karma server started in autoWatch mode.
104104
* @return {Promise<KarmaOutput>} A `Promise` that resolve to the Karma execution results.
105105
*/
106-
export async function waitForRunComplete(server) {
106+
async function waitForRunComplete(server) {
107107
try {
108108
const [, result] = await pEvent(server, 'run_complete', {
109109
multiArgs: true,
@@ -121,3 +121,5 @@ export async function waitForRunComplete(server) {
121121
return {success, failed, error: err, disconnected, exitCode: 1};
122122
}
123123
}
124+
125+
module.exports = {run, watch, waitForRunComplete};

test/helpers/mock.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import {EventEmitter} from 'events';
2-
import proxyquire from 'proxyquire';
3-
import {spy, stub} from 'sinon';
4-
import pify from 'pify';
1+
const {EventEmitter} = require('events');
2+
const proxyquire = require('proxyquire');
3+
const {spy, stub} = require('sinon');
4+
const pify = require('pify');
55

66
/**
77
* @typedef {Object} MockPreprocessor
@@ -30,7 +30,7 @@ import pify from 'pify';
3030
* @param {Boolean} autoWatch `true` for autoWatch mode, `false` for a single run.
3131
* @return {MockFactory} mocked preprocessor factory and watcher.
3232
*/
33-
export function mockFactory(autoWatch) {
33+
function mockFactory(autoWatch) {
3434
const FSWatcher = stub();
3535

3636
return {
@@ -64,7 +64,7 @@ export function mockFactory(autoWatch) {
6464
* @param {Object} [config={}] Karma config to pass to the factory.
6565
* @return {MockPreprocessor} mocked preprocessor function and spies.
6666
*/
67-
export async function mockPreprocessor(args = {}, config = {}) {
67+
async function mockPreprocessor(args = {}, config = {}) {
6868
const debug = spy();
6969
const error = spy();
7070
const info = spy();
@@ -85,3 +85,5 @@ export async function mockPreprocessor(args = {}, config = {}) {
8585

8686
return {preprocessor, debug, error, info, refreshFiles, watcher: await watcher, FSWatcher};
8787
}
88+
89+
module.exports = {mockFactory, mockPreprocessor};

test/helpers/utils.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import path from 'path';
2-
import {readFile} from 'fs-extra';
3-
import pEvent from 'p-event';
4-
import sourceMappingURL from 'source-map-url';
5-
import postcss from 'postcss';
1+
const path = require('path');
2+
const {readFile} = require('fs-extra');
3+
const pEvent = require('p-event');
4+
const sourceMappingURL = require('source-map-url');
5+
const postcss = require('postcss');
66

77
/**
88
* Return a Promise that resolve when an event is emitted and reject after a timeout expire if the event is not emitted.
@@ -13,7 +13,7 @@ import postcss from 'postcss';
1313
* @param {Number} [timeout=30000] maximum time to wait for the event to be emitted.
1414
* @return {Promise} Promise tht resolve when the event is emitted.
1515
*/
16-
export function waitFor(emitter, event, timeout = 30000) {
16+
function waitFor(emitter, event, timeout = 30000) {
1717
return pEvent(emitter, event, {timeout});
1818
}
1919

@@ -31,7 +31,7 @@ export function waitFor(emitter, event, timeout = 30000) {
3131
* @param {Object} [options={}] postcss options.
3232
* @return {Compiled} compiled code and source map.
3333
*/
34-
export async function compile(file, options = {}) {
34+
async function compile(file, options = {}) {
3535
if (options.sourceMap || options.map) {
3636
options.map = {inline: false};
3737
}
@@ -51,3 +51,5 @@ export async function compile(file, options = {}) {
5151
map: map ? JSON.parse(map.toString()) : undefined,
5252
};
5353
}
54+
55+
module.exports = {waitFor, compile};

test/integration.test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import path from 'path';
2-
import {copy} from 'fs-extra';
3-
import test from 'ava';
4-
import {stub} from 'sinon';
5-
import tempy from 'tempy';
6-
import cssnano from 'cssnano';
7-
import mixins from 'postcss-mixins';
8-
import simpleVars from 'postcss-simple-vars';
9-
import atImport from 'postcss-import';
10-
import {run, watch, waitForRunComplete} from './helpers/karma';
1+
const path = require('path');
2+
const {copy} = require('fs-extra');
3+
const test = require('ava');
4+
const {stub} = require('sinon');
5+
const tempy = require('tempy');
6+
const cssnano = require('cssnano');
7+
const mixins = require('postcss-mixins');
8+
const simpleVars = require('postcss-simple-vars');
9+
const atImport = require('postcss-import');
10+
const {run, watch, waitForRunComplete} = require('./helpers/karma');
1111

1212
let stubWrite;
1313

test/unit.test.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import path from 'path';
2-
import {readFile, copy, outputFile, remove} from 'fs-extra';
3-
import test from 'ava';
4-
import {spy, match} from 'sinon';
5-
import tempy from 'tempy';
6-
import cssnano from 'cssnano';
7-
import mixins from 'postcss-mixins';
8-
import simpleVars from 'postcss-simple-vars';
9-
import atImport from 'postcss-import';
10-
import {waitFor, compile} from './helpers/utils';
11-
import {mockPreprocessor} from './helpers/mock';
1+
const path = require('path');
2+
const {readFile, copy, outputFile, remove} = require('fs-extra');
3+
const test = require('ava');
4+
const {spy, match} = require('sinon');
5+
const tempy = require('tempy');
6+
const cssnano = require('cssnano');
7+
const mixins = require('postcss-mixins');
8+
const simpleVars = require('postcss-simple-vars');
9+
const atImport = require('postcss-import');
10+
const {waitFor, compile} = require('./helpers/utils');
11+
const {mockPreprocessor} = require('./helpers/mock');
1212

1313
test('Compile css file', async t => {
1414
const fixture = 'test/fixtures/basic.css';
@@ -155,7 +155,7 @@ test('Log error on invalid css file', async t => {
155155
const options = {plugins: [atImport, mixins, simpleVars, cssnano]};
156156
const {preprocessor, debug, error} = await mockPreprocessor({}, {postcssPreprocessor: {options}});
157157
const file = {originalPath: fixture};
158-
const err = await t.throwsAsync(preprocessor(await readFile(fixture), file), {instanceOf: Object});
158+
const err = await t.throwsAsync(preprocessor(await readFile(fixture), file), {instanceOf: Error});
159159

160160
t.is(err.name, 'CssSyntaxError');
161161
t.true(debug.firstCall.calledWith(match('Processing'), fixture));
@@ -467,7 +467,7 @@ test('Call refreshFiles when dependency is deleted and added', async t => {
467467
t.true(refreshFiles.calledOnce);
468468
info.resetHistory();
469469
refreshFiles.resetHistory();
470-
await t.throwsAsync(preprocessor(await readFile(fixture), file), Error);
470+
await t.throwsAsync(preprocessor(await readFile(fixture), file), {instanceOf: Error});
471471
const cpy = waitFor(watcher, 'add');
472472

473473
await copy('test/fixtures/partials/partial.css', partial);

0 commit comments

Comments
 (0)