Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
1aron committed Nov 8, 2023
1 parent f92bd61 commit d3c31fd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
26 changes: 13 additions & 13 deletions packages/css/tests/keyframes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ it('expects the animation output', async () => {
p.id = 'mp'
p.classList.add('@fade|1s')
document.body.append(p)
await new Promise(resolve => setTimeout(resolve))
await new Promise(resolve => setTimeout(resolve, 100))
expect(window.masterCSS.text).toContain('.\\@fade\\|1s{animation:fade 1s}')
})

Expand All @@ -33,7 +33,7 @@ it('expects the keyframe output', async () => {
'@zoom|1s',
'{@zoom|1s;f:16}'
)
await new Promise(resolve => setTimeout(resolve))
await new Promise(resolve => setTimeout(resolve, 100))
expect(window.masterCSS.text).toContain('@keyframes fade{0%{opacity:0}to{opacity:1}}')
expect(window.masterCSS.text).toContain('@keyframes flash{0%,50%,to{opacity:1}25%,75%{opacity:0}}')
expect(window.masterCSS.text).toContain('@keyframes float{0%{transform:none}50%{transform:translateY(-1.25rem)}to{transform:none}}')
Expand All @@ -45,36 +45,36 @@ it('expects the keyframe output', async () => {
expect(window.masterCSS.text).toContain('@keyframes shake{0%{transform:none}6.5%{transform:translateX(-6px) rotateY(-9deg)}18.5%{transform:translateX(5px) rotateY(7deg)}31.5%{transform:translateX(-3px) rotateY(-5deg)}43.5%{transform:translateX(2px) rotateY(3deg)}50%{transform:none}}')
expect(window.masterCSS.text).toContain('@keyframes zoom{0%{transform:scale(0)}to{transform:none}}')
p?.classList.remove('@fade|1s')
await new Promise(resolve => setTimeout(resolve))
await new Promise(resolve => setTimeout(resolve, 100))
expect(window.masterCSS.text).not.toContain('@keyframes fade{0%{opacity:0}to{opacity:1}}')
p?.classList.remove('@flash|1s')
await new Promise(resolve => setTimeout(resolve))
await new Promise(resolve => setTimeout(resolve, 100))
expect(window.masterCSS.text).not.toContain('@keyframes flash{0%,50%,to{opacity:1}25%,75%{opacity:0}}')
p?.classList.remove('@float|1s')
await new Promise(resolve => setTimeout(resolve))
await new Promise(resolve => setTimeout(resolve, 100))
expect(window.masterCSS.text).not.toContain('@keyframes float{0%{transform:none}50%{transform:translateY(-1.25rem)}to{transform:none}}')
p?.classList.remove('@heart|1s')
await new Promise(resolve => setTimeout(resolve))
await new Promise(resolve => setTimeout(resolve, 100))
expect(window.masterCSS.text).not.toContain('@keyframes heart{0%{transform:scale(1)}14%{transform:scale(1.3)}28%{transform:scale(1)}42%{transform:scale(1.3)}70%{transform:scale(1)}}')
p?.classList.remove('@jump|1s')
await new Promise(resolve => setTimeout(resolve))
await new Promise(resolve => setTimeout(resolve, 100))
expect(window.masterCSS.text).not.toContain('@keyframes jump{0%,to{transform:translateY(-25%);animation-timing-function:cubic-bezier(.8,0,1,1)}50%{transform:translateY(0);animation-timing-function:cubic-bezier(0,0,.2,1)}}')
p?.classList.remove('@ping|1s')
await new Promise(resolve => setTimeout(resolve))
await new Promise(resolve => setTimeout(resolve, 100))
expect(window.masterCSS.text).not.toContain('@keyframes ping{75%,to{transform:scale(2);opacity:0}}')
p?.classList.remove('@pulse|1s')
await new Promise(resolve => setTimeout(resolve))
await new Promise(resolve => setTimeout(resolve, 100))
expect(window.masterCSS.text).not.toContain('@keyframes pulse{0%{transform:none}50%{transform:scale(1.05)}to{transform:none}}')
p?.classList.remove('@rotate|1s')
await new Promise(resolve => setTimeout(resolve))
await new Promise(resolve => setTimeout(resolve, 100))
expect(window.masterCSS.text).not.toContain('@keyframes rotate{0%{transform:rotate(-360deg)}to{transform:none}}')
p?.classList.remove('@shake|1s')
await new Promise(resolve => setTimeout(resolve))
await new Promise(resolve => setTimeout(resolve, 100))
expect(window.masterCSS.text).not.toContain('@keyframes shake{0%{transform:none}6.5%{transform:translateX(-6px) rotateY(-9deg)}18.5%{transform:translateX(5px) rotateY(7deg)}31.5%{transform:translateX(-3px) rotateY(-5deg)}43.5%{transform:translateX(2px) rotateY(3deg)}50%{transform:none}}')
p?.classList.remove('@zoom|1s')
await new Promise(resolve => setTimeout(resolve))
await new Promise(resolve => setTimeout(resolve, 100))
expect(window.masterCSS.text).toContain('@keyframes zoom{0%{transform:scale(0)}to{transform:none}}')
p?.classList.remove('{@zoom|1s;f:16}')
await new Promise(resolve => setTimeout(resolve))
await new Promise(resolve => setTimeout(resolve, 100))
expect(window.masterCSS.text).not.toContain('@keyframes zoom{0%{transform:scale(0)}to{transform:none}}')
})
6 changes: 3 additions & 3 deletions packages/css/tests/runtime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ it('css count class add', async () => {
p1.classList.add('block', 'font:bold')
document.body.append(p1)
p1.classList.add('italic')
await new Promise(resolve => setTimeout(resolve))
await new Promise(resolve => setTimeout(resolve, 100))
expect(window.masterCSS.classesUsage).toEqual({
'block': 1,
'font:bold': 1,
Expand All @@ -24,9 +24,9 @@ it('css count class add', async () => {

it('css count class complicated example', async () => {
document.body.innerHTML = complexHTML
await new Promise(resolve => setTimeout(resolve))
await new Promise(resolve => setTimeout(resolve, 100))
expect(Object.keys(window.masterCSS.classesUsage).length).toBeTruthy()
document.body.innerHTML = ''
await new Promise(resolve => setTimeout(resolve))
await new Promise(resolve => setTimeout(resolve, 100))
expect(window.masterCSS.classesUsage).toEqual({})
})
2 changes: 1 addition & 1 deletion packages/css/tests/variables.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ it('expects the variable output', async () => {
p.id = 'mp'
p.classList.add('bg:first')
document.body.append(p)
await new Promise(resolve => setTimeout(resolve))
await new Promise(resolve => setTimeout(resolve, 100))
expect(window.masterCSS.text).toContain(':root{--first:17 17 17}.dark{--first:34 34 34}.light{--first:51 51 51}.bg\\:first{background-color:rgb(var(--first))}')
})

Expand Down

0 comments on commit d3c31fd

Please sign in to comment.