Adding Unit test for File size!!! (#107)

* Added unit test for File Size
* Added convert-units to the npm modules in travis.yml
This commit is contained in:
melinerunen 2017-03-29 13:46:29 -03:00 committed by John Hobbs
parent 4cb311b319
commit 234d4088f6
3 changed files with 32 additions and 0 deletions

View File

@ -2,4 +2,5 @@ language: node_js
install:
- npm install -g mocha
- npm install chai jsonschema
- npm install convert-units
script: "mocha"

View File

@ -17,6 +17,7 @@
"homepage": "https://github.com/jmhobbs/cultofthepartyparrot.com#readme",
"devDependencies": {
"chai": "^3.5.0",
"convert-units": "^2.1.0",
"gulp": "^3.9.1",
"gulp-data": "^1.2.1",
"gulp-imagemin": "^3.1.1",

30
test/parrots_size.js Normal file
View File

@ -0,0 +1,30 @@
var fs = require('fs'),
assert = require('chai').assert,
convert = require('convert-units');
describe("parrots", function() {
it("in HD should weight less than 64KB", function() {
var parrot_hd_gifs = fs.readdirSync(__dirname + '/../parrots/hd');
parrot_hd_gifs.forEach(function(gif) {
var size = fs.statSync(__dirname + '/../parrots/hd/' + gif).size;
assert(size <= convert(64).from('KB').to('B'), gif + " is too big(" + convert(size).from('B').to('KB') + " KB)");
});
});
it("in SD should weight less than 64KB", function() {
var parrot_hd_gifs = fs.readdirSync(__dirname + '/../parrots');
parrot_hd_gifs.forEach(function(gif) {
var size = fs.statSync(__dirname + '/../parrots/' + gif).size;
assert(size <= convert(64).from('KB').to('B'), gif + " is too big(" + convert(size).from('B').to('KB') + " KB)");
});
});
});