Skip to content

Commit

Permalink
chore: add missing util tests
Browse files Browse the repository at this point in the history
As part of podman-desktop/extension-bootc#866
it was noticed that the Util class is missing tests for a couple functions,
this just adds them.

Signed-off-by: Tim deBoer <[email protected]>
  • Loading branch information
deboer-tim committed Sep 30, 2024
1 parent 1982569 commit dfdacce
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion packages/renderer/src/lib/ui/Util.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,25 @@ import '@testing-library/jest-dom/vitest';

import { expect, test } from 'vitest';

import { capitalize } from './Util';
import { capitalize, getTabUrl, isTabSelected } from './Util';

test('test capitalize function', () => {
expect(capitalize('test')).toBe('Test');
expect(capitalize('Test')).toBe('Test');
expect(capitalize('TEST')).toBe('TEST');
});

test('test getTabUrl', () => {
expect(getTabUrl('/images', 'images')).toBe('/images');
expect(getTabUrl('/images/summary', 'summary')).toBe('/images/summary');
expect(getTabUrl('/images/summary', 'logs')).toBe('/images/logs');
expect(getTabUrl('/images/image-id/summary', 'logs')).toBe('/images/image-id/logs');
expect(getTabUrl('/images/image-id/logs', 'logs')).toBe('/images/image-id/logs');
});

test('test isTabSelected', () => {
expect(isTabSelected('/images/details/summary', 'summary')).toBe(true);
expect(isTabSelected('/images/details/logs', 'summary')).toBe(false);
expect(isTabSelected('/images/details/', 'images')).toBe(false);
expect(isTabSelected('/images/image-id/details/summary', 'summary')).toBe(true);
});

0 comments on commit dfdacce

Please sign in to comment.