Skip to content

Commit

Permalink
fix: imageKit test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
bigint committed Jul 3, 2023
1 parent 07cbe74 commit a8ce6a9
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions packages/lib/imageKit.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { AVATAR, STATIC_IMAGES_URL } from '@lenster/data/constants';
import {
LENS_MEDIA_SNAPSHOT_URL,
STATIC_IMAGES_URL
} from '@lenster/data/constants';
import { describe, expect, test } from 'vitest';

import imageKit from './imageKit';
Expand All @@ -15,15 +18,25 @@ describe('imageKit', () => {
expect(result).toEqual(url);
});

test.skip('should return a url with just the image url when no name is provided', () => {
const url = 'image.jpg';
const result = imageKit(url);
// expect(result).toEqual(`${USER_CONTENT_URL}/${url}`);
test('should return an empty string if url is null', () => {
expect(imageKit(null as any)).toBe('');
});

test('should return the original url if it does not include LENS_MEDIA_SNAPSHOT_URL', () => {
const url = 'https://example.com/image.jpg';
expect(imageKit(url)).toBe(url);
});

test.skip('should return a url with the image url and name when name is provided', () => {
const url = 'image.jpg';
const result = imageKit(url, AVATAR);
// expect(result).toEqual(`${USER_CONTENT_URL}/${AVATAR}/${url}`);
test('should return the transformed url if it includes LENS_MEDIA_SNAPSHOT_URL', () => {
const originalUrl = `${LENS_MEDIA_SNAPSHOT_URL}/some-image.jpg`;
const transformedUrl = `${LENS_MEDIA_SNAPSHOT_URL}/transformed/some-image.jpg`;

expect(imageKit(originalUrl, 'transformed')).toBe(transformedUrl);
});

test('should return the original url if name is not provided', () => {
const originalUrl = 'https://lenster.com/some-image.jpg';

expect(imageKit(originalUrl)).toBe(originalUrl);
});
});

0 comments on commit a8ce6a9

Please sign in to comment.