Skip to content

Commit a3e34e5

Browse files
committed
wip
1 parent a075de8 commit a3e34e5

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

packages/signals/signals/src/core/signal-generators/dom-gen/__tests__/mutation-observer.test.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ describe('MutationObservable', () => {
6969
})
7070
})
7171

72-
it('should debounce attribute changes if they occur in text inputs', async () => {
72+
it('should debounce text inputs', async () => {
7373
mutationObservable = new MutationObservable(
7474
new MutationObservableSettings({
7575
debounceMs: 100,
@@ -89,42 +89,41 @@ describe('MutationObservable', () => {
8989
attributes: { value: 'hello world' },
9090
})
9191
})
92-
93-
it('should handle multiple attributes changeing', async () => {
92+
it('should debounce tect inputs if happening in the same tick', async () => {
9493
mutationObservable = new MutationObservable(
9594
new MutationObservableSettings({
9695
debounceMs: 100,
97-
observedAttributes: (roles) => [...roles, 'aria-foo'],
9896
})
9997
)
10098
mutationObservable.subscribe(subscribeFn)
10199
testInput.setAttribute('value', 'hello')
102-
testInput.setAttribute('aria-foo', 'bar')
103-
await sleep(200)
100+
testInput.setAttribute('value', 'hello wor')
101+
testInput.setAttribute('value', 'hello world')
102+
await sleep(100)
104103

105104
expect(subscribeFn).toHaveBeenCalledTimes(1)
106105
expect(subscribeFn).toHaveBeenCalledWith({
107106
element: testInput,
108-
attributes: { value: 'hello', 'aria-foo': 'bar' },
107+
attributes: { value: 'hello world' },
109108
})
110109
})
111110

112-
it('should debounce if happening in the same tick', async () => {
111+
it('should handle multiple attributes changing', async () => {
113112
mutationObservable = new MutationObservable(
114113
new MutationObservableSettings({
115-
debounceMs: 50,
114+
debounceMs: 100,
115+
observedAttributes: (roles) => [...roles, 'aria-foo'],
116116
})
117117
)
118118
mutationObservable.subscribe(subscribeFn)
119119
testInput.setAttribute('value', 'hello')
120-
testInput.setAttribute('value', 'hello wor')
121-
testInput.setAttribute('value', 'hello world')
122-
await sleep(100)
120+
testInput.setAttribute('aria-foo', 'bar')
121+
await sleep(200)
123122

124123
expect(subscribeFn).toHaveBeenCalledTimes(1)
125124
expect(subscribeFn).toHaveBeenCalledWith({
126125
element: testInput,
127-
attributes: { value: 'hello world' },
126+
attributes: { value: 'hello', 'aria-foo': 'bar' },
128127
})
129128
})
130129

0 commit comments

Comments
 (0)