Skip to content
Source
Sign inSign up
TanStack/devtools
Open History to see the last commit

devtools-packages.test.ts

58 lines2.0 KB

1import { describe, expect, it } from 'vitest'
2import {
3 TANSTACK_DEVTOOLS_PACKAGES,
4 isTanStackDevtoolsImport,
5} from './devtools-packages'
6​
7describe('TANSTACK_DEVTOOLS_PACKAGES', () => {
8 it('contains exactly 7 entries', () => {
9 expect(TANSTACK_DEVTOOLS_PACKAGES).toHaveLength(7)
10 })
11​
12 it('includes the known framework-specific devtools packages', () => {
13 expect(TANSTACK_DEVTOOLS_PACKAGES).toContain('@tanstack/react-devtools')
14 expect(TANSTACK_DEVTOOLS_PACKAGES).toContain('@tanstack/preact-devtools')
15 expect(TANSTACK_DEVTOOLS_PACKAGES).toContain('@tanstack/solid-devtools')
16 expect(TANSTACK_DEVTOOLS_PACKAGES).toContain('@tanstack/vue-devtools')
17 expect(TANSTACK_DEVTOOLS_PACKAGES).toContain('@tanstack/svelte-devtools')
18 expect(TANSTACK_DEVTOOLS_PACKAGES).toContain('@tanstack/angular-devtools')
19 })
20​
21 it('includes the framework-agnostic @tanstack/devtools entry', () => {
22 expect(TANSTACK_DEVTOOLS_PACKAGES).toContain('@tanstack/devtools')
23 })
24})
25​
26describe('isTanStackDevtoolsImport', () => {
27 it('returns true for @tanstack/react-devtools', () => {
28 expect(isTanStackDevtoolsImport('@tanstack/react-devtools')).toBe(true)
29 })
30​
31 it('returns true for @tanstack/devtools', () => {
32 expect(isTanStackDevtoolsImport('@tanstack/devtools')).toBe(true)
33 })
34​
35 it('returns true for every entry in TANSTACK_DEVTOOLS_PACKAGES', () => {
36 for (const pkg of TANSTACK_DEVTOOLS_PACKAGES) {
37 expect(isTanStackDevtoolsImport(pkg)).toBe(true)
38 }
39 })
40​
41 it('returns false for an unrelated package', () => {
42 expect(isTanStackDevtoolsImport('react')).toBe(false)
43 })
44​
45 it('returns false for an empty string', () => {
46 expect(isTanStackDevtoolsImport('')).toBe(false)
47 })
48​
49 it('returns false for a @tanstack package that is not in the devtools list', () => {
50 expect(isTanStackDevtoolsImport('@tanstack/other-thing')).toBe(false)
51 })
52​
53 it('returns false for a prefix-only match (no partial matching)', () => {
54 expect(isTanStackDevtoolsImport('@tanstack/react-devtools/extra')).toBe(
55 false,
56 )
57 })
58})