Skip to content
This repository was archived by the owner on Aug 4, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make tests compatible with rollup1.0
  • Loading branch information
lukastaegert committed Dec 10, 2018
commit b37a7f35c075644f656316ed68580ad9ced0dd28
58 changes: 20 additions & 38 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 24 additions & 9 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,20 @@ test('Platform path.resolve(\'file-with.ext\') aliasing', (t) => {
t.is(resolved, path.resolve('./test/files/folder/hipster.jsx'));
});

const getModuleIdsFromBundle = (bundle) => {
if (bundle.modules) {
return Promise.resolve(bundle.modules.map(module => module.id));
}
return bundle.generate({ format: 'esm' }).then((generated) => {
if (generated.output) {
return generated.output.length ? generated.output : Object.keys(generated.output)
.map(chunkName => generated.output[chunkName]);
}
return [generated];
}).then(chunks => chunks
.reduce((moduleIds, chunk) => moduleIds.concat(Object.keys(chunk.modules)), []));
};

// Tests in Rollup
test(t => rollup({
input: './test/files/index.js',
Expand All @@ -173,12 +187,13 @@ test(t => rollup({
numberFolder: './folder',
'./numberFolder': './folder',
})],
}).then((stats) => {
const fileNames = stats.modules.map(({ id }) => id).sort();
t.is(fileNames.length, 5);
t.is(fileNames[0].endsWith(path.normalize('/files/aliasMe.js')), true);
t.is(fileNames[1].endsWith(path.normalize('/files/folder/anotherNumber.js')), true);
t.is(fileNames[2].endsWith(path.normalize('/files/index.js')), true);
t.is(fileNames[3].endsWith(path.normalize('/files/localAliasMe.js')), true);
t.is(fileNames[4].endsWith(path.normalize('/files/nonAliased.js')), true);
}));
}).then(getModuleIdsFromBundle)
.then((moduleIds) => {
moduleIds.sort();
t.is(moduleIds.length, 5);
t.is(moduleIds[0].endsWith(path.normalize('/files/aliasMe.js')), true);
t.is(moduleIds[1].endsWith(path.normalize('/files/folder/anotherNumber.js')), true);
t.is(moduleIds[2].endsWith(path.normalize('/files/index.js')), true);
t.is(moduleIds[3].endsWith(path.normalize('/files/localAliasMe.js')), true);
t.is(moduleIds[4].endsWith(path.normalize('/files/nonAliased.js')), true);
}));