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

Commit

Permalink
Add new test to src/deploy/util.js
Browse files Browse the repository at this point in the history
  • Loading branch information
polemius committed Sep 19, 2019
1 parent 3d40ef4 commit a8d8bfc
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/deploy/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ async function waitForDeploy(api, deployId, siteId, timeout) {
}

// Transform the fileShaMap and fnShaMap into a generic shaMap that file-uploader.js can use
exports.getUploadList = getUploadList
function getUploadList(required, shaMap) {
exports.getUploadList = function(required, shaMap) {
if (!required || !shaMap) return []
return flatten(required.map(sha => shaMap[sha]))
}
Expand Down
43 changes: 42 additions & 1 deletion src/deploy/util.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const test = require('ava')
const { normalizePath } = require('./util')
const { normalizePath, defaultFilter } = require('./util')

test('normalizes relative file paths', t => {
const cases = [
Expand All @@ -22,3 +22,44 @@ test('normalizes relative file paths', t => {
t.is(normalizePath(c.input), c.expect, c.msg)
})
})

test('normalizePath should throw the error if name is invalid', t => {
t.throws(() => normalizePath('invalid name#'))
t.throws(() => normalizePath('invalid name?'))
t.throws(() => normalizePath('??'))
t.throws(() => normalizePath('#'))
})

test('pass empty name to defaultFilter', t => {
const cases = [
{
input: null,
expect: false
},
{
input: undefined,
expect: false
},
{
input: 'foo/bar/baz.js',
expect: true
},
{
input: 'directory/node_modules',
expect: false
},
{
input: 'directory/.gitignore',
expect: false
},
{
input: 'directory/.well-known',
expect: true
},
{
input: '__MACOSX',
expect: true
}
]
cases.forEach(c => t.is(defaultFilter(c.input), c.expect))
})

0 comments on commit a8d8bfc

Please sign in to comment.