Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

file.test.ts 1.2 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
  1. import { isJavascriptFile } from '../../src/util/file';
  2. describe('util', () => {
  3. beforeEach(() => {
  4. jest.clearAllMocks();
  5. });
  6. describe('isJavascriptFile', () => {
  7. it('should return true for JavaScript files', () => {
  8. expect(isJavascriptFile('file.js')).toBe(true);
  9. expect(isJavascriptFile('file.cjs')).toBe(true);
  10. expect(isJavascriptFile('file.mjs')).toBe(true);
  11. });
  12. it('should return true for TypeScript files', () => {
  13. expect(isJavascriptFile('file.ts')).toBe(true);
  14. expect(isJavascriptFile('file.cts')).toBe(true);
  15. expect(isJavascriptFile('file.mts')).toBe(true);
  16. });
  17. it('should return false for non-JavaScript/TypeScript files', () => {
  18. expect(isJavascriptFile('file.txt')).toBe(false);
  19. expect(isJavascriptFile('file.py')).toBe(false);
  20. expect(isJavascriptFile('file.jsx')).toBe(false);
  21. expect(isJavascriptFile('file.tsx')).toBe(false);
  22. });
  23. it('should handle paths with directories', () => {
  24. expect(isJavascriptFile('/path/to/file.js')).toBe(true);
  25. expect(isJavascriptFile('C:\\path\\to\\file.ts')).toBe(true);
  26. expect(isJavascriptFile('/path/to/file.txt')).toBe(false);
  27. });
  28. });
  29. });
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...