Path: blob/master/node_modules/@jimp/plugin-crop/test/crop.test.js
1129 views
import { Jimp, mkJGD } from '@jimp/test-utils';1import configure from '@jimp/custom';23import crop from '../src';45const jimp = configure({ plugins: [crop] }, Jimp);67describe('crop', () => {8// 6x5 size9const testImage = mkJGD(' ◆◆ ', ' ◆▦▦◆ ', '◆▦▦▦▦◆', ' ◆▦▦◆ ', ' ◆◆ ');1011it('full width from top', async () => {12const imgSrc = await jimp.read(testImage);1314imgSrc15.crop(0, 0, 6, 2)16.getJGDSync()17.should.be.sameJGD(mkJGD(' ◆◆ ', ' ◆▦▦◆ '));18});1920it('full width from bottom', async () => {21const imgSrc = await jimp.read(testImage);2223imgSrc24.crop(0, 3, 6, 2)25.getJGDSync()26.should.be.sameJGD(mkJGD(' ◆▦▦◆ ', ' ◆◆ '));27});2829it('full width from middle', async () => {30const imgSrc = await jimp.read(testImage);3132imgSrc33.crop(0, 2, 6, 2)34.getJGDSync()35.should.be.sameJGD(mkJGD('◆▦▦▦▦◆', ' ◆▦▦◆ '));36});3738it('full height from left', async () => {39const imgSrc = await jimp.read(testImage);4041imgSrc42.crop(0, 0, 2, 5)43.getJGDSync()44.should.be.sameJGD(mkJGD(' ', ' ◆', '◆▦', ' ◆', ' '));45});4647it('full height from right', async () => {48const imgSrc = await jimp.read(testImage);4950imgSrc51.crop(4, 0, 2, 5)52.getJGDSync()53.should.be.sameJGD(mkJGD(' ', '◆ ', '▦◆', '◆ ', ' '));54});5556it('full height from middle', async () => {57const imgSrc = await jimp.read(testImage);5859imgSrc60.crop(2, 0, 2, 5)61.getJGDSync()62.should.be.sameJGD(mkJGD('◆◆', '▦▦', '▦▦', '▦▦', '◆◆'));63});64});656667