-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.js
34 lines (27 loc) · 906 Bytes
/
test.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
var fs = require('fs');
var path = require('path');
var folders = [ 'xml', 'txt', 'multipage' ];
var nexa = 'Nexa Light-32.fnt'
var paths = folders.map(function(dir) {
return path.join(__dirname, 'test-files', dir, nexa);
});
var test = require('tape');
var bmfont = require('./');
var expected = require('./test-files/txt/Test.json');
test('should parse fonts', function(t) {
paths.forEach(function(p) {
var f = fs.readFileSync(p);
var result = bmfont(f);
t.equal(result.info.face, 'Nexa Light', 'face parsed');
t.equal(result.chars.length, 96, 'chars parsed');
t.equal(result.kernings.length, 487, 'kernings parsed');
});
t.end();
});
test('should match expected', function(t) {
var p = path.join(__dirname, 'test-files', 'txt', nexa);
var f = fs.readFileSync(p);
var result = bmfont(f);
t.deepEqual(result, expected, 'matches JSON');
t.end();
});