Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Write missing tests for the Flip plugin * Remove broken code branch in Flip plugin Removing this unnecessary "shortcut": - Has no bad effect on complexity - Removes dependency on Rotate plugin - Fixes #829 - Actually shortens and simplifies the implementation
- Loading branch information
Showing
2 changed files
with
99 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import { Jimp, mkJGD } from '@jimp/test-utils'; | ||
|
||
import configure from '@jimp/custom'; | ||
|
||
import flip from '../src'; | ||
|
||
const jimp = configure({ plugins: [flip] }, Jimp); | ||
|
||
describe('Flipping plugin', () => { | ||
it('can flip horizontally', async () => { | ||
const src = await jimp.read( | ||
mkJGD( | ||
'AAAABBBB', | ||
'AAABAAAB', | ||
'ABABABAB', | ||
'CCCCCCCC', | ||
'CCCCCCCC', | ||
'CCCCCCCC', | ||
'AACCCCAA' | ||
) | ||
); | ||
|
||
const result = src.flip(true, false); | ||
|
||
result | ||
.getJGDSync() | ||
.should.be.sameJGD( | ||
mkJGD( | ||
'BBBBAAAA', | ||
'BAAABAAA', | ||
'BABABABA', | ||
'CCCCCCCC', | ||
'CCCCCCCC', | ||
'CCCCCCCC', | ||
'AACCCCAA' | ||
) | ||
); | ||
}); | ||
|
||
it('can flip vertically', async () => { | ||
const src = await jimp.read( | ||
mkJGD( | ||
'AAAABBBB', | ||
'AAABAAAB', | ||
'ABABABAB', | ||
'CCCCCCCC', | ||
'CCCCCCCC', | ||
'CCCCCCCC', | ||
'AACCCCAA' | ||
) | ||
); | ||
|
||
const result = src.flip(false, true); | ||
|
||
result | ||
.getJGDSync() | ||
.should.be.sameJGD( | ||
mkJGD( | ||
'AACCCCAA', | ||
'CCCCCCCC', | ||
'CCCCCCCC', | ||
'CCCCCCCC', | ||
'ABABABAB', | ||
'AAABAAAB', | ||
'AAAABBBB' | ||
) | ||
); | ||
}); | ||
|
||
it('can flip both horizontally and vertically at once', async () => { | ||
const src = await jimp.read( | ||
mkJGD( | ||
'AAAABBBB', | ||
'AAABAAAB', | ||
'ABABABAB', | ||
'CCCCCCCC', | ||
'CCCCCCCC', | ||
'CCCCCCCC', | ||
'AACCCCAA' | ||
) | ||
); | ||
|
||
const result = src.flip(true, true); | ||
|
||
result | ||
.getJGDSync() | ||
.should.be.sameJGD( | ||
mkJGD( | ||
'AACCCCAA', | ||
'CCCCCCCC', | ||
'CCCCCCCC', | ||
'CCCCCCCC', | ||
'BABABABA', | ||
'BAAABAAA', | ||
'BBBBAAAA' | ||
) | ||
); | ||
}); | ||
}); |