-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathformat.test.ts
98 lines (84 loc) · 3.81 KB
/
format.test.ts
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import {formatSize, generateTestChangesSummary} from '../utils/format';
describe('format utils', () => {
describe('formatSize', () => {
test('should format size in KB when less than 1024 bytes', () => {
const size = 512; // 512 bytes
expect(formatSize(size)).toBe('0.50 KB');
});
test('should format size in MB when greater than or equal to 1024 bytes', () => {
const size = 2.5 * 1024; // 2.5 KB -> will be shown in MB
expect(formatSize(size)).toBe('2.50 KB');
});
test('should handle small sizes', () => {
const size = 100; // 100 bytes
expect(formatSize(size)).toBe('0.10 KB');
});
test('should handle zero', () => {
expect(formatSize(0)).toBe('0.00 KB');
});
});
describe('generateTestChangesSummary', () => {
test('should generate summary for new tests only', () => {
const comparison = {
new: ['Test 1 (file1.ts)', 'Test 2 (file2.ts)'],
skipped: [],
deleted: [],
};
const summary = generateTestChangesSummary(comparison);
expect(summary).toContain('✨ New Tests (2)');
expect(summary).toContain('1. Test 1 (file1.ts)');
expect(summary).toContain('2. Test 2 (file2.ts)');
expect(summary).not.toContain('⏭️ Skipped Tests');
expect(summary).not.toContain('🗑️ Deleted Tests');
});
test('should generate summary for skipped tests only', () => {
const comparison = {
new: [],
skipped: ['Test 1 (file1.ts)', 'Test 2 (file2.ts)'],
deleted: [],
};
const summary = generateTestChangesSummary(comparison);
expect(summary).toContain('⏭️ Skipped Tests (2)');
expect(summary).toContain('1. Test 1 (file1.ts)');
expect(summary).toContain('2. Test 2 (file2.ts)');
expect(summary).not.toContain('✨ New Tests');
expect(summary).not.toContain('🗑️ Deleted Tests');
});
test('should generate summary for deleted tests only', () => {
const comparison = {
new: [],
skipped: [],
deleted: ['Test 1 (file1.ts)', 'Test 2 (file2.ts)'],
};
const summary = generateTestChangesSummary(comparison);
expect(summary).toContain('🗑️ Deleted Tests (2)');
expect(summary).toContain('1. Test 1 (file1.ts)');
expect(summary).toContain('2. Test 2 (file2.ts)');
expect(summary).not.toContain('✨ New Tests');
expect(summary).not.toContain('⏭️ Skipped Tests');
});
test('should generate summary for all types of changes', () => {
const comparison = {
new: ['New Test (file1.ts)'],
skipped: ['Skipped Test (file2.ts)'],
deleted: ['Deleted Test (file3.ts)'],
};
const summary = generateTestChangesSummary(comparison);
expect(summary).toContain('✨ New Tests (1)');
expect(summary).toContain('⏭️ Skipped Tests (1)');
expect(summary).toContain('🗑️ Deleted Tests (1)');
expect(summary).toContain('New Test (file1.ts)');
expect(summary).toContain('Skipped Test (file2.ts)');
expect(summary).toContain('Deleted Test (file3.ts)');
});
test('should handle no changes', () => {
const comparison = {
new: [],
skipped: [],
deleted: [],
};
const summary = generateTestChangesSummary(comparison);
expect(summary).toBe('😟 No changes in tests. 😕');
});
});
});