forked from pterodactyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelpers.spec.ts
More file actions
29 lines (25 loc) · 1.17 KB
/
helpers.spec.ts
File metadata and controls
29 lines (25 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { hexToRgba } from '@/lib/helpers';
describe('@/lib/helpers.ts', function () {
describe('hexToRgba()', function () {
it('should return the expected rgba', function () {
expect(hexToRgba('#ffffff')).toBe('rgba(255, 255, 255, 1)');
expect(hexToRgba('#00aabb')).toBe('rgba(0, 170, 187, 1)');
expect(hexToRgba('#efefef')).toBe('rgba(239, 239, 239, 1)');
});
it('should ignore case', function () {
expect(hexToRgba('#FF00A3')).toBe('rgba(255, 0, 163, 1)');
});
it('should allow alpha channel changes', function () {
expect(hexToRgba('#ece5a8', 0.5)).toBe('rgba(236, 229, 168, 0.5)');
expect(hexToRgba('#ece5a8', 0.1)).toBe('rgba(236, 229, 168, 0.1)');
expect(hexToRgba('#000000', 0)).toBe('rgba(0, 0, 0, 0)');
});
it('should handle invalid strings', function () {
expect(hexToRgba('')).toBe('');
expect(hexToRgba('foobar')).toBe('foobar');
expect(hexToRgba('#fff')).toBe('#fff');
expect(hexToRgba('#')).toBe('#');
expect(hexToRgba('#fffffy')).toBe('#fffffy');
});
});
});