forked from jmhobbs/cultofthepartyparrot.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsize.js
45 lines (37 loc) · 1.78 KB
/
size.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
var fs = require('fs'),
assert = require('chai').assert,
convert = require('convert-units'),
imageSize = require('image-size');
['parrots', 'guests', 'flags'].forEach(function(type) {
describe(type + " gifs", function() {
it("in HD should weigh less than 128KB", function() {
let gifs = fs.readdirSync(__dirname + '/../' + type + '/hd');
gifs.forEach(function(gif) {
let size = fs.statSync(__dirname + '/../' + type + '/hd/' + gif).size;
assert(size <= convert(128).from('KB').to('B'), gif + " is too big(" + convert(size).from('B').to('KB') + " KB)");
});
});
it("in SD should weigh less than 128KB", function() {
let gifs = fs.readdirSync(__dirname + '/../' + type);
gifs.forEach(function(gif) {
var size = fs.statSync(__dirname + '/../' + type + '/' + gif).size;
assert(size <= convert(128).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 () {
let hd_gifs = fs.readdirSync(__dirname + '/../' + type + '/hd'),
gifs = fs.readdirSync(__dirname + '/../' + type);
gifs.forEach(function(gif) {
if(gif == "hd") { return; } // Skip the HD directory
let dimensions = imageSize(__dirname + '/../' + type + '/' + gif);
assert(dimensions.width <= 128, gif + " is wider than 128px");
assert(dimensions.height <= 128, gif + " is taller than 128px");
});
hd_gifs.forEach(function(gif) {
let dimensions = imageSize(__dirname + '/../' + type + '/hd/' + gif);
assert(dimensions.width <= 128, gif + " is wider than 128px");
assert(dimensions.height <= 128, gif + " is taller than 128px");
});
});
});
});