compat.test.ts 1.0 KB

1234567891011121314151617181920212223242526
  1. import { describe, expect, it } from 'vitest'
  2. import { compatStatus, needsFreshLaunch } from './compat'
  3. describe('compatStatus', () => {
  4. it('ranks a launch crash above everything else', () => {
  5. expect(compatStatus({ freshLaunch: 'crash', hotswapCrash: true, runtimeCrashes: 3 })).toBe('crashes')
  6. })
  7. it('tells a hotswap-only problem from one still being tested', () => {
  8. expect(compatStatus({ hotswapCrash: true, freshLaunch: 'ok' })).toBe('hotswap-only')
  9. expect(compatStatus({ hotswapCrash: true })).toBe('hotswap-untested')
  10. })
  11. it('reports runtime crashes and is fine otherwise', () => {
  12. expect(compatStatus({ runtimeCrashes: 1 })).toBe('unstable')
  13. expect(compatStatus({ note: 'looks odd' })).toBe('ok')
  14. expect(compatStatus(undefined)).toBe('ok')
  15. })
  16. })
  17. describe('needsFreshLaunch', () => {
  18. it('is only needed after a hotswap crash', () => {
  19. expect(needsFreshLaunch({ hotswapCrash: true, freshLaunch: 'ok' })).toBe(true)
  20. expect(needsFreshLaunch({ runtimeCrashes: 2 })).toBe(false)
  21. })
  22. })