1 import { SupportedProtonDocsMimeTypes } from '@proton/shared/lib/drive/constants'
2 import { getNodeNameWithoutExtension } from './Title'
3 import type { DecryptedNode } from '@proton/drive-store/lib'
5 const mockDecryptedNode = (name: string, mimeType: any) => ({ name, mimeType }) as DecryptedNode
7 describe('getNodeNameWithoutExtension', () => {
8 it('should return the node name without the .md extension', () => {
9 const node = mockDecryptedNode('document.md', SupportedProtonDocsMimeTypes.md)
10 expect(getNodeNameWithoutExtension(node)).toBe('document')
13 it('should return the node name without the .docx extension', () => {
14 const node = mockDecryptedNode('document.docx', SupportedProtonDocsMimeTypes.docx)
15 expect(getNodeNameWithoutExtension(node)).toBe('document')
18 it('should return the node name without the .html extension', () => {
19 const node = mockDecryptedNode('document.html', SupportedProtonDocsMimeTypes.html)
20 expect(getNodeNameWithoutExtension(node)).toBe('document')
23 it('should return the node name without the .txt extension by default', () => {
24 const node = mockDecryptedNode('document.txt', 'unknown/mimetype')
25 expect(getNodeNameWithoutExtension(node)).toBe('document')
28 it('should return the node name as is if it does not have the expected extension', () => {
29 const node = mockDecryptedNode('document', SupportedProtonDocsMimeTypes.md)
30 expect(getNodeNameWithoutExtension(node)).toBe('document')
33 it('should handle edge case with no extension correctly', () => {
34 const node = mockDecryptedNode('document', 'unknown/mimetype')
35 expect(getNodeNameWithoutExtension(node)).toBe('document')
38 it('should handle different extensions correctly', () => {
39 const node = mockDecryptedNode('document.other', SupportedProtonDocsMimeTypes.md)
40 expect(getNodeNameWithoutExtension(node)).toBe('document.other')