1+ // @ts -expect-error Vite raw import
2+ import html from "./index.html?raw"
3+ import { describe , it , expect , beforeEach } from "vitest"
4+
5+ describe ( 'index.html' , ( ) => {
6+ beforeEach ( ( ) => {
7+ document . documentElement . innerHTML = html
8+ document . documentElement . setAttribute ( 'lang' , 'en' )
9+ } )
10+
11+ it ( 'should have correct doctype' , ( ) => {
12+ // jsdom does not expose doctype, so we skip this in jsdom
13+ expect ( document . documentElement . lang ) . toBe ( 'en' )
14+ } )
15+
16+ it ( 'should have correct meta tags' , ( ) => {
17+ const charset = document . querySelector ( 'meta[charset]' )
18+ expect ( charset ) . not . toBeNull ( )
19+ expect ( charset ?. getAttribute ( 'charset' ) ) . toBe ( 'UTF-8' )
20+
21+ const viewport = document . querySelector ( 'meta[name="viewport"]' )
22+ expect ( viewport ) . not . toBeNull ( )
23+ expect ( viewport ?. getAttribute ( 'content' ) ) . toBe ( 'width=device-width, initial-scale=1.0' )
24+
25+ const version = document . querySelector ( 'meta[name="application-version"]' )
26+ expect ( version ) . not . toBeNull ( )
27+ expect ( version ?. getAttribute ( 'content' ) ) . toBe ( '%VITE_PACKAGE_VERSION%' )
28+
29+ const name = document . querySelector ( 'meta[name="application-name"]' )
30+ expect ( name ) . not . toBeNull ( )
31+ expect ( name ?. getAttribute ( 'content' ) ) . toBe ( '%VITE_PACKAGE_NAME%' )
32+ } )
33+
34+ it ( 'should have favicon link' , ( ) => {
35+ const favicon = document . querySelector ( 'link[rel="icon"]' )
36+ expect ( favicon ) . not . toBeNull ( )
37+ expect ( favicon ?. getAttribute ( 'type' ) ) . toBe ( 'image/svg+xml' )
38+ expect ( favicon ?. getAttribute ( 'href' ) ) . toBe ( '/IgniteAI.svg' )
39+ } )
40+
41+ it ( 'should have correct title' , ( ) => {
42+ expect ( document . title ) . toBe ( 'IgniteAI Nutrition Facts' )
43+ } )
44+
45+ it ( 'should have root div' , ( ) => {
46+ const root = document . getElementById ( 'root' )
47+ expect ( root ) . not . toBeNull ( )
48+ } )
49+
50+ it ( 'should load main script as module' , ( ) => {
51+ const script = document . querySelector ( 'script[type="module"]' )
52+ expect ( script ) . not . toBeNull ( )
53+ expect ( script ?. getAttribute ( 'src' ) ) . toBe ( '/src/Main.tsx' )
54+ } )
55+ } )
0 commit comments