Skip to content
This repository was archived by the owner on Oct 10, 2022. It is now read-only.

Commit a8d8bfc

Browse files
committed
Add new test to src/deploy/util.js
1 parent 3d40ef4 commit a8d8bfc

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

src/deploy/util.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ async function waitForDeploy(api, deployId, siteId, timeout) {
109109
}
110110

111111
// Transform the fileShaMap and fnShaMap into a generic shaMap that file-uploader.js can use
112-
exports.getUploadList = getUploadList
113-
function getUploadList(required, shaMap) {
112+
exports.getUploadList = function(required, shaMap) {
114113
if (!required || !shaMap) return []
115114
return flatten(required.map(sha => shaMap[sha]))
116115
}

src/deploy/util.test.js

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const test = require('ava')
2-
const { normalizePath } = require('./util')
2+
const { normalizePath, defaultFilter } = require('./util')
33

44
test('normalizes relative file paths', t => {
55
const cases = [
@@ -22,3 +22,44 @@ test('normalizes relative file paths', t => {
2222
t.is(normalizePath(c.input), c.expect, c.msg)
2323
})
2424
})
25+
26+
test('normalizePath should throw the error if name is invalid', t => {
27+
t.throws(() => normalizePath('invalid name#'))
28+
t.throws(() => normalizePath('invalid name?'))
29+
t.throws(() => normalizePath('??'))
30+
t.throws(() => normalizePath('#'))
31+
})
32+
33+
test('pass empty name to defaultFilter', t => {
34+
const cases = [
35+
{
36+
input: null,
37+
expect: false
38+
},
39+
{
40+
input: undefined,
41+
expect: false
42+
},
43+
{
44+
input: 'foo/bar/baz.js',
45+
expect: true
46+
},
47+
{
48+
input: 'directory/node_modules',
49+
expect: false
50+
},
51+
{
52+
input: 'directory/.gitignore',
53+
expect: false
54+
},
55+
{
56+
input: 'directory/.well-known',
57+
expect: true
58+
},
59+
{
60+
input: '__MACOSX',
61+
expect: true
62+
}
63+
]
64+
cases.forEach(c => t.is(defaultFilter(c.input), c.expect))
65+
})

0 commit comments

Comments
 (0)