generated from actions/javascript-action
-
Notifications
You must be signed in to change notification settings - Fork 27
/
label-extractor.test.js
51 lines (34 loc) · 1.92 KB
/
label-extractor.test.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
const labelExtractor = require('../src/label-extractor')
const EXPECTED_LABELS = ['label-1','label-2_with_underscore','special-[characters](please)']
const EXPECTED_LABELS_SPACES = ['label 1','label 2_with_underscore','special [characters] (please)']
const EXPECTED_SINGLE_ENTRY = ['no changelog entry needed']
describe('the label-extractor', () => {
it('should return all labels', () => {
const labels = labelExtractor.extractLabels('label-1,label-2_with_underscore,special-[characters](please)')
expect(labels).toStrictEqual(EXPECTED_LABELS)
})
it('should return all labels when spaces are included and trailing comma', () => {
const labels = labelExtractor.extractLabels('label-1 , label-2_with_underscore , special-[characters](please),')
expect(labels).toStrictEqual(EXPECTED_LABELS)
})
it('should return all labels with spaces', () => {
const labels = labelExtractor.extractLabels('label 1,label 2_with_underscore,special [characters] (please)')
expect(labels).toStrictEqual(EXPECTED_LABELS_SPACES)
})
it('should return only a single labels with spaces', () => {
const labels = labelExtractor.extractLabels('no changelog entry needed')
expect(labels).toStrictEqual(EXPECTED_SINGLE_ENTRY)
})
it('should handle labels containing a forward slash', () => {
const labels = labelExtractor.extractLabels('skip/changelog')
expect(labels).toStrictEqual(['skip/changelog'])
})
it('should handle multiple labels containing a forward slash', () => {
const labels = labelExtractor.extractLabels('skip/changelog,no/changelog')
expect(labels).toStrictEqual(['skip/changelog', 'no/changelog'])
})
it('should handle multiple labels containing a `:` characters (emoji usage)', () => {
const labels = labelExtractor.extractLabels(':wrench: GitHub Actions, :smile: Best Label Ever')
expect(labels).toStrictEqual([':wrench: GitHub Actions', ':smile: Best Label Ever'])
})
})