mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-22 21:47:01 +02:00
refactor: import jest as global; unify import style of some modules (#6898)
* refactor: import jest as global * fix react
This commit is contained in:
parent
e97dc0d37e
commit
c9ee6e467c
59 changed files with 177 additions and 139 deletions
|
@ -13,7 +13,9 @@ describe('lqip library', () => {
|
|||
const invalidPath = path.join(__dirname, '__fixtures__', 'docusaurus.svg');
|
||||
|
||||
it('should reject unknown or unsupported file format', async () => {
|
||||
await expect(lqip.base64(invalidPath)).rejects.toBeTruthy();
|
||||
await expect(lqip.base64(invalidPath)).rejects.toThrow(
|
||||
/Error: Input file is missing or uses unsupported image format, lqip v.*/,
|
||||
);
|
||||
});
|
||||
|
||||
it('should generate a valid base64', async () => {
|
||||
|
|
|
@ -11,36 +11,35 @@ import type {Palette} from 'node-vibrant/lib/color';
|
|||
|
||||
import {toPalette, toBase64} from '../utils';
|
||||
|
||||
describe('lqip-loader', () => {
|
||||
describe('toBase64', () => {
|
||||
test('should return a properly formatted Base64 image string', () => {
|
||||
const expected = 'data:image/jpeg;base64,aGVsbG8gd29ybGQ=';
|
||||
const mockedMimeType = 'image/jpeg';
|
||||
const mockedBase64Data = Buffer.from('hello world');
|
||||
expect(toBase64(mockedMimeType, mockedBase64Data)).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('toPalette', () => {
|
||||
let correctTestSwatch: Palette = {};
|
||||
let testSwatchWithNull: Palette & {Vibrant?: null} = {};
|
||||
|
||||
beforeAll(() => {
|
||||
const imgPath = path.join(__dirname, '__fixtures__', 'endi.jpg');
|
||||
const vibrant = new Vibrant(imgPath, {});
|
||||
|
||||
return vibrant.getPalette().then((palette) => {
|
||||
correctTestSwatch = {...palette};
|
||||
testSwatchWithNull = {...palette, Vibrant: null};
|
||||
});
|
||||
});
|
||||
|
||||
it('should return 6 hex colours sorted by popularity', () => {
|
||||
expect(toPalette(correctTestSwatch)).toHaveLength(6);
|
||||
});
|
||||
|
||||
it('should return 5 hex colours with no errors if a palette was incomplete', () => {
|
||||
expect(toPalette(testSwatchWithNull)).toHaveLength(5);
|
||||
});
|
||||
describe('toBase64', () => {
|
||||
test('should return a properly formatted Base64 image string', () => {
|
||||
const mockedMimeType = 'image/jpeg';
|
||||
const mockedBase64Data = Buffer.from('hello world');
|
||||
expect(toBase64(mockedMimeType, mockedBase64Data)).toEqual(
|
||||
'data:image/jpeg;base64,aGVsbG8gd29ybGQ=',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('toPalette', () => {
|
||||
let correctTestSwatch: Palette = {};
|
||||
let testSwatchWithNull: Palette & {Vibrant?: null} = {};
|
||||
|
||||
beforeAll(() => {
|
||||
const imgPath = path.join(__dirname, '__fixtures__/endi.jpg');
|
||||
const vibrant = new Vibrant(imgPath, {});
|
||||
|
||||
return vibrant.getPalette().then((palette) => {
|
||||
correctTestSwatch = {...palette};
|
||||
testSwatchWithNull = {...palette, Vibrant: null};
|
||||
});
|
||||
});
|
||||
|
||||
it('should return 6 hex colours sorted by popularity', () => {
|
||||
expect(toPalette(correctTestSwatch)).toHaveLength(6);
|
||||
});
|
||||
|
||||
it('should return 5 hex colours with no errors if a palette was incomplete', () => {
|
||||
expect(toPalette(testSwatchWithNull)).toHaveLength(5);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue