Skip to content

Commit

Permalink
Improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Nov 30, 2019
1 parent 4b07d38 commit f677bef
Show file tree
Hide file tree
Showing 15 changed files with 118 additions and 13 deletions.
2 changes: 1 addition & 1 deletion test/cli/samples/warn-broken-sourcemap/_config.js
Expand Up @@ -12,7 +12,7 @@ module.exports = {
stderr,
'(!) Broken sourcemap\n' +
'https://rollupjs.org/guide/en/#warning-sourcemap-is-likely-to-be-incorrect\n' +
"Plugins that transform code (such as 'test-plugin1', 'test-plugin2' and 'test-plugin3') should generate accompanying sourcemaps"
"Plugins that transform code (such as 'test-plugin1') should generate accompanying sourcemaps\n"
);
}
};
12 changes: 0 additions & 12 deletions test/cli/samples/warn-broken-sourcemap/rollup.config.js
Expand Up @@ -6,18 +6,6 @@ module.exports = {
transform(code) {
return code + '/*1*/';
}
},
{
name: 'test-plugin2',
transform(code) {
return code + '/*2*/';
}
},
{
name: 'test-plugin3',
transform(code) {
return code + '/*3*/';
}
}
],
output: {
Expand Down
18 changes: 18 additions & 0 deletions test/cli/samples/warn-broken-sourcemaps/_config.js
@@ -0,0 +1,18 @@
const fs = require('fs');
const path = require('path');
const { assertStderrIncludes } = require('../../../utils.js');

module.exports = {
description: 'displays warnings for broken sourcemaps',
command: 'rollup -c',
stderr: stderr => {
fs.unlinkSync(path.resolve(__dirname, 'bundle'));
fs.unlinkSync(path.resolve(__dirname, 'bundle.map'));
assertStderrIncludes(
stderr,
'(!) Broken sourcemap\n' +
'https://rollupjs.org/guide/en/#warning-sourcemap-is-likely-to-be-incorrect\n' +
"Plugins that transform code (such as 'test-plugin1', 'test-plugin2' and 'test-plugin3') should generate accompanying sourcemaps"
);
}
};
1 change: 1 addition & 0 deletions test/cli/samples/warn-broken-sourcemaps/main.js
@@ -0,0 +1 @@
console.log('main');
28 changes: 28 additions & 0 deletions test/cli/samples/warn-broken-sourcemaps/rollup.config.js
@@ -0,0 +1,28 @@
module.exports = {
input: 'main.js',
plugins: [
{
name: 'test-plugin1',
transform(code) {
return code + '/*1*/';
}
},
{
name: 'test-plugin2',
transform(code) {
return code + '/*2*/';
}
},
{
name: 'test-plugin3',
transform(code) {
return code + '/*3*/';
}
}
],
output: {
format: 'esm',
file: 'bundle',
sourcemap: true
}
};
9 changes: 9 additions & 0 deletions test/form/samples/default-export-mode/_config.js
@@ -0,0 +1,9 @@
module.exports = {
description: 'allows specifying the export mode to be "default"',
options: {
output: {
exports: 'default',
name: 'bundle'
}
}
};
7 changes: 7 additions & 0 deletions test/form/samples/default-export-mode/_expected/amd.js
@@ -0,0 +1,7 @@
define(function () { 'use strict';

var main = 42;

return main;

});
5 changes: 5 additions & 0 deletions test/form/samples/default-export-mode/_expected/cjs.js
@@ -0,0 +1,5 @@
'use strict';

var main = 42;

module.exports = main;
3 changes: 3 additions & 0 deletions test/form/samples/default-export-mode/_expected/es.js
@@ -0,0 +1,3 @@
var main = 42;

export default main;
8 changes: 8 additions & 0 deletions test/form/samples/default-export-mode/_expected/iife.js
@@ -0,0 +1,8 @@
var bundle = (function () {
'use strict';

var main = 42;

return main;

}());
10 changes: 10 additions & 0 deletions test/form/samples/default-export-mode/_expected/system.js
@@ -0,0 +1,10 @@
System.register('bundle', [], function (exports) {
'use strict';
return {
execute: function () {

var main = exports('default', 42);

}
};
});
11 changes: 11 additions & 0 deletions test/form/samples/default-export-mode/_expected/umd.js
@@ -0,0 +1,11 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = global || self, global.bundle = factory());
}(this, (function () { 'use strict';

var main = 42;

return main;

})));
1 change: 1 addition & 0 deletions test/form/samples/default-export-mode/main.js
@@ -0,0 +1 @@
export default 42;
14 changes: 14 additions & 0 deletions test/function/samples/invalid-default-export-mode/_config.js
@@ -0,0 +1,14 @@
module.exports = {
solo: true,
description: 'throw for invalid default export mode',
options: {
output: {
exports: 'default'
}
},
generateError: {
code: 'INVALID_EXPORT_OPTION',
message:
'"default" was specified for "output.exports", but entry module "main.js" has the following exports: default, foo'
}
};
2 changes: 2 additions & 0 deletions test/function/samples/invalid-default-export-mode/main.js
@@ -0,0 +1,2 @@
export default 42;
export const foo = 43;

0 comments on commit f677bef

Please sign in to comment.