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 84 85 86 87 88 89
|
Description: Modify test scripts to use available files only
Also, the current version of read-chunk seems to be incompatible with these
test scripts, so we simply replace it with fs.
Author: Julian Gilbey <jdg@debian.org>
Forwarded: not-needed
Last-Update: 2022-12-24
--- a/is-eot/test.js
+++ b/is-eot/test.js
@@ -1,16 +1,17 @@
'use strict';
var assert = require('assert');
-var readChunk = require('read-chunk');
+var fs = require('fs');
var isEot = require('./');
function check(filename) {
- return isEot(readChunk.sync(filename, 0, 36));
+ return isEot(fs.readFileSync(filename));
}
it('should detect EOT 0x20002 from Buffer', function () {
assert(check('fontawesome-webfont.eot'));
});
-it('should detect EOT 0x20001 from Buffer', function () {
- assert(check('fonteditor.eot'));
+it('should be false when detect other type file', function () {
+ assert(!check('fontawesome-webfont.woff'));
+ assert(!check('fontawesome-webfont.ttf'));
});
--- a/is-ttf/test.js
+++ b/is-ttf/test.js
@@ -29,6 +29,8 @@
it('should be false when detect other type file', function () {
assert(!isTtf(fs.readFileSync('index.js')));
assert(!isTtf(fs.readFileSync('package.json')));
+ assert(!isTtf(fs.readFileSync('pixel.woff')));
+ assert(!isTtf(fs.readFileSync('pixel.eot')));
});
it('should detect TTF by opts.tables', function () {
--- a/is-woff/test.js
+++ b/is-woff/test.js
@@ -1,20 +1,16 @@
'use strict';
var assert = require('assert');
-var readChunk = require('read-chunk');
+var fs = require('fs');
var isWoff = require('./');
function check(filename) {
- return isWoff(readChunk.sync(filename, 0, 8));
+ return isWoff(fs.readFileSync(filename));
}
it('should detect WOFF from Buffer', function () {
assert(check('fixture/fontawesome-webfont.woff'));
});
-it('should detect WOFF(OTTO) from Buffer', function () {
- assert(check('fixture/young-heart.woff'));
-});
-
it('should not detect WOFF from WOFF2 Buffer', function () {
assert(!check('fixture/fontawesome-webfont.woff2'));
});
--- a/is-woff2/test/test.js
+++ b/is-woff2/test/test.js
@@ -1,16 +1,13 @@
'use strict';
var path = require('path');
var assert = require('assert');
-var readChunk = require('read-chunk');
+var fs = require('fs');
var isWoff2 = require('../');
it('should detect woff2 files', function () {
- var woff2 = readChunk.sync(path.join(__dirname, 'fixture/fixture.woff2'), 0, 8);
+ var woff2 = fs.readFileSync(path.join(__dirname, 'fixture/fixture.woff2'));
assert(isWoff2(woff2));
- var woff = readChunk.sync(path.join(__dirname, 'fixture/fixture.woff'), 0, 8);
+ var woff = fs.readFileSync(path.join(__dirname, 'fixture/fixture.woff'));
assert(!isWoff2(woff));
-
- var png = readChunk.sync(path.join(__dirname, 'fixture/fixture.png'), 0, 8);
- assert(!isWoff2(png));
});
|