Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
edi9999 committed Mar 28, 2017
1 parent 977320f commit 5fdeee2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"chai": "^1.9.1",
"eslint": "^2.13.1",
"mocha": "^2.4.5",
"png-js": "^0.1.1",
"image-parser": "^1.2.4",
"rollup": "^0.34.13",
"uglify-js": "^2.7.3"
}
Expand Down
32 changes: 15 additions & 17 deletions test/qrcode.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,40 @@
var expect = require('chai').expect;
var fs = require('fs');
var PNG = require('png-js');
var QrCode = require('../dist/index.js');
var ImageParser = require("image-parser");

it('should work with basic image', function(done) {

var c = fs.readFileSync(__dirname + '/image.png');
var p = new PNG(c);

p.decode(function(data) {

var img = new ImageParser(c);
img.parse((err) => {
if (err) {
return done(err);
}
var qr = new QrCode();
qr.callback = function(result) {

expect(result).to.equal('Test');
done();
};
qr.decode(p, data);
qr.decode({width: img.width(), height: img.height()}, img._imgBuffer);
});
});

it('should work with imageData format', function(done) {

var c = fs.readFileSync(__dirname + '/image.png');
var p = new PNG(c);

p.decode(function(data) {

var img = new ImageParser(c);
img.parse((err) => {
if (err) {
return done(err);
}
var qr = new QrCode();
qr.callback = function(result) {

expect(result).to.equal('Test');
done();
};
qr.decode({
height: p.height,
width: p.width,
data: data
height: img.height(),
width: img.width(),
data: img._imgBuffer
});
});
});

0 comments on commit 5fdeee2

Please sign in to comment.