Test parrot dimensions.
This commit is contained in:
parent
1821616123
commit
d6c7d6f186
|
@ -3,4 +3,5 @@ install:
|
|||
- npm install -g mocha@"^3.5.3"
|
||||
- npm install chai jsonschema
|
||||
- npm install convert-units
|
||||
- npm install image-size
|
||||
script: "mocha"
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
"gulp-mustache": "^2.3.0",
|
||||
"gulp-rev": "^7.1.2",
|
||||
"gulp-uglifycss": "^1.0.6",
|
||||
"image-size": "^0.6.1",
|
||||
"jsonschema": "1.1.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
var fs = require('fs'),
|
||||
assert = require('chai').assert,
|
||||
convert = require('convert-units');
|
||||
var fs = require('fs'),
|
||||
assert = require('chai').assert,
|
||||
convert = require('convert-units'),
|
||||
imageSize = require('image-size');
|
||||
|
||||
|
||||
describe("parrots", function() {
|
||||
|
@ -18,13 +19,31 @@ describe("parrots", function() {
|
|||
|
||||
it("in SD should weight less than 64KB", function() {
|
||||
|
||||
var parrot_hd_gifs = fs.readdirSync(__dirname + '/../parrots');
|
||||
parrot_hd_gifs.forEach(function(gif) {
|
||||
var parrot_gifs = fs.readdirSync(__dirname + '/../parrots');
|
||||
parrot_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)");
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
it("should never be wider or taller than 128px", function () {
|
||||
var parrot_hd_gifs = fs.readdirSync(__dirname + '/../parrots/hd'),
|
||||
parrot_gifs = fs.readdirSync(__dirname + '/../parrots');
|
||||
|
||||
parrot_gifs.forEach(function(gif) {
|
||||
if(gif == "hd") { return; } // Skip the HD directory
|
||||
var dimensions = imageSize(__dirname + '/../parrots/' + gif);
|
||||
assert(dimensions.width <= 128, gif + " is wider than 128px");
|
||||
assert(dimensions.height <= 128, gif + " is taller than 128px");
|
||||
});
|
||||
|
||||
parrot_hd_gifs.forEach(function(gif) {
|
||||
var dimensions = imageSize(__dirname + '/../parrots/hd/' + gif);
|
||||
assert(dimensions.width <= 128, gif + " is wider than 128px");
|
||||
assert(dimensions.height <= 128, gif + " is taller than 128px");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue