Skip to content

Commit

Permalink
Lint test configs on commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Aug 21, 2018
1 parent e06e6b7 commit 2d4a062
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 47 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@
"tslint --project test/typescript --fix",
"prettier --write",
"git add"
],
"{test/test,test/*/index,test/utils,test/**/_config}.js": [
"eslint --fix",
"prettier --write",
"git add"
]
}
}
63 changes: 30 additions & 33 deletions test/hooks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,20 +274,19 @@ describe('hooks', () => {
`var input = new URL('../assets/test-19916f7d.ext', import.meta.url).href;\n\nexport default input;\n`
);

return rollup
.rollup({
cache,
input: 'input',
experimentalCodeSplitting: true,
plugins: [
loader({ input: '' }),
{
transform () {
assert.fail('Should cache transform');
}
return rollup.rollup({
cache,
input: 'input',
experimentalCodeSplitting: true,
plugins: [
loader({ input: '' }),
{
transform() {
assert.fail('Should cache transform');
}
]
});
}
]
});
})
.then(bundle => {
return bundle.generate({ format: 'es' });
Expand Down Expand Up @@ -332,22 +331,21 @@ describe('hooks', () => {
`var input = new URL('../assets/test-19916f7d.ext', import.meta.url).href;\n\nexport default input;\n`
);

return rollup
.rollup({
cache,
input: 'input',
experimentalCodeSplitting: true,
plugins: [
loader({ input: '' }),
{
name: 'x',
transform () {
runs++;
return `alert('hello world')`;
}
return rollup.rollup({
cache,
input: 'input',
experimentalCodeSplitting: true,
plugins: [
loader({ input: '' }),
{
name: 'x',
transform() {
runs++;
return `alert('hello world')`;
}
]
});
}
]
});
})
.then(bundle => {
return bundle.generate({ format: 'es' });
Expand Down Expand Up @@ -823,7 +821,7 @@ module.exports = input;
loader({ input: `alert('hello')` }),
{
name: 'x',
buildStart () {
buildStart() {
this.cache.set('first', 'first');
this.cache.set('second', 'second');
}
Expand All @@ -842,9 +840,8 @@ module.exports = input;
loader({ input: `alert('hello')` }),
{
name: 'x',
buildStart () {
if (i === 4)
assert.equal(this.cache.has('second'), true);
buildStart() {
if (i === 4) assert.equal(this.cache.has('second'), true);
}
}
]
Expand All @@ -862,7 +859,7 @@ module.exports = input;
loader({ input: `alert('hello')` }),
{
name: 'x',
buildStart () {
buildStart() {
assert.equal(this.cache.has('first'), false);
assert.equal(this.cache.get('first'), undefined);
assert.equal(this.cache.get('second'), 'second');
Expand Down
31 changes: 17 additions & 14 deletions test/watch/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const assert = require('assert');
const path = require('path');
const sander = require('sander');
const rollup = require('../../dist/rollup');
const path = require('path');

const cwd = process.cwd();

Expand Down Expand Up @@ -38,8 +38,7 @@ describe('rollup.watch', () => {
console.error(event.error);
}
watcher.close();
if (event.code === 'ERROR')
console.log(event.error);
if (event.code === 'ERROR') console.log(event.error);
reject(new Error(`Expected ${next} event, got ${event.code}`));
} else {
go(event);
Expand Down Expand Up @@ -107,7 +106,8 @@ describe('rollup.watch', () => {
});

it('passes file events to the watchChange plugin hook', () => {
let watchChangeId, watchChangeCnt = 0;
let watchChangeId;
let watchChangeCnt = 0;
return sander
.copydir('test/watch/samples/basic')
.to('test/_tmp/input')
Expand All @@ -118,12 +118,14 @@ describe('rollup.watch', () => {
file: 'test/_tmp/output/bundle.js',
format: 'cjs'
},
plugins: [{
watchChange (id) {
watchChangeId = id;
watchChangeCnt++;
plugins: [
{
watchChange(id) {
watchChangeId = id;
watchChangeCnt++;
}
}
}],
],
watch: { chokidar }
});

Expand All @@ -143,10 +145,8 @@ describe('rollup.watch', () => {
() => {
assert.equal(run('../_tmp/output/bundle.js'), 43);
assert.equal(watchChangeId, path.resolve('test/_tmp/input/main.js'));
if (chokidar)
assert.equal(watchChangeCnt, 1);
else
assert.ok(watchChangeCnt >= 1);
if (chokidar) assert.equal(watchChangeCnt, 1);
else assert.ok(watchChangeCnt >= 1);
}
]);
});
Expand Down Expand Up @@ -650,7 +650,10 @@ describe('rollup.watch', () => {
if (err.code !== 'ENOENT') throw err;
this.emitAsset('test', 'test');
}
return { code: `export default ${v++}`, dependencies: v === 2 ? [path.resolve(file)] : [] };
return {
code: `export default ${v++}`,
dependencies: v === 2 ? [path.resolve(file)] : []
};
}
}
],
Expand Down

0 comments on commit 2d4a062

Please sign in to comment.