mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-23 14:06:59 +02:00
test: enable a few jest eslint rules (#6900)
* test: enable a few jest eslint rules * more
This commit is contained in:
parent
1efc6c6091
commit
aa5a2d4c04
155 changed files with 3644 additions and 3478 deletions
|
@ -6,25 +6,27 @@
|
|||
*/
|
||||
|
||||
import path from 'path';
|
||||
import * as lqip from '../lqip';
|
||||
import {base64, palette} from '../lqip';
|
||||
|
||||
describe('lqip library', () => {
|
||||
const imgPath = path.join(__dirname, '__fixtures__', 'endi.jpg');
|
||||
const invalidPath = path.join(__dirname, '__fixtures__', 'docusaurus.svg');
|
||||
const imgPath = path.join(__dirname, '__fixtures__', 'endi.jpg');
|
||||
const invalidPath = path.join(__dirname, '__fixtures__', 'docusaurus.svg');
|
||||
|
||||
it('should reject unknown or unsupported file format', async () => {
|
||||
await expect(lqip.base64(invalidPath)).rejects.toThrow(
|
||||
describe('base64', () => {
|
||||
it('rejects unknown or unsupported file format', async () => {
|
||||
await expect(base64(invalidPath)).rejects.toThrow(
|
||||
/Error: Input file is missing or uses unsupported image format, lqip v.*/,
|
||||
);
|
||||
});
|
||||
|
||||
it('should generate a valid base64', async () => {
|
||||
it('generates a valid base64', async () => {
|
||||
const expectedBase64 = 'data:image/jpeg;base64,/9j/2wBDA';
|
||||
await expect(lqip.base64(imgPath)).resolves.toContain(expectedBase64);
|
||||
await expect(base64(imgPath)).resolves.toContain(expectedBase64);
|
||||
});
|
||||
});
|
||||
|
||||
it('should generate a valid color palette', async () => {
|
||||
const imgPalette = await lqip.palette(imgPath);
|
||||
describe('palette', () => {
|
||||
it('generates a valid color palette', async () => {
|
||||
const imgPalette = await palette(imgPath);
|
||||
expect(imgPalette).toHaveLength(6);
|
||||
expect(imgPalette).toContain('#578ca1');
|
||||
});
|
||||
|
|
|
@ -12,7 +12,7 @@ import type {Palette} from 'node-vibrant/lib/color';
|
|||
import {toPalette, toBase64} from '../utils';
|
||||
|
||||
describe('toBase64', () => {
|
||||
test('should return a properly formatted Base64 image string', () => {
|
||||
it('returns a properly formatted Base64 image string', () => {
|
||||
const mockedMimeType = 'image/jpeg';
|
||||
const mockedBase64Data = Buffer.from('hello world');
|
||||
expect(toBase64(mockedMimeType, mockedBase64Data)).toEqual(
|
||||
|
@ -35,11 +35,11 @@ describe('toPalette', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should return 6 hex colours sorted by popularity', () => {
|
||||
it('returns 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', () => {
|
||||
it('returns 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