-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added unit-tests around chunked-download-validators
- Loading branch information
1 parent
c700010
commit bba7741
Showing
1 changed file
with
59 additions
and
0 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,59 @@ | ||
/* global describe, it */ | ||
var should = require('should'), | ||
validators = require.main.require('libs/validators/chunked-download-validators.js'); | ||
|
||
describe("chunked-download-validators.js", function () { | ||
describe("#valid", function () { | ||
it('should return the signifier of a valid call', function() { | ||
var valid = validators.valid; | ||
should.exist(valid); | ||
valid.should.be.a.String; | ||
valid.should.equal("valid"); | ||
}); | ||
}); | ||
|
||
describe("#validateDownloadRequest", function() { | ||
it('should return the signifier of a valid call for a valid downloadRequest', function() { | ||
var valid = validators.validateDownloadRequest({ | ||
path: "/i/am/a/path/to/a/destination" | ||
}); | ||
should.exist(valid); | ||
valid.should.be.a.String; | ||
valid.should.equal("valid"); | ||
}); | ||
|
||
it('should NOT return the signifier of a valid call when passed a non-object value', function() { | ||
var valid = validators.validateDownloadRequest(null); | ||
should.exist(valid); | ||
valid.should.be.a.String.and.equal("Download request object was not recieved, or is not an object."); | ||
valid = validators.validateDownloadRequest(undefined); | ||
should.exist(valid); | ||
valid.should.be.a.String.and.equal("Download request object was not recieved, or is not an object."); | ||
valid = validators.validateDownloadRequest(NaN); | ||
should.exist(valid); | ||
valid.should.be.a.String.and.equal("Download request object was not recieved, or is not an object."); | ||
valid = validators.validateDownloadRequest(0); | ||
should.exist(valid); | ||
valid.should.be.a.String.and.equal("Download request object was not recieved, or is not an object."); | ||
valid = validators.validateDownloadRequest(""); | ||
should.exist(valid); | ||
valid.should.be.a.String.and.equal("Download request object was not recieved, or is not an object."); | ||
valid = validators.validateDownloadRequest(true); | ||
should.exist(valid); | ||
valid.should.be.a.String.and.equal("Download request object was not recieved, or is not an object."); | ||
}); | ||
|
||
it('should NOT return the signifier of a valid call when passed an object with incorrectly typed, or missing parameters', function() { | ||
var valid = validators.validateDownloadRequest({ | ||
}); | ||
should.exist(valid); | ||
valid.should.be.a.String.and.equal("Download path missing or it is not a string."); | ||
|
||
valid = validators.validateDownloadRequest({ | ||
path: true | ||
}); | ||
should.exist(valid); | ||
valid.should.be.a.String.and.equal("Download path missing or it is not a string."); | ||
}); | ||
}); | ||
}); |