-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextract.test.ts
More file actions
50 lines (42 loc) · 1.82 KB
/
Copy pathextract.test.ts
File metadata and controls
50 lines (42 loc) · 1.82 KB
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
import { describe, expect, test } from 'bun:test'
import { parseSkillUsage } from './extract'
describe('parseSkillUsage', () => {
test('parses skill-invocation lines', () => {
const input = ` 3 skill: superpowers:brainstorming"\n 1 skill: journal:update-journal"\n`
expect(parseSkillUsage(input)).toEqual({
'superpowers:brainstorming': 3,
'journal:update-journal': 1,
})
})
test('parses slash-command lines under a slash: prefix', () => {
const input = ` 2 /clear\n 1 /model\n`
expect(parseSkillUsage(input)).toEqual({ 'slash:clear': 2, 'slash:model': 1 })
})
test('routes a namespaced slash command to the bare plugin:skill key, no slash: prefix', () => {
const input = ` 4 /actual-budget:access\n 2 /cronjobs:cronjob\n 1 /superpowers:test-driven-development\n`
expect(parseSkillUsage(input)).toEqual({
'actual-budget:access': 4,
'cronjobs:cronjob': 2,
'superpowers:test-driven-development': 1,
})
})
test('a non-namespaced slash command still gets the slash: prefix', () => {
const input = ` 3 /clear\n`
expect(parseSkillUsage(input)).toEqual({ 'slash:clear': 3 })
})
test('sums a namespaced slash command with the same key recorded via the Skill-tool convention', () => {
const input = ` 2 skill: cronjobs:cronjob"\n 1 /cronjobs:cronjob\n`
expect(parseSkillUsage(input)).toEqual({ 'cronjobs:cronjob': 3 })
})
test('sums duplicate keys across lines', () => {
const input = ` 1 skill: foo:bar"\n 2 skill: foo:bar"\n`
expect(parseSkillUsage(input)).toEqual({ 'foo:bar': 3 })
})
test('ignores unrelated lines', () => {
const input = `=== Aug 14 20:57\nsome noise\n`
expect(parseSkillUsage(input)).toEqual({})
})
test('empty input produces empty counts', () => {
expect(parseSkillUsage('')).toEqual({})
})
})