Skip to content

Commit

Permalink
Improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Jan 25, 2020
1 parent 48c74c2 commit 3d86d24
Show file tree
Hide file tree
Showing 18 changed files with 54 additions and 36 deletions.
2 changes: 1 addition & 1 deletion cli/run/index.ts
Expand Up @@ -16,7 +16,7 @@ export default function runRollup(command: any) {
if (command.input) {
handleError({
code: 'DUPLICATE_IMPORT_OPTIONS',
message: 'use --input, or pass input path as argument'
message: 'Either use --input, or pass input path as argument'
});
}
inputSource = command._;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/parseOptions.ts
Expand Up @@ -43,7 +43,7 @@ const getObjectOption = (
const commandOption = normalizeObjectOptionValue(overrides[name]);
const configOption = normalizeObjectOptionValue(config[name]);
if (commandOption !== undefined) {
return commandOption && configOption ? { ...configOption, ...commandOption } : commandOption;
return commandOption && { ...configOption, ...commandOption };
}
return configOption;
};
Expand Down
11 changes: 0 additions & 11 deletions test/cli/node_modules/rollup-config-foo/lib/config.js

This file was deleted.

3 changes: 0 additions & 3 deletions test/cli/node_modules/rollup-config-foo/package.json

This file was deleted.

File renamed without changes.
File renamed without changes.
11 changes: 0 additions & 11 deletions test/cli/node_modules_rename_me/foo/lib/config.js

This file was deleted.

3 changes: 0 additions & 3 deletions test/cli/node_modules_rename_me/foo/package.json

This file was deleted.

10 changes: 10 additions & 0 deletions test/cli/samples/duplicate-import-options/_config.js
@@ -0,0 +1,10 @@
const { assertStderrIncludes } = require('../../../utils.js');

module.exports = {
description: 'throws if different types of entries are combined',
command: 'rollup main.js --format es --input main.js',
error: () => true,
stderr(stderr) {
assertStderrIncludes(stderr, '[!] Either use --input, or pass input path as argument');
}
};
1 change: 1 addition & 0 deletions test/cli/samples/duplicate-import-options/main.js
@@ -0,0 +1 @@
assert.equal( 1 + 1, 2 );
10 changes: 8 additions & 2 deletions test/cli/samples/external-modules-auto-global/_config.js
@@ -1,5 +1,11 @@
const assert = require('assert');

module.exports = {
description: 'populates options.external with --global keys',
command: 'rollup main.js --format iife --globals mathematics:Math',
execute: true
command:
'rollup main.js --format iife --globals mathematics:Math,promises:Promise --external promises',
execute: true,
stderr(stderr) {
assert.strictEqual(stderr.indexOf('(!)'), -1);
}
};
2 changes: 2 additions & 0 deletions test/cli/samples/external-modules-auto-global/main.js
@@ -1,3 +1,5 @@
import { max } from 'mathematics';
import { resolve } from 'promises';

assert.equal( max( 1, 2, 3 ), 3 );
assert.ok( resolve().then );
9 changes: 7 additions & 2 deletions test/cli/samples/external-modules/_config.js
@@ -1,5 +1,10 @@
const assert = require('assert');

module.exports = {
description: 'allows external modules to be specified with --external=foo,bar,baz',
command: 'rollup main.js --format cjs --external path,util',
execute: true
command: 'rollup main.js --format cjs --external=path,util',
execute: true,
stderr(stderr) {
assert.strictEqual(stderr.indexOf('(!)'), -1);
}
};
2 changes: 1 addition & 1 deletion test/cli/samples/node-config-auto-prefix/_config.js
@@ -1,5 +1,5 @@
module.exports = {
description: 'uses config file installed from npm',
description: 'uses config file installed from npm, automatically adding a rollup-config- prefix',
command: 'rollup --config node:foo',
execute: true
};
10 changes: 10 additions & 0 deletions test/cli/samples/node-config-not-found/_config.js
@@ -0,0 +1,10 @@
const { assertStderrIncludes } = require('../../../utils.js');

module.exports = {
description: 'throws if a config in node_modules cannot be found',
command: 'rollup --config node:baz',
error: () => true,
stderr(stderr) {
assertStderrIncludes(stderr, '[!] Could not resolve config file node:baz');
}
};
11 changes: 11 additions & 0 deletions test/cli/samples/node-config-not-found/_expected.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.myBundle = factory();
}(this, function () { 'use strict';

var main = 42;

return main;

}));
1 change: 1 addition & 0 deletions test/cli/samples/node-config-not-found/main.js
@@ -0,0 +1 @@
assert.equal( ANSWER, 42 );
2 changes: 1 addition & 1 deletion test/cli/samples/node-config/_config.js
@@ -1,6 +1,6 @@
module.exports = {
description: 'uses config file installed from npm',
command: 'rollup --config node:foo',
command: 'rollup --config node:bar',
cwd: __dirname,
execute: true
};

0 comments on commit 3d86d24

Please sign in to comment.