create separate function for path checking

This commit is contained in:
Brian Gough
2017-03-21 11:29:37 +00:00
parent 8803762081
commit 021d848819
4 changed files with 45 additions and 20 deletions

View File

@@ -157,6 +157,19 @@ describe "ResourceWriter", ->
.calledWith(new Error("resource path is outside root directory"))
.should.equal true
describe "checkPath", ->
describe "with a valid path", ->
beforeEach ->
@ResourceWriter.checkPath("foo", "bar", @callback)
it "should return the joined path", ->
@callback.calledWith(null, "foo/bar")
.should.equal true
describe "with an invalid path", ->
beforeEach ->
@ResourceWriter.checkPath("foo", "baz/../../bar", @callback)
it "should return an error", ->
@callback.calledWith(new Error("resource path is outside root directory"))
.should.equal true