Skip to content

Commit ee5d2e5

Browse files
committed
mods: tests name their tier with tier(), and /diff's two answers and the tests on them use an ASCII apostrophe
1 parent a5b0e0c commit ee5d2e5

9 files changed

Lines changed: 27 additions & 33 deletions

File tree

‎mods/README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ would be, and nothing is beneath them: a call they leave unanswered throws,
3131
naming its event.
3232

3333
```ts
34-
import { expect, seat, test } from 'claude-code/testing'
34+
import { expect, test, tier } from 'claude-code/testing'
3535

36-
seat('builtin')
36+
tier('builtin')
3737

3838
test('outside a git repository /diff says so and opens nothing', async ($, on) => {
3939
const opened: string[] = []
@@ -52,7 +52,7 @@ test('outside a git repository /diff says so and opens nothing', async ($, on) =
5252
origin: { kind: 'composer' },
5353
})
5454

55-
expect(text).toMatch(/isn.t in a git repository/)
55+
expect(text).toContain("isn't in a git repository")
5656
expect(opened).toEqual([])
5757
})
5858
```

‎mods/diff/hooks/names/texts/git-unanswered-text.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
* cannot start has answered, and gets the not-a-repository text.
66
*/
77
export const GIT_UNANSWERED_TEXT =
8-
'The diff panel couldn’t read git state — git didn’t answer; run /diff ' +
8+
"The diff panel couldn't read git state — git didn't answer; run /diff " +
99
'again'
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
2-
* `/diff`'s answer outside a git repository, worded as the built-in words it.
2+
* `/diff`'s answer outside a git repository, worded as the built-in words it
3+
* but for its apostrophe, which is ASCII.
34
*/
45
export const NOT_IN_REPOSITORY_TEXT =
5-
'The diff panel shows git changes — the current directory isn’t in a ' +
6+
"The diff panel shows git changes — the current directory isn't in a " +
67
'git repository'

‎mods/diff/tests/boot-probe.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import type {
33
ProcessRunResult,
44
SessionStartInput,
55
} from 'claude-code'
6-
import { clock, expect, seat, test } from 'claude-code/testing'
6+
import { clock, expect, test, tier } from 'claude-code/testing'
77

8-
seat('builtin')
8+
tier('builtin')
99

1010
const SESSION: SessionStartInput = {
1111
surface: 'terminal',
@@ -52,7 +52,7 @@ test('/diff at boot joins the boot probe, then asks again', async ($, on) => {
5252
await booting
5353

5454
expect(await ran).toEqual({
55-
text: expect.stringMatching(/isn.t in a git repository/),
55+
text: expect.stringContaining("isn't in a git repository"),
5656
})
5757
expect(probes, 'then one more of its own').toHaveLength(2)
5858
})

‎mods/diff/tests/command.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import type {
33
ProcessRunResult,
44
SessionStartInput,
55
} from 'claude-code'
6-
import { expect, seat, test } from 'claude-code/testing'
6+
import { expect, test, tier } from 'claude-code/testing'
77

8-
seat('builtin')
8+
tier('builtin')
99

1010
const SESSION: SessionStartInput = {
1111
surface: 'terminal',
@@ -37,7 +37,7 @@ test('outside a git repository /diff says so and opens nothing', async ($, on) =
3737
await $.session.start(SESSION)
3838
const { text } = await $.command.run(DIFF)
3939

40-
expect(text).toMatch(/isn.t in a git repository/)
40+
expect(text).toContain("isn't in a git repository")
4141
expect(opened).toEqual([])
4242
})
4343

@@ -51,7 +51,7 @@ test('a git that never answers is not "no repository"', async ($, on) => {
5151
await $.session.start(SESSION)
5252
const { text } = await $.command.run(DIFF)
5353

54-
expect(text).toMatch(/git didn.t answer/)
54+
expect(text).toContain("git didn't answer")
5555
})
5656

5757
test('with the built-in holding /diff, the plugin stands down', async ($, on) => {

‎mods/diff/tests/pane.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import {
1111
clock,
1212
expect,
1313
memoryStore,
14-
seat,
1514
test,
1615
textOf,
16+
tier,
1717
} from 'claude-code/testing'
1818

19-
seat('builtin')
19+
tier('builtin')
2020

2121
const SESSION: SessionStartInput = {
2222
surface: 'terminal',

‎mods/sec-default/tests/sec-default.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import type {
77
ToolInfo,
88
} from 'claude-code'
99
import type { Plugin } from 'claude-code/testing'
10-
import { expect, seat, test } from 'claude-code/testing'
10+
import { expect, test, tier } from 'claude-code/testing'
1111

12-
seat('prepend')
12+
tier('prepend')
1313

1414
const SESSION: SessionStartInput = {
1515
surface: 'terminal',
@@ -116,7 +116,7 @@ const dropping: Plugin = {
116116
}
117117

118118
/**
119-
* The organization's own plugin, seated last, which signs the section.
119+
* The organization's own plugin, in its last tier, which signs the section.
120120
*/
121121
const signing: Plugin = {
122122
name: 'signing',

‎mods/telemetry/tests/telemetry.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import type {
66
SessionAuthorization,
77
} from 'claude-code'
88
import type { Plugin } from 'claude-code/testing'
9-
import { expect, memoryEnv, seat, test } from 'claude-code/testing'
9+
import { expect, memoryEnv, test, tier } from 'claude-code/testing'
1010

1111
import type { LogEntry } from '../hooks/telemetry-types'
1212

13-
seat('builtin')
13+
tier('builtin')
1414

1515
const BEARER: SessionAuthorization = { handle: 'the-handle', kind: 'bearer' }
1616
const ACCEPTED: HttpResponse = { status: 200, ok: true, headers: {}, text: '' }

‎mods/types/claude-code.d.ts‎

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// Also here: 'claude-code/testing', the kit a plugin's *.test.ts files
2020
// import under `claude plugin test <dir>`: `test(name, async ($, on) =>
2121
// { ... })`, where `$` is the engine's own and the hooks `on` registers
22-
// sit beneath every plugin; with seat, describe, expect and clock.
22+
// sit beneath every plugin; with tier, describe, expect and clock.
2323
//
2424
// Typing a plugin against it:
2525
// export const register: Register = (on, options) => { ... }
@@ -8300,22 +8300,15 @@ declare module 'claude-code/testing' {
83008300
*/
83018301
export type TestBody = ($: Engine, on: import('claude-code').On) => unknown
83028302

8303-
/**
8304-
* Where a plugin is seated: the organization's first (`prepend`), the
8305-
* person's own (`user`), the organization's last (`append`), or built in
8306-
* (`builtin`), in the engine's own chain order.
8307-
*/
8308-
export type Seat = Exclude<import('claude-code').Tier, 'core'>
8309-
83108303
/**
83118304
* A plugin a test writes inline, loaded as a plugin folder is: its name,
8312-
* where it is seated (`user` when not given), and its hooks module's
8305+
* the tier it loads in (`user` when not given), and its hooks module's
83138306
* `register`, written `register(on) { ... }`. `register` is
83148307
* self-contained, as a module's is: it closes over nothing of the test file.
83158308
*/
83168309
export type Plugin = {
83178310
name: string
8318-
tier?: Seat
8311+
tier?: Exclude<import('claude-code').Tier, 'core'>
83198312
register: import('claude-code').Register
83208313
}
83218314

@@ -8342,10 +8335,10 @@ declare module 'claude-code/testing' {
83428335
export function describe(name: string, body: () => void): void
83438336

83448337
/**
8345-
* Where the plugin under test is seated, once for the file, at its top
8346-
* level: the tier it ships in. Unsaid, it is the person's own (`user`).
8338+
* The tier the plugin under test loads in, once for the file, at its top
8339+
* level: `prepend`, `user` (when unsaid), `append` or `builtin`.
83478340
*/
8348-
export function seat(tier: Seat): void
8341+
export function tier(tier: Exclude<import('claude-code').Tier, 'core'>): void
83498342

83508343
/**
83518344
* The time `$.clock` reads in a test, which moves only when the test says:

0 commit comments

Comments
 (0)