konva/test/import-test.js

27 lines
638 B
JavaScript
Raw Normal View History

2019-02-27 21:06:04 +08:00
function equal(val1, val2, message) {
if (val1 !== val2) {
throw new Error('Not passed: ' + message);
}
}
// try to import only core
2019-02-28 06:30:47 +08:00
let Konva = require('../lib/Core');
2019-02-27 21:06:04 +08:00
// no external shapes
equal(Konva.Rect, undefined, 'no external shapes');
let Rect = require('../lib/shapes/Rect').Rect;
equal(Rect !== undefined, true, 'Rect is defined');
2019-03-07 11:19:32 +08:00
equal(Konva.Rect, Rect, 'Rect is injected');
2019-02-27 21:06:04 +08:00
// now import from package.json
2019-02-28 06:30:47 +08:00
let NewKonva = require('../');
2019-02-27 21:06:04 +08:00
equal(NewKonva.Rect, Rect, 'Same rects');
2019-02-28 00:18:21 +08:00
// check global injection
equal(global.Konva, NewKonva, 'injected');
2019-03-07 11:19:32 +08:00
equal(NewKonva, Konva, 'Full package is the same as core.');