Skip to content

Commit 462fee5

Browse files
committed
Breaking: Throw when dest()/symlink() is called with invalid folder argument & unskip tests
1 parent 710122a commit 462fee5

File tree

4 files changed

+37
-27
lines changed

4 files changed

+37
-27
lines changed

lib/dest/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ var folderConfig = {
1717
};
1818

1919
function dest(outFolder, opt) {
20+
if (!outFolder) {
21+
throw new Error('Invalid dest() folder argument.' +
22+
' Please specify a non-empty string or a function.');
23+
}
24+
2025
var optResolver = createResolver(config, opt);
2126
var folderResolver = createResolver(folderConfig, { outFolder: outFolder });
2227

lib/symlink/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ var folderConfig = {
1616
};
1717

1818
function symlink(outFolder, opt) {
19+
if (!outFolder) {
20+
throw new Error('Invalid symlink() folder argument.' +
21+
' Please specify a non-empty string or a function.');
22+
}
23+
1924
var optResolver = createResolver(config, opt);
2025
var folderResolver = createResolver(folderConfig, { outFolder: outFolder });
2126

test/dest.js

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,28 +59,22 @@ describe('.dest()', function() {
5959
beforeEach(clean);
6060
afterEach(clean);
6161

62-
// TODO: make this work correctly
63-
it.skip('throws on invalid folder (empty)', function(done) {
64-
var stream;
65-
try {
66-
stream = vfs.dest();
67-
} catch (err) {
68-
expect(err).toExist();
69-
expect(stream).toNotExist();
70-
done();
62+
it('throws on no folder argument', function(done) {
63+
function noFolder() {
64+
vfs.dest();
7165
}
66+
67+
expect(noFolder).toThrow('Invalid dest() folder argument. Please specify a non-empty string or a function.');
68+
done();
7269
});
7370

74-
// TODO: make this work correctly
75-
it.skip('throws on invalid folder (empty string)', function(done) {
76-
var stream;
77-
try {
78-
stream = vfs.dest('');
79-
} catch (err) {
80-
expect(err).toExist();
81-
expect(stream).toNotExist();
82-
done();
71+
it('throws on empty string folder argument', function(done) {
72+
function emptyFolder() {
73+
vfs.dest('');
8374
}
75+
76+
expect(emptyFolder).toThrow('Invalid dest() folder argument. Please specify a non-empty string or a function.');
77+
done();
8478
});
8579

8680
it('accepts the sourcemap option as true', function(done) {

test/symlink.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,22 @@ describe('symlink stream', function() {
4040
beforeEach(clean);
4141
afterEach(clean);
4242

43-
// TODO: make this work correctly
44-
it.skip('throws on invalid folder', function(done) {
45-
var stream;
46-
try {
47-
stream = vfs.symlink();
48-
} catch (err) {
49-
expect(err).toExist();
50-
expect(stream).toNotExist();
51-
done();
43+
it('throws on no folder argument', function(done) {
44+
function noFolder() {
45+
vfs.symlink();
5246
}
47+
48+
expect(noFolder).toThrow('Invalid symlink() folder argument. Please specify a non-empty string or a function.');
49+
done();
50+
});
51+
52+
it('throws on empty string folder argument', function(done) {
53+
function emptyFolder() {
54+
vfs.symlink('');
55+
}
56+
57+
expect(emptyFolder).toThrow('Invalid symlink() folder argument. Please specify a non-empty string or a function.');
58+
done();
5359
});
5460

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

0 commit comments

Comments
 (0)