-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcommitOrder.test.ts
61 lines (60 loc) · 2.04 KB
/
commitOrder.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
import { validateCommitOrder } from '../src/utils/validateCommits'
describe('commitOrder', () => {
describe('#.# format', () => {
it('should return true if order is valid', () => {
const positions = ['INIT', '1', '1.1:T', '1.2:T', '2', '2.1:T']
const result = validateCommitOrder(positions)
expect(result).toBe(true)
})
it('should return true if valid with duplicates', () => {
const positions = [
'INIT',
'INIT',
'1',
'1',
'1.1:T',
'1.1:T',
'1.1:S',
'1.1:S',
'1.2:T',
'1.2:S',
'2',
'2',
'2.1:T',
'2.1:S'
]
const result = validateCommitOrder(positions)
expect(result).toBe(true)
})
it('should return false if INIT is out of order', () => {
const positions = ['INIT', '1', '1.1:T', '1.2:T', 'INIT', '2', '2.1:T']
const result = validateCommitOrder(positions)
expect(result).toBe(false)
})
it('should return false if level after step is out of order', () => {
const positions = ['INIT', '1', '1.1:T', '1.2:T', '2.1:T', '2']
const result = validateCommitOrder(positions)
expect(result).toBe(false)
})
it('should return false if level is out of order', () => {
const positions = ['INIT', '1', '3', '2']
const result = validateCommitOrder(positions)
expect(result).toBe(false)
})
it('should return false if step is out of order', () => {
const positions = ['INIT', '1', '1.1:T', '1.3:T', '1.2:T']
const result = validateCommitOrder(positions)
expect(result).toBe(false)
})
it('should return false if solution is before step', () => {
const positions = ['INIT', '1', '1.1:S', '1.1:T', '1.2:T']
const result = validateCommitOrder(positions)
expect(result).toBe(false)
})
it('should return false if solution but no test step', () => {
const positions = ['INIT', '1', '1.1:S', '1.2:T']
const result = validateCommitOrder(positions)
expect(result).toBe(false)
})
})
})