Skip to content

Commit

Permalink
fix async test errors
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed Feb 17, 2021
1 parent 568680c commit 4e4d612
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions packages/lqip-loader/src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,19 @@ describe('lqip-loader', () => {
const imgPath = path.join(__dirname, '__fixtures__', 'endi.jpg');
const invalidPath = path.join(__dirname, '__fixtures__', 'docusaurus.svg');

it('should reject unknown or unsupported file format', () => {
expect(lqip.base64(invalidPath)).rejects.toBeTruthy();
it('should reject unknown or unsupported file format', async () => {
await expect(lqip.base64(invalidPath)).rejects.toBeTruthy();
});

it('should generate a valid base64', () => {
it('should generate a valid base64', async () => {
const expectedBase64 = 'data:image/jpeg;base64,/9j/2wBDA';
lqip.base64(imgPath).then((base64: string) => {
expect(base64).toContain(expectedBase64);
});
await expect(lqip.base64(imgPath)).resolves.toContain(expectedBase64);
});

it('should generate a valid color palette', () => {
lqip.palette(imgPath).then((imgPalette: string[]) => {
expect(imgPalette).toHaveLength(6);
expect(imgPalette).toContain('#578ca1');
});
it('should generate a valid color palette', async () => {
const imgPalette = await lqip.palette(imgPath);
expect(imgPalette).toHaveLength(6);
expect(imgPalette).toContain('#578ca1');
});
});
});

0 comments on commit 4e4d612

Please sign in to comment.