1+ import { describe , it , expect } from 'vitest' ;
2+ import { getLanguageFromPath } from './getLanguageFromPath' ;
3+
4+ describe ( 'getLanguageFromPath' , ( ) => {
5+ it ( 'should return typescript for .tsx files' , ( ) => {
6+ expect ( getLanguageFromPath ( 'ReactRenders3.tsx' ) ) . toBe ( 'typescript' ) ;
7+ } ) ;
8+
9+ it ( 'should return typescript for .ts files' , ( ) => {
10+ expect ( getLanguageFromPath ( 'component.ts' ) ) . toBe ( 'typescript' ) ;
11+ } ) ;
12+
13+ it ( 'should return javascript for .js files' , ( ) => {
14+ expect ( getLanguageFromPath ( 'script.js' ) ) . toBe ( 'javascript' ) ;
15+ } ) ;
16+
17+ it ( 'should return javascript for .jsx files' , ( ) => {
18+ expect ( getLanguageFromPath ( 'component.jsx' ) ) . toBe ( 'javascript' ) ;
19+ } ) ;
20+
21+ it ( 'should return python for .py files' , ( ) => {
22+ expect ( getLanguageFromPath ( 'script.py' ) ) . toBe ( 'python' ) ;
23+ } ) ;
24+
25+ it ( 'should return go for .go files' , ( ) => {
26+ expect ( getLanguageFromPath ( 'main.go' ) ) . toBe ( 'go' ) ;
27+ } ) ;
28+
29+ it ( 'should return html for .html files' , ( ) => {
30+ expect ( getLanguageFromPath ( 'index.html' ) ) . toBe ( 'html' ) ;
31+ } ) ;
32+
33+ it ( 'should return css for .css files' , ( ) => {
34+ expect ( getLanguageFromPath ( 'styles.css' ) ) . toBe ( 'css' ) ;
35+ } ) ;
36+
37+ it ( 'should return json for .json files' , ( ) => {
38+ expect ( getLanguageFromPath ( 'package.json' ) ) . toBe ( 'json' ) ;
39+ } ) ;
40+
41+ it ( 'should return markdown for .md files' , ( ) => {
42+ expect ( getLanguageFromPath ( 'README.md' ) ) . toBe ( 'markdown' ) ;
43+ } ) ;
44+
45+ it ( 'should return yaml for .yaml files' , ( ) => {
46+ expect ( getLanguageFromPath ( 'config.yaml' ) ) . toBe ( 'yaml' ) ;
47+ } ) ;
48+
49+ it ( 'should return yaml for .yml files' , ( ) => {
50+ expect ( getLanguageFromPath ( 'config.yml' ) ) . toBe ( 'yaml' ) ;
51+ } ) ;
52+
53+ it ( 'should return javascript as fallback for unknown extensions' , ( ) => {
54+ expect ( getLanguageFromPath ( 'file.unknown' ) ) . toBe ( 'javascript' ) ;
55+ } ) ;
56+
57+ it ( 'should return javascript as fallback for files without extension' , ( ) => {
58+ expect ( getLanguageFromPath ( 'README' ) ) . toBe ( 'javascript' ) ;
59+ } ) ;
60+
61+ it ( 'should handle paths with multiple dots' , ( ) => {
62+ expect ( getLanguageFromPath ( 'src/components/MyComponent.tsx' ) ) . toBe ( 'typescript' ) ;
63+ } ) ;
64+
65+ it ( 'should handle case insensitive extensions' , ( ) => {
66+ expect ( getLanguageFromPath ( 'Component.TSX' ) ) . toBe ( 'typescript' ) ;
67+ expect ( getLanguageFromPath ( 'Script.JS' ) ) . toBe ( 'javascript' ) ;
68+ } ) ;
69+ } ) ;
0 commit comments