Skip to content
Snippets Groups Projects
Commit 1c084937 authored by tatsy's avatar tatsy
Browse files

Add unit tests for improve the coverage.

parent 644bdc4a
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@ lint:
publish:
webpack ./
uglifyjs dist/markdown-it-imsize.js > dist/markdown-it-imsize.min.js
bower register markdown-it-imsize https://github.com/tatsy/markdown-it-imsize.git
test: lint
mocha
......
......@@ -18,6 +18,6 @@
"test",
"helpers",
"Makefile",
"index*"
"lib"
]
}
......@@ -28,7 +28,7 @@ function lookup(buffer, filepath) {
}
function asyncFileToBuffer(filepath, callback) {
fs.oepn(filepath, 'r', function(err0, descriptor) {
fs.open(filepath, 'r', function(err0, descriptor) {
if (err0) {
return callback(err0);
}
......
......@@ -29,6 +29,7 @@
"markdown-it": "^3.0.4",
"markdown-it-testgen": "^0.1.4",
"mocha": "^2.1.0",
"should": "^5.0.0",
"uglify-js": "^2.4.16",
"webpack": "^1.5.3"
}
......
......@@ -3,6 +3,7 @@
var assert = require('assert');
var path = require('path');
var generate = require('markdown-it-testgen');
var should = require('should');
describe('markdown-it-imsize', function() {
var md = require('markdown-it')({
......@@ -23,9 +24,10 @@ describe('markdown-it-imsize (autofill)', function() {
});
describe('image size detector', function() {
it('image size detector', function(done) {
var imsize = require('../lib/imsize');
var types = require('../lib/imsize/types');
it('image size detector', function(done) {
types.forEach(function(type) {
var dim = imsize('./test/img/lena.' + type);
assert.equal(dim.width, 128);
......@@ -33,4 +35,18 @@ describe('image size detector', function() {
});
done();
});
it('imsize detector anync', function() {
types.forEach(function(type) {
imsize('./test/img/lena.' + type, function(err, dim) {
assert.equal(dim.width, 128);
assert.equal(dim.height, 128);
});
});
});
it('invalid operation', function(done) {
(function() { imsize('./test/img/lena.svg') }).should.throw();
done();
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment