-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathturboStreamListener.test.js
More file actions
35 lines (29 loc) · 1.03 KB
/
turboStreamListener.test.js
File metadata and controls
35 lines (29 loc) · 1.03 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
import './index'
import { animateIn } from './index'
describe('when turbo:before-stream-render event fires', () => {
let turboStream
let element
beforeEach(() => {
let body = document.querySelector('body')
let template = document.createElement('template')
turboStream = document.createElement('turbo-stream')
element = document.createElement('div')
element.setAttribute("data-hw-animate-in", "fade")
template.content.appendChild(element)
turboStream.appendChild(template)
body.appendChild(turboStream)
})
test('animation classes are added on turbo:before-stream-render event', () => {
const event = new CustomEvent("turbo:before-stream-render", {
bubbles: true,
cancelable: true,
detail: {
target: turboStream,
},
})
document.dispatchEvent(event)
// Since animateIn() function is used in the event listener, we need to call it directly in the test.
animateIn(element, 'fade')
expect(element.classList.contains('animate__fade')).toBeTruthy()
})
})