Browse Source

new parseFont() tests

v1.x
Tj Holowaychuk 14 years ago
parent
commit
3ecdb5d6b6
  1. 2
      lib/canvas.js
  2. 13
      test/canvas.test.js

2
lib/canvas.js

@ -77,7 +77,7 @@ exports.parseFont = function(str){
if (cache[str]) return cache[str];
var obj = {}
, captures = /^ *(\d+)(px) *(Arial)/.exec(str);
obj.size = captures[1];
obj.size = parseInt(captures[1], 10);
obj.unit = captures[2];
obj.family = captures[3];
return cache[str] = obj;

13
test/canvas.test.js

@ -60,9 +60,16 @@ module.exports = {
},
'test .parseFont()': function(assert){
assert.eql(
{ size: '20', unit: 'px', family: 'Arial' }
, Canvas.parseFont('20px Arial'));
var tests = [
'20px Arial'
, { size: 20, unit: 'px', family: 'Arial' }
];
for (var i = 0, len = tests.length; i < len; ++i) {
var str = tests[i++]
, obj = tests[i];
assert.eql(obj, Canvas.parseFont(str));
}
},
'test color serialization': function(){

Loading…
Cancel
Save