mirror of
https://github.com/idrawjs/idraw
synced 2026-05-24 01:58:27 +00:00
21 lines
594 B
TypeScript
21 lines
594 B
TypeScript
import { downloadImageFromCanvas } from '@idraw/util';
|
|
|
|
describe('@idraw/util: lib/file', () => {
|
|
const canvas = document.createElement('canvas');
|
|
const ctx = canvas.getContext('2d') as CanvasRenderingContext2D;
|
|
const opts = {
|
|
width: 600,
|
|
height: 400
|
|
};
|
|
ctx.clearRect(0, 0, opts.width, opts.height);
|
|
ctx.fillStyle = '#ffffff';
|
|
ctx.fillRect(0, 0, opts.width / 2, opts.height / 2);
|
|
|
|
test('downloadImageFromCanvas', async () => {
|
|
downloadImageFromCanvas(canvas, {
|
|
fileName: 'hello',
|
|
type: 'image/png'
|
|
});
|
|
expect(canvas).toMatchSnapshot();
|
|
});
|
|
});
|