forked from badges/shields
/
build-status.spec.js
90 lines (84 loc) · 2.51 KB
/
build-status.spec.js
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
'use strict'
const { expect } = require('chai')
const { test, given, forCases } = require('sazerac')
const { renderBuildStatusBadge } = require('./build-status')
test(renderBuildStatusBadge, () => {
given({ label: 'build', status: 'passed' }).expect({
label: 'build',
message: 'passing',
color: 'brightgreen',
})
given({ label: 'build', status: 'success' }).expect({
label: 'build',
message: 'passing',
color: 'brightgreen',
})
given({ label: 'build', status: 'partially succeeded' }).expect({
label: 'build',
message: 'passing',
color: 'orange',
})
given({ label: 'build', status: 'failed' }).expect({
label: 'build',
message: 'failing',
color: 'red',
})
given({ label: 'build', status: 'error' }).expect({
label: 'build',
message: 'error',
color: 'red',
})
})
test(renderBuildStatusBadge, () => {
forCases([
given({ status: 'fixed' }),
given({ status: 'passed' }),
given({ status: 'passing' }),
given({ status: 'succeeded' }),
given({ status: 'success' }),
given({ status: 'successful' }),
]).assert('should be brightgreen', b =>
expect(b).to.include({ color: 'brightgreen' })
)
})
test(renderBuildStatusBadge, () => {
forCases([
given({ status: 'partially succeeded' }),
given({ status: 'timeout' }),
given({ status: 'unstable' }),
]).assert('should be orange', b => expect(b).to.include({ color: 'orange' }))
})
test(renderBuildStatusBadge, () => {
forCases([
given({ status: 'error' }),
given({ status: 'failed' }),
given({ status: 'failing' }),
given({ status: 'failure' }),
given({ status: 'infrastructure_failure' }),
]).assert('should be red', b => expect(b).to.include({ color: 'red' }))
})
test(renderBuildStatusBadge, () => {
forCases([
given({ status: 'building' }),
given({ status: 'canceled' }),
given({ status: 'cancelled' }),
given({ status: 'expired' }),
given({ status: 'initiated' }),
given({ status: 'no builds' }),
given({ status: 'no tests' }),
given({ status: 'not built' }),
given({ status: 'not run' }),
given({ status: 'pending' }),
given({ status: 'processing' }),
given({ status: 'queued' }),
given({ status: 'running' }),
given({ status: 'scheduled' }),
given({ status: 'skipped' }),
given({ status: 'starting' }),
given({ status: 'stopped' }),
given({ status: 'testing' }),
given({ status: 'waiting' }),
]).assert('should have undefined color', b =>
expect(b).to.include({ color: undefined })
)
})