Skip to content

Commit

Permalink
test: rewrite ignore artifacts dir when zipping test
Browse files Browse the repository at this point in the history
  • Loading branch information
eight04 committed Jan 17, 2017
1 parent fc02fc2 commit 452e382
Showing 1 changed file with 14 additions and 23 deletions.
37 changes: 14 additions & 23 deletions tests/unit/test-cmd/test.build.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
fixturePath,
makeSureItFails,
ZipFile,
copyDirAsPromised,
} from '../helpers';
import {
basicManifest,
Expand Down Expand Up @@ -53,29 +52,21 @@ describe('build', () => {
);
});

it('ignore artifacts dir if included by source dir when zipping', () => {
const zipFile = new ZipFile();
return withTempDir(
(tmpDir) =>
copyDirAsPromised(
fixturePath('minimal-web-ext-with-artifacts'),
tmpDir.path()
)
.then(() =>
build({
sourceDir: tmpDir.path(),
artifactsDir: path.join(tmpDir.path(), 'web-ext-artifacts'),
})
)
.then((buildResult) => buildResult.extensionPath)
.then((extensionPath) => zipFile.open(extensionPath))
.then(() => zipFile.extractFilenames())
.then((fileNames) => {
fileNames.sort();
assert.deepEqual(fileNames,
['background-script.js', 'manifest.json']);
})
it('ensure artifacts dir is excluded from zipping', () => {
const packageCreator = sinon.spy(
() => ({extensionPath: 'extension/path'})
);
return build({
sourceDir: '/src',
artifactsDir: 'artifacts',
}, {packageCreator}).then(() => {
assert(packageCreator.calledOnce);
assert.isObject(packageCreator.firstCall.args[0]);
assert.property(packageCreator.firstCall.args[0], 'fileFilter');
const fileFilter = packageCreator.firstCall.args[0].fileFilter;
assert.isFalse(fileFilter.wantFile('/src/artifacts'));
assert.isFalse(fileFilter.wantFile('/src/artifacts/something'));
});
});

it('ignore files', () => {
Expand Down

0 comments on commit 452e382

Please sign in to comment.