shortcuts.spec.ts — vite Source File
Architecture documentation for shortcuts.spec.ts, a typescript file in the vite codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 398088ae_77cc_a820_af72_6027733755e4["shortcuts.spec.ts"] a423a1ed_f7d8_0eb5_9b8f_ddfa7fa8147e["index.ts"] 398088ae_77cc_a820_af72_6027733755e4 --> a423a1ed_f7d8_0eb5_9b8f_ddfa7fa8147e 19009191_26ac_2526_d048_41ac02638e55["createServer"] 398088ae_77cc_a820_af72_6027733755e4 --> 19009191_26ac_2526_d048_41ac02638e55 e49f0ff7_5101_3a1d_5a1f_33fae58eea2d["preview.ts"] 398088ae_77cc_a820_af72_6027733755e4 --> e49f0ff7_5101_3a1d_5a1f_33fae58eea2d 5c50110b_5c76_c14f_b1dd_3efd3df7f375["preview"] 398088ae_77cc_a820_af72_6027733755e4 --> 5c50110b_5c76_c14f_b1dd_3efd3df7f375 ed89bdb5_1269_0bd7_7665_244657588aa2["shortcuts.ts"] 398088ae_77cc_a820_af72_6027733755e4 --> ed89bdb5_1269_0bd7_7665_244657588aa2 bb1ed403_9d6f_40ac_2626_a66dcdc3a0cb["bindCLIShortcuts"] 398088ae_77cc_a820_af72_6027733755e4 --> bb1ed403_9d6f_40ac_2626_a66dcdc3a0cb a340ba46_b2b7_3048_3bb3_6907a74c8464["vitest"] 398088ae_77cc_a820_af72_6027733755e4 --> a340ba46_b2b7_3048_3bb3_6907a74c8464 style 398088ae_77cc_a820_af72_6027733755e4 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import type { Mock } from 'vitest'
import { describe, expect, test, vi } from 'vitest'
import { createServer } from '../server'
import { preview } from '../preview'
import { bindCLIShortcuts } from '../shortcuts'
describe('bindCLIShortcuts', () => {
test.each([
['dev server', () => createServer()],
['preview server', () => preview()],
])('binding custom shortcuts with the %s', async (_, startServer) => {
const server = await startServer()
try {
const xAction = vi.fn()
const yAction = vi.fn()
bindCLIShortcuts(
server,
{
customShortcuts: [
{ key: 'x', description: 'test x', action: xAction },
{ key: 'y', description: 'test y', action: yAction },
],
},
true,
)
expect.assert(
server._shortcutsState?.rl,
'The readline interface should be defined after binding shortcuts.',
)
expect(xAction).not.toHaveBeenCalled()
server._shortcutsState.rl.emit('line', 'x')
await vi.waitFor(() => expect(xAction).toHaveBeenCalledOnce())
const xUpdatedAction = vi.fn()
const zAction = vi.fn()
bindCLIShortcuts(
server,
{
customShortcuts: [
{ key: 'x', description: 'test x updated', action: xUpdatedAction },
{ key: 'z', description: 'test z', action: zAction },
],
},
true,
)
expect(xUpdatedAction).not.toHaveBeenCalled()
server._shortcutsState.rl.emit('line', 'x')
await vi.waitFor(() => expect(xUpdatedAction).toHaveBeenCalledOnce())
// Ensure original xAction is not called again
expect(xAction).toHaveBeenCalledOnce()
expect(yAction).not.toHaveBeenCalled()
server._shortcutsState.rl.emit('line', 'y')
// ... (114 more lines)
Domain
Dependencies
Source
Frequently Asked Questions
What does shortcuts.spec.ts do?
shortcuts.spec.ts is a source file in the vite codebase, written in typescript. It belongs to the ViteCore domain.
What does shortcuts.spec.ts depend on?
shortcuts.spec.ts imports 7 module(s): bindCLIShortcuts, createServer, index.ts, preview, preview.ts, shortcuts.ts, vitest.
Where is shortcuts.spec.ts in the architecture?
shortcuts.spec.ts is located at packages/vite/src/node/__tests__/shortcuts.spec.ts (domain: ViteCore, directory: packages/vite/src/node/__tests__).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free