Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: imageKit test cases #3205

Merged
merged 1 commit into from
Jul 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
});
});
Loading