Jonatan Nilsson
17830d7f8d
All checks were successful
continuous-integration/appveyor/branch AppVeyor build succeeded
36 lines
1 KiB
JavaScript
36 lines
1 KiB
JavaScript
import { Eltro as t, assert} from 'eltro'
|
|
import fs from 'fs/promises'
|
|
import Util from '../core/util.mjs'
|
|
|
|
const isWindows = process.platform === 'win32'
|
|
|
|
t.describe('#getPathFromRoot()', function() {
|
|
t.test('should return file relative to root', async function() {
|
|
var util = new Util(import.meta.url)
|
|
let path = util.getPathFromRoot('')
|
|
if (isWindows) {
|
|
assert.ok(path.endsWith('\\test\\'))
|
|
} else {
|
|
assert.ok(path.endsWith('/test/'))
|
|
}
|
|
|
|
path = util.getPathFromRoot('../core/http.mjs')
|
|
if (isWindows) {
|
|
assert.ok(path.endsWith('\\core\\http.mjs'))
|
|
} else {
|
|
assert.ok(path.endsWith('/core/http.mjs'))
|
|
}
|
|
|
|
let stat = await fs.stat(util.getPathFromRoot('../manage/.gitkeep'))
|
|
assert.strictEqual(stat.size, 0)
|
|
})
|
|
})
|
|
|
|
t.describe('#getUrlFromRoot()', function() {
|
|
t.test('should return an import compatible path', async function() {
|
|
var util = new Util(import.meta.url)
|
|
|
|
let data = await import(util.getUrlFromRoot('template.mjs'))
|
|
assert.deepEqual(data.default, { a: 1 })
|
|
})
|
|
})
|