-
Notifications
You must be signed in to change notification settings - Fork 439
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
convertTypes
option to configure converting mime types
fix #123
- Loading branch information
1 parent
8e761ab
commit caafa4c
Showing
8 changed files
with
61 additions
and
3 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
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
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
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,32 @@ | ||
describe('convertTypes', () => { | ||
it('should convert the image from PNG to JPEG', (done) => { | ||
window.loadImageAsBlob('/base/docs/images/picture.png', (image) => { | ||
const compressor = new Compressor(image, { | ||
convertSize: 0, | ||
success(result) { | ||
expect(image.type).to.equal('image/png'); | ||
expect(result.type).to.equal('image/jpeg'); | ||
done(); | ||
}, | ||
}); | ||
|
||
expect(compressor.options.convertTypes).to.deep.equal(['image/png']); | ||
}); | ||
}); | ||
|
||
it('should not convert the image from PNG to JPEG', (done) => { | ||
window.loadImageAsBlob('/base/docs/images/picture.png', (image) => { | ||
const compressor = new Compressor(image, { | ||
convertTypes: [], | ||
convertSize: 0, | ||
success(result) { | ||
expect(image.type).to.equal('image/png'); | ||
expect(result.type).to.equal('image/png'); | ||
done(); | ||
}, | ||
}); | ||
|
||
expect(compressor.options.convertTypes).to.deep.equal([]); | ||
}); | ||
}); | ||
}); |
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