diff --git a/common/cloudfunc.spec.js b/common/cloudfunc.spec.js index 217d9ca5..4e7c2150 100644 --- a/common/cloudfunc.spec.js +++ b/common/cloudfunc.spec.js @@ -1,7 +1,50 @@ 'use strict'; +const {join} = require('path'); +const {readFileSync} = require('fs'); + const test = require('supertape'); -const {_getSize} = require('./cloudfunc'); +const montag = require('montag'); + +const {_getSize, getPathLink} = require('./cloudfunc'); + +const templatePath = join(__dirname, '../tmpl/fs'); +const template = { + pathLink: readFileSync(`${templatePath}/pathLink.hbs`, 'utf8'), +}; + +test('cloudfunc: getPathLink: /', (t) => { + const {pathLink} = template; + const result = getPathLink('/', '', pathLink); + const expected = montag` + / + `; + + t.equal(result, expected); + t.end(); +}); + +test('cloudfunc: getPathLink: /hello/world', (t) => { + const {pathLink} = template; + const result = getPathLink('/hello/world', '', pathLink); + const expected = montag` + /hello/ + `; + + t.equal(result, expected); + t.end(); +}); + +test('cloudfunc: getPathLink: prefix', (t) => { + const {pathLink} = template; + const result = getPathLink('/hello/world', '/cloudcmd', pathLink); + const expected = montag` + /hello/ + `; + + t.equal(result, expected); + t.end(); +}); test('cloudfunc: getSize: dir', (t) => { const type = 'directory';