Avatar defaults and colors
This commit is contained in:
parent
a001882d58
commit
12d2b1bf7c
140 changed files with 4212 additions and 1084 deletions
|
@ -2,12 +2,15 @@
|
|||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { assert } from 'chai';
|
||||
import { IMAGE_JPEG, IMAGE_PNG } from '../../types/MIME';
|
||||
import { sniffImageMimeType } from '../../util/sniffImageMimeType';
|
||||
|
||||
import { canvasToBlob } from '../../util/canvasToBlob';
|
||||
|
||||
describe('canvasToBlob', () => {
|
||||
it('converts a canvas to an Blob', async () => {
|
||||
const canvas = document.createElement('canvas');
|
||||
let canvas: HTMLCanvasElement;
|
||||
beforeEach(() => {
|
||||
canvas = document.createElement('canvas');
|
||||
canvas.width = 100;
|
||||
canvas.height = 200;
|
||||
|
||||
|
@ -17,11 +20,27 @@ describe('canvasToBlob', () => {
|
|||
}
|
||||
context.fillStyle = '#ff9900';
|
||||
context.fillRect(10, 10, 20, 20);
|
||||
});
|
||||
|
||||
it('converts a canvas to an Blob, JPEG by default', async () => {
|
||||
const result = await canvasToBlob(canvas);
|
||||
|
||||
assert.strictEqual(
|
||||
sniffImageMimeType(await result.arrayBuffer()),
|
||||
IMAGE_JPEG
|
||||
);
|
||||
|
||||
// These are just smoke tests.
|
||||
assert.instanceOf(result, Blob);
|
||||
assert.isAtLeast(result.size, 50);
|
||||
});
|
||||
|
||||
it('can convert a canvas to a PNG Blob', async () => {
|
||||
const result = await canvasToBlob(canvas, IMAGE_PNG);
|
||||
|
||||
assert.strictEqual(
|
||||
sniffImageMimeType(await result.arrayBuffer()),
|
||||
IMAGE_PNG
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue