generated from actions/javascript-action
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.test.js
92 lines (83 loc) · 2.07 KB
/
index.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
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
import {test, expect} from 'vitest';
import {parseTitle} from './parse-title.js';
test('ignores valid title', async () => {
const output = parseTitle('Hello world', {
keywords: ['bug'],
});
expect(output).toMatchObject({
title: 'Hello world',
labels: [],
});
});
test('Drops keyword with semicolon', async () => {
const output = parseTitle('Bug: things are broken', {
keywords: ['bug'],
});
expect(output).toMatchObject({
title: 'Things are broken',
labels: [],
});
});
test('Drops keyword with brackets', async () => {
const output = parseTitle('[Bug] things are broken', {
keywords: ['bug'],
});
expect(output).toMatchObject({
title: 'Things are broken',
labels: [],
});
});
test('Drops keyword with dash', async () => {
const output = parseTitle('Bug - things are broken', {
keywords: ['bug'],
});
expect(output).toMatchObject({
title: 'Things are broken',
labels: [],
});
});
test('Drops keyword in string with multiple unrelated separators', async () => {
const output = parseTitle('Bug - a[href] is broken(-ish)', {
keywords: ['bug'],
});
expect(output).toMatchObject({
title: 'A[href] is broken(-ish)',
});
});
test('Drops keyword that has space', async () => {
const output = parseTitle('Bug report: things are broken', {
keywords: ['bug report'],
});
expect(output).toMatchObject({
title: 'Things are broken',
labels: [],
});
});
test('Drops keyword regardless of case', async () => {
const output = parseTitle('bug: things are broken', {
keywords: ['Bug'],
});
expect(output).toMatchObject({
title: 'Things are broken',
labels: [],
});
});
test('Supports multiple keyword', async () => {
const output = parseTitle('Bug report: things are broken', {
keywords: ['bug report', 'bug'],
});
expect(output).toMatchObject({
title: 'Things are broken',
labels: [],
});
});
test('Adds specified label', async () => {
const output = parseTitle('Feature request - cool things', {
keywords: ['Feature request'],
labels: ['enhancement'],
});
expect(output).toMatchObject({
title: 'Cool things',
labels: ['enhancement'],
});
});