Browse Source

expresso -> mocha

v1.x
Tj Holowaychuk 13 years ago
parent
commit
078a8572d3
  1. 4
      Makefile
  2. 3
      package.json
  3. 11
      test/canvas.test.js
  4. 30
      test/image.test.js

4
Makefile

@ -5,7 +5,9 @@ $(ADDON): src/*.cc
node-waf configure build
test: $(ADDON)
@./node_modules/.bin/expresso \
@./node_modules/.bin/mocha \
--ui exports \
--require should \
test/*.test.js
test-server: $(ADDON)

3
package.json

@ -10,8 +10,9 @@
}
, "devDependencies": {
"express": "2.3.7"
, "expresso": "0.7.6"
, "jade": "0.11.0"
, "mocha": "*"
, "should": "*"
}
, "engines": { "node": ">= 0.4.0 && < 0.7.0" }
, "main": "./lib/canvas.js"

11
test/canvas.test.js

@ -16,11 +16,11 @@ console.log(' cairo: %s', Canvas.cairoVersion);
module.exports = {
'test .version': function(){
assert.match(Canvas.version, /^\d+\.\d+\.\d+$/);
Canvas.version.should.match(/^\d+\.\d+\.\d+$/);
},
'test .cairoVersion': function(){
assert.match(Canvas.cairoVersion, /^\d+\.\d+\.\d+$/);
Canvas.cairoVersion.should.match(/^\d+\.\d+\.\d+$/);
},
'test .parseFont()': function(){
@ -72,13 +72,10 @@ module.exports = {
for (var i = 0, len = tests.length; i < len; ++i) {
var str = tests[i++]
, obj = tests[i]
, got = parseFont(str);
, actual = parseFont(str);
if (!obj.style) obj.style = 'normal';
if (!obj.weight) obj.weight = 'normal';
assert.eql(obj, got, ''
+ '\n from: ' + sys.inspect(str)
+ '\n got:\n' + sys.inspect(got)
+ '\n expected:\n' + sys.inspect(obj));
actual.should.eql(obj);
}
},

30
test/image.test.js

@ -14,7 +14,7 @@ module.exports = {
assert.ok(Image instanceof Function);
},
'test Image#onload': function(beforeExit){
'test Image#onload': function(){
var img = new Image
, n = 0;
@ -27,16 +27,14 @@ module.exports = {
img.src = png;
assert.equal(img.src, png);
beforeExit(function(){
assert.equal(img.src, png);
assert.strictEqual(true, img.complete);
assert.strictEqual(320, img.width);
assert.strictEqual(320, img.height);
assert.equal(1, n);
});
assert.equal(img.src, png);
assert.strictEqual(true, img.complete);
assert.strictEqual(320, img.width);
assert.strictEqual(320, img.height);
assert.equal(1, n);
},
'test Image#onerror': function(beforeExit){
'test Image#onerror': function(){
var img = new Image
, error
, n = 0;
@ -59,14 +57,12 @@ module.exports = {
assert.equal(img.src, png + 's');
beforeExit(function(){
assert.ok(error instanceof Error, 'did not invoke onerror() with error');
assert.strictEqual(false, img.complete);
assert.equal(1, n);
});
assert.ok(error instanceof Error, 'did not invoke onerror() with error');
assert.strictEqual(false, img.complete);
assert.equal(1, n);
},
'test Image#{width,height}': function(beforeExit){
'test Image#{width,height}': function(){
var img = new Image
, n = 0;
@ -79,8 +75,6 @@ module.exports = {
};
img.src = png;
beforeExit(function(){
assert.equal(1, n);
});
assert.equal(1, n);
}
};
Loading…
Cancel
Save