Skip to content

Commit

Permalink
Breaking: Throw when dest()/symlink() is called with invalid fold…
Browse files Browse the repository at this point in the history
…er argument & unskip tests
  • Loading branch information
phated committed Dec 5, 2017
1 parent 710122a commit 462fee5
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 27 deletions.
5 changes: 5 additions & 0 deletions lib/dest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ var folderConfig = {
};

function dest(outFolder, opt) {
if (!outFolder) {
throw new Error('Invalid dest() folder argument.' +
' Please specify a non-empty string or a function.');
}

var optResolver = createResolver(config, opt);
var folderResolver = createResolver(folderConfig, { outFolder: outFolder });

Expand Down
5 changes: 5 additions & 0 deletions lib/symlink/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ var folderConfig = {
};

function symlink(outFolder, opt) {
if (!outFolder) {
throw new Error('Invalid symlink() folder argument.' +
' Please specify a non-empty string or a function.');
}

var optResolver = createResolver(config, opt);
var folderResolver = createResolver(folderConfig, { outFolder: outFolder });

Expand Down
30 changes: 12 additions & 18 deletions test/dest.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,22 @@ describe('.dest()', function() {
beforeEach(clean);
afterEach(clean);

// TODO: make this work correctly
it.skip('throws on invalid folder (empty)', function(done) {
var stream;
try {
stream = vfs.dest();
} catch (err) {
expect(err).toExist();
expect(stream).toNotExist();
done();
it('throws on no folder argument', function(done) {
function noFolder() {
vfs.dest();
}

expect(noFolder).toThrow('Invalid dest() folder argument. Please specify a non-empty string or a function.');
done();
});

// TODO: make this work correctly
it.skip('throws on invalid folder (empty string)', function(done) {
var stream;
try {
stream = vfs.dest('');
} catch (err) {
expect(err).toExist();
expect(stream).toNotExist();
done();
it('throws on empty string folder argument', function(done) {
function emptyFolder() {
vfs.dest('');
}

expect(emptyFolder).toThrow('Invalid dest() folder argument. Please specify a non-empty string or a function.');
done();
});

it('accepts the sourcemap option as true', function(done) {
Expand Down
24 changes: 15 additions & 9 deletions test/symlink.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,22 @@ describe('symlink stream', function() {
beforeEach(clean);
afterEach(clean);

// TODO: make this work correctly
it.skip('throws on invalid folder', function(done) {
var stream;
try {
stream = vfs.symlink();
} catch (err) {
expect(err).toExist();
expect(stream).toNotExist();
done();
it('throws on no folder argument', function(done) {
function noFolder() {
vfs.symlink();
}

expect(noFolder).toThrow('Invalid symlink() folder argument. Please specify a non-empty string or a function.');
done();
});

it('throws on empty string folder argument', function(done) {
function emptyFolder() {
vfs.symlink('');
}

expect(emptyFolder).toThrow('Invalid symlink() folder argument. Please specify a non-empty string or a function.');
done();
});

it('passes through writes with cwd', function(done) {
Expand Down

1 comment on commit 462fee5

@phated
Copy link
Member Author

@phated phated commented on 462fee5 Dec 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erikkemperman I'm not sure if we needed this since our options logic would error upon the first invalid folder during prepare but I wanted to make these tests pass instead of remove them because they were supposed to be working a LONG time ago (but they were false-positives).

Please sign in to comment.