-
Notifications
You must be signed in to change notification settings - Fork 213
Expand file tree
/
Copy pathOutputChannel.test.ts
More file actions
113 lines (87 loc) · 2.62 KB
/
Copy pathOutputChannel.test.ts
File metadata and controls
113 lines (87 loc) · 2.62 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
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import type { MockedObject } from "vitest"
import { OutputChannel } from "../classes/OutputChannel.js"
import { setLogger, type Logger } from "../utils/logger.js"
describe("OutputChannel", () => {
let mockLogger: MockedObject<Logger>
beforeEach(() => {
mockLogger = {
debug: vi.fn(),
info: vi.fn(),
warn: vi.fn(),
error: vi.fn(),
}
setLogger(mockLogger)
})
describe("constructor", () => {
it("should create an output channel with the given name", () => {
const channel = new OutputChannel("TestChannel")
expect(channel.name).toBe("TestChannel")
})
})
describe("name property", () => {
it("should return the channel name", () => {
const channel = new OutputChannel("MyChannel")
expect(channel.name).toBe("MyChannel")
})
})
describe("append()", () => {
it("should log the value with channel name prefix", () => {
const channel = new OutputChannel("TestChannel")
channel.append("test message")
expect(mockLogger.info).toHaveBeenCalledWith(
"[TestChannel] test message",
"VSCode.OutputChannel",
undefined,
)
})
it("should handle empty strings", () => {
const channel = new OutputChannel("TestChannel")
channel.append("")
expect(mockLogger.info).toHaveBeenCalledWith("[TestChannel] ", "VSCode.OutputChannel", undefined)
})
})
describe("appendLine()", () => {
it("should log the value with channel name prefix", () => {
const channel = new OutputChannel("TestChannel")
channel.appendLine("line message")
expect(mockLogger.info).toHaveBeenCalledWith(
"[TestChannel] line message",
"VSCode.OutputChannel",
undefined,
)
})
it("should handle multi-line strings", () => {
const channel = new OutputChannel("TestChannel")
channel.appendLine("line1\nline2")
expect(mockLogger.info).toHaveBeenCalledWith(
"[TestChannel] line1\nline2",
"VSCode.OutputChannel",
undefined,
)
})
})
describe("clear()", () => {
it("should not throw when called", () => {
const channel = new OutputChannel("TestChannel")
expect(() => channel.clear()).not.toThrow()
})
})
describe("show()", () => {
it("should not throw when called without arguments", () => {
const channel = new OutputChannel("TestChannel")
expect(() => channel.show()).not.toThrow()
})
})
describe("hide()", () => {
it("should not throw when called", () => {
const channel = new OutputChannel("TestChannel")
expect(() => channel.hide()).not.toThrow()
})
})
describe("dispose()", () => {
it("should not throw when called", () => {
const channel = new OutputChannel("TestChannel")
expect(() => channel.dispose()).not.toThrow()
})
})
})