UNPKG

observable-fs

Version:

Provides as Observables some of the APIs of node fs

29 lines (24 loc) 1.19 kB
import 'mocha'; import { expect } from 'chai'; import { homedir } from 'os'; import { normalizeTilde } from './path'; import path = require('path'); describe('normalizeTilde function', () => { it('substitutes the tilde (~) symbol with the home directory', () => { const dirName = path.join('~', 'aDirPath', 'aSubDirPath'); const expectedNormalizedPath = path.join(homedir(), 'aDirPath', 'aSubDirPath'); const normalizedPath = normalizeTilde(dirName); expect(normalizedPath).equal(expectedNormalizedPath); }); it('substitutes the tilde (~) symbol with the home directory - works also with a trailing slash', () => { const dirName = path.join('~', 'aDirPath', 'aSubDirPath', '/'); const expectedNormalizedPath = path.join(homedir(), 'aDirPath', 'aSubDirPath', '/'); const normalizedPath = normalizeTilde(dirName); expect(normalizedPath).equal(expectedNormalizedPath); }); it('if there is no tilde (~) symbol the same path is returned', () => { const dirName = 'aDirPath/aSubDirPath/'; const normalizedPath = normalizeTilde(dirName); expect(normalizedPath).equal(dirName); }); });