Skip to content

Commit e3e3e5d

Browse files
committed
chore: add comments about zero quality and test for it
1 parent 4699ffe commit e3e3e5d

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/__tests__/convert-to-uploadcare-quality-string.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,9 @@ describe('convertToUploadcareQualityString', () => {
1616
it('should map 100 to best', () => {
1717
expect(convertToUploadcareQualityString(100)).toBe('best');
1818
});
19+
20+
it('should falsy values to smart', () => {
21+
expect(convertToUploadcareQualityString()).toBe('smart');
22+
expect(convertToUploadcareQualityString(0)).toBe('smart');
23+
});
1924
});

src/utils/helpers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ export function convertToUploadcareQualityString(
6868
requestedQuality?: number
6969
): string {
7070
// If any particular quality has not been requested, we use the smart quality mode.
71+
// zero quality is treated as no quality, so we use smart.
72+
// see https://nextjs.org/docs/api-reference/next/image#quality
7173
if (!requestedQuality) {
7274
return 'smart';
7375
}

0 commit comments

Comments
 (0)