img-stats_test.js
2.96 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*global require:true, process:true, console: true*/
(function( exports ){
"use strict";
var img_stats = require('../lib/img-stats.js');
/*
======== A Handy Little Nodeunit Reference ========
https://github.com/caolan/nodeunit
Test methods:
test.expect(numAssertions)
test.done()
Test assertions:
test.ok(value, [message])
test.equal(actual, expected, [message])
test.notEqual(actual, expected, [message])
test.deepEqual(actual, expected, [message])
test.notDeepEqual(actual, expected, [message])
test.strictEqual(actual, expected, [message])
test.notStrictEqual(actual, expected, [message])
test.throws(block, [error], [message])
test.doesNotThrow(block, [error], [message])
test.ifError(value)
*/
exports['img-stats'] = {
setUp: function(done) {
// setup here
done();
},
'no args': function( test ) {
test.expect(1);
// tests here
test.throws( function(){
img_stats.stats();
}, Error , 'Needs a filename.');
test.done();
},
'cat.png async': function( test ){
test.expect(3);
img_stats.stats( process.cwd() + '/test/files/cat.png' , function( data ){
test.equal( data.width , 100 , "Width should be 100" );
test.equal( data.height , 100 , "Height should be 100" );
test.equal( data.type , 'PNG' , "Cat should be a png" );
test.done();
});
},
'cat.png Sync': function( test ){
test.expect(3);
var data = img_stats.statsSync( process.cwd() + '/test/files/cat.png' );
test.equal( data.width , 100 , "Width should be 100" );
test.equal( data.height , 100 , "Height should be 100" );
test.equal( data.type , 'PNG' , "Cat should be a png" );
test.done();
},
'bear.svg async': function( test ){
test.expect(3);
img_stats.stats( process.cwd() + '/test/files/bear.svg' , function( data ){
test.equal( data.width , "100" , "Bear width should be 100" );
test.equal( data.height , "62.905" , "Bear height should be 100" );
test.equal( data.type , "SVG" , "Bear should be an SVG" );
test.done();
});
},
'bear.svg sync': function( test ){
test.expect(3);
var data = img_stats.statsSync( process.cwd() + '/test/files/bear.svg' );
test.equal( data.width , "100" , "Bear width should be 100" );
test.equal( data.height , "62.905" , "Bear height should be 100" );
test.equal( data.type , "SVG" , "Bear should be an SVG" );
test.done();
},
'bear-2.svg sync': function( test ){
test.expect(3);
var data = img_stats.statsSync( process.cwd() + '/test/files/bear-2.svg' );
test.equal( data.width , "100" , "Bear width should be 100" );
test.equal( data.height , "62.905" , "Bear height should be 100" );
test.equal( data.type , "SVG" , "Bear should be an SVG" );
test.done();
}
};
}(typeof exports === 'object' && exports || this));