Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
blond
committed
Sep 12, 2016
1 parent
f8d2674
commit 0cefe5d
Showing
4 changed files
with
75 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
'use strict'; | ||
|
||
const test = require('ava'); | ||
|
||
const normalizeArtifact = require('../../lib/normalize-artifact'); | ||
|
||
test('should throw error if dest is not specified', t => { | ||
t.throws(() => normalizeArtifact(), 'You should specify the dest for artifact.'); | ||
}); | ||
|
||
test('should throw error if include or patterns param is not specified', t => { | ||
t.throws( | ||
() => normalizeArtifact({ dest: 'dest-dir' }), | ||
'You should specify the includes or patterns parameters for artifact.' | ||
); | ||
}); | ||
|
||
test('should throw error if includes param is negative patterns', t => { | ||
t.throws( | ||
() => normalizeArtifact({ dest: 'dest-dir', includes: '!source-dir/**' }), | ||
'The includes parameter of artifact should not contains negative patterns.' | ||
); | ||
}); | ||
|
||
test('should throw error if includes has negative patterns', t => { | ||
t.throws( | ||
() => normalizeArtifact({ dest: 'dest-dir', includes: ['source-dir/file-1.txt', '!source-dir/file-2.txt'] }), | ||
'The includes parameter of artifact should not contains negative patterns.' | ||
); | ||
}); | ||
|
||
test('should throw error if patterns param is negative patterns', t => { | ||
t.throws( | ||
() => normalizeArtifact({ dest: 'dest-dir', patterns: '!source-dir/**' }), | ||
'The first pattern of artifact should not be is negative.' | ||
); | ||
}); | ||
|
||
test('should throw error if first pattern is negative glob', t => { | ||
t.throws( | ||
() => normalizeArtifact({ dest: 'dest-dir', patterns: ['!source-dir/**', 'source-dir/file-1.txt'] }), | ||
'The first pattern of artifact should not be is negative.' | ||
); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict'; | ||
|
||
// Immediately invoke all dependencies, | ||
// because of the `copy` module use `lazy-cache` (it can't work with `mock-fs`). | ||
process.env.UNLAZY = true; | ||
|
||
const fs = require('fs'); | ||
|
||
const test = require('ava'); | ||
const promisify = require('es6-promisify'); | ||
const mockFs = require('mock-fs'); | ||
|
||
const writeArtifact = promisify(require('../../lib/write-artifact')); | ||
const cwd = process.cwd(); | ||
|
||
test.afterEach(() => mockFs.restore()); | ||
|
||
test('should copy artifact by default', async t => { | ||
mockFs({ | ||
'source-dir': { | ||
'file-1.txt': 'Hi!', | ||
'file-2.txt': 'Hello!' | ||
} | ||
}); | ||
|
||
await writeArtifact({ dest: 'dest-dir', includes: ['source-dir/**'] }, { root: cwd }); | ||
|
||
const stats = fs.statSync('dest-dir'); | ||
|
||
t.true(stats.isDirectory()); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters