Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions __tests__/utils/duration.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { describe, expect, it } from 'vitest'

import { parseDuration } from '../../src/utils/duration'

describe('parseDuration', () => {
it.each([
[' 5s', 5000],
['5s ', 5000],
['\t2m\n', 120_000],
[' 0 ', 0],
[' ', 0],
])('trims surrounding whitespace: %j -> %d ms', (text, ms) => {
expect(parseDuration(text)).toBe(ms)
})

it.each([
['1.5ms', 2],
['2.25ms', 2],
['0.0015s', 2],
])('rounds a fractional result to whole milliseconds: %s -> %d ms', (text, ms) => {
expect(parseDuration(text)).toBe(ms)
})

it('names the field in the error', () => {
expect(() => parseDuration('soon', 'delay')).toThrow(`invalid delay 'soon'`)
})
})
13 changes: 13 additions & 0 deletions __tests__/utils/labelCatalog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,19 @@ require_matching_label:
expect(labels.find(l => l.name === 'triage/unlabeled')).toEqual({ name: 'triage/unlabeled' })
})

it('gives the needs- color to a missing label whatever its case', () => {
const labels = desiredLabels(configFrom(`
require_matching_label:
- regexp: ^kind/
missing_label: Needs-Kind
- regexp: ^sig/
missing_label: NEEDS-SIG
`))

expect(labels.find(l => l.name === 'Needs-Kind')).toEqual({ name: 'Needs-Kind', color: 'ededed' })
expect(labels.find(l => l.name === 'NEEDS-SIG')).toEqual({ name: 'NEEDS-SIG', color: 'ededed' })
})

it('de-duplicates case-insensitively, first definition wins', () => {
const labels = desiredLabels(configFrom(`
labels:
Expand Down
Loading