File: tests/unit/DAV/Entry.test.ts

Recommend this page to a friend!
  Classes of Dom Hastings   JS Webdav Client   tests/unit/DAV/Entry.test.ts   Download  
File: tests/unit/DAV/Entry.test.ts
Role: Example script
Content type: text/plain
Description: Example script
Class: JS Webdav Client
Access files of a Webdav server
Author: By
Last change:
Date: 1 year ago
Size: 2,088 bytes
 

Contents

Class file image Download
import Entry from '../../../src/lib/Entry'; import { trailingSlash } from '../../../src/lib/joinPath'; describe('Entry', () => { const directory = new Entry({ directory: true, fullPath: '/path/to/', modified: Date.now(), }), file = new Entry({ fullPath: '/path/to/file.txt', modified: Date.now(), size: 54321, mimeType: 'text/plain', }), atFile = new Entry({ fullPath: '/%40', modified: Date.now(), size: 54321, mimeType: 'text/plain', }); // directory it('should strip the trailing slash for directories', () => { expect(directory.path).toBe('/path'); expect(directory.name).toBe('to'); }); it('should return an empty size for directories', () => { expect(directory.directory).toBe(true); }); it('should return an empty size for directories', () => { expect(directory.displaySize).toBe(''); }); it('should return a new object on update', () => { expect(directory.update()).not.toBe(directory); }); it('should create the expected parent object', () => { const parent = directory.createParentEntry(); expect(parent.fullPath).toBe(trailingSlash(directory.path)); expect(parent.title).toBe('←'); }); it('should be possible to change the placeholder status', () => { expect(file.placeholder).toBe(false); file.placeholder = true; expect(file.placeholder).toBe(true); }); // file it('should return the expected path', () => { expect(file.path).toBe('/path/to'); }); it('should return the expected filename', () => { expect(file.name).toBe('file.txt'); }); it('should return the expected extension', () => { expect(file.extension).toBe('txt'); }); it('should return the expected type', () => { expect(file.type).toBe('text'); }); it('should return the expected size string', () => { expect(file.displaySize).toBe('53.05 KiB'); }); // atFile it('should correctly decode filenames', () => { expect(atFile.name).toBe('%40'); expect(atFile.title).toBe('@'); }); });