UNPKG

voluptasquisquam

Version:

Image processing and manipulation in JavaScript

84 lines (73 loc) 2.05 kB
import {Image} from 'test/common'; import 'should'; describe('check getBestMatch class', function () { it('should move the image to the bottom right', function () { let image1 = new Image(5, 5, [ 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 2, 2, 2, 0, 1, 2, 3, 3, 0, 1, 2, 3, 4 ], {kind: 'GREY'} ); let image2 = new Image(5, 5, [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], {kind: 'GREY'} ); image1.getBestMatch(image2).should.eql([2, 2]); }); it('should move the image to the bottom', function () { let image1 = new Image(5, 5, [ 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 2, 1, 0, 0, 1, 3, 1, 0, 0, 1, 4, 1, 0 ], {kind: 'GREY'} ); let image2 = new Image(5, 5, [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], {kind: 'GREY'} ); image1.getBestMatch(image2).should.eql([0, 2]); }); it('should move the image to the top left', function () { let image1 = new Image(5, 5, [ 6, 0, 0, 0, 0, 0, 5, 1, 1, 0, 0, 1, 2, 1, 0, 0, 1, 3, 1, 0, 0, 1, 4, 1, 0 ], {kind: 'GREY'} ); let image2 = new Image(5, 5, [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], {kind: 'GREY'} ); image1.getBestMatch(image2).should.eql([-2, -2]); }); });