-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdditionalContext.test.ts
More file actions
64 lines (52 loc) · 2.02 KB
/
AdditionalContext.test.ts
File metadata and controls
64 lines (52 loc) · 2.02 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
import { describe, expect, it } from 'vitest'
// Create a mock model that simulates the AdditionalContext component
class AdditionalContextModel {
additionalContext: string
expanded: boolean
changeContext: (newContext: string) => void
toggleExpanded: () => void
clearContext: () => void
constructor(initialContext = '', initialExpanded = false) {
this.additionalContext = initialContext
this.expanded = initialExpanded
this.changeContext = (newContext: string) => {
this.additionalContext = newContext
}
this.clearContext = () => {
this.additionalContext = ''
}
this.toggleExpanded = () => {
this.expanded = !this.expanded
}
}
}
describe('AdditionalContext Component', () => {
it('should initialize with default values', () => {
const component = new AdditionalContextModel()
expect(component.additionalContext).toBe('')
expect(component.expanded).toBe(false)
})
it('should initialize with provided values', () => {
const component = new AdditionalContextModel('Some context', true)
expect(component.additionalContext).toBe('Some context')
expect(component.expanded).toBe(true)
})
it('should update additionalContext when changed', () => {
const component = new AdditionalContextModel()
component.changeContext('New context information')
expect(component.additionalContext).toBe('New context information')
})
it('should toggle expanded state', () => {
const component = new AdditionalContextModel()
expect(component.expanded).toBe(false)
component.toggleExpanded()
expect(component.expanded).toBe(true)
component.toggleExpanded()
expect(component.expanded).toBe(false)
})
it('should clear additionalContext', () => {
const component = new AdditionalContextModel('hey')
component.clearContext()
expect(component.additionalContext).toBe('')
})
})