Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const Tom = require('test-runner').Tom
const fs = require('fs')
const spawn = require('child_process').spawn
const a = require('assert')
const tom = module.exports = new Tom('cli')
const inputPath = 'test/fixture/ignore.js'
try {
fs.mkdirSync('tmp-test')
} catch (err) {
// dir exists
}
tom.test('cli: json option', function () {
const outputFile = fs.openSync('tmp-test/ignore.json', 'w')
return new Promise((resolve, reject) => {
const handle = spawn(
'node',
['bin/cli.js', '--no-usage-stats', '--no-cache', '--json', inputPath],
{ stdio: ['ignore', outputFile, 'ignore'] }
)
const Tom = require('test-runner').Tom
const jsdoc = require('../')
const Fixture = require('./lib/fixture')
const path = require('path')
const fs = require('fs-then-native')
const a = require('assert')
/* tests need to run sequentially as `jsdoc.cache` is shared between tests */
const tom = module.exports = new Tom('caching', { maxConcurrency: 1 })
tom.test('.explainSync({ files, cache: true })', async function () {
const f = new Fixture('class-all')
jsdoc.cache.dir = 'tmp/test/cache-sync'
await jsdoc.cache.clear()
const output = jsdoc.explainSync({ files: f.sourcePath, cache: true })
const expectedOutput = f.getExpectedOutput(output)
a.ok(typeof output === 'object')
a.deepEqual(output, expectedOutput)
})
tom.test('.explain({ files, cache: true })', async function () {
const f = new Fixture('class-all')
jsdoc.cache.dir = 'tmp/test/cache' + this.index
await jsdoc.cache.clear()
const Tom = require('test-runner').Tom
const t = require('./')
const a = require('assert')
const tom = module.exports = new Tom('typical-v10')
tom.test('.isIterable [v10]', function () {
a.strictEqual(t.isIterable((async function * () {})()), true)
})
const Tom = require('test-runner').Tom
const Table = require('../')
const a = require('assert')
const tom = module.exports = new Tom('bad-input')
tom.test('table.lines(): no data', function () {
let table = new Table([])
a.deepStrictEqual(table.getLines([]), [])
table = new Table([])
a.deepStrictEqual(table.getLines(), [])
})
const Tom = require('test-runner').Tom
const jsdoc = require('../')
const Fixture = require('./lib/fixture')
const fs = require('fs')
const a = require('assert')
const tom = module.exports = new Tom('render-sync')
tom.test('.renderSync({ files })', function () {
Fixture.createTmpFolder('tmp')
Fixture.createTmpFolder('tmp/renderSync')
const f = new Fixture('class-all')
jsdoc.renderSync({ files: f.sourcePath, destination: 'tmp/renderSync/out' })
a.doesNotThrow(function () {
fs.statSync('./tmp/renderSync/out/index.html')
})
})
tom.test('.renderSync({ source, destination })', function () {
Fixture.createTmpFolder('tmp')
Fixture.createTmpFolder('tmp/renderSync')
const f = new Fixture('class-all')
jsdoc.renderSync({ source: f.getSource(), destination: 'tmp/renderSync/out' })
const Tom = require('test-runner').Tom
const jsdoc = require('../')
const Fixture = require('./lib/fixture')
const path = require('path')
const a = require('assert')
const tom = module.exports = new Tom('explain-sync')
tom.test('.explainSync({ files })', function () {
const f = new Fixture('class-all')
const output = jsdoc.explainSync({ files: f.sourcePath })
const expectedOutput = f.getExpectedOutput(output)
a.ok(typeof output === 'object')
a.deepStrictEqual(output, expectedOutput)
})
tom.test('.explainSync({ source })', function () {
const f = new Fixture('class-all')
const output = jsdoc.explainSync({ source: f.getSource() })
const expectedOutput = f.getExpectedOutput(output)
a.ok(typeof output === 'object')
const util = require('../../lib/util')
const a = require('assert')
const os = require('os')
const Tom = require('test-runner').Tom
const tom = module.exports = new Tom('util-win32')
if (os.platform() === 'win32') {
tom.test('util.depthFirstCompare(pathA, pathB) windows 1', function () {
a.deepStrictEqual(util.depthFirstCompare('\\one\\two', '\\one'), -1)
a.deepStrictEqual(util.depthFirstCompare('\\one', '\\one\\two'), 1)
a.deepStrictEqual(util.depthFirstCompare('\\one', '\\one'), 0)
})
tom.test('util.depthFirstCompare(pathA, pathB) windows 2 (cygwin usage)', function () {
a.deepStrictEqual(util.depthFirstCompare('/one/two', '/one'), -1)
a.deepStrictEqual(util.depthFirstCompare('/one', '/one/two'), 1)
a.deepStrictEqual(util.depthFirstCompare('/one', '/one'), 0)
})
}
const Tom = require('test-runner').Tom
const a = require('assert').strict
const Lws = require('../index')
const fetch = require('node-fetch')
const tom = module.exports = new Tom()
tom.test('one middleware', async function () {
const port = 9400 + this.index
class One {
middleware (options) {
return (ctx, next) => {
ctx.body = 'one'
next()
}
}
}
const lws = Lws.create({
stack: [One],
port: port
})
const response = await fetch(`http://127.0.0.1:${port}`)
const Tom = require('test-runner').Tom
const Lws = require('../')
const a = require('assert').strict
const fetch = require('node-fetch')
const tom = module.exports = new Tom()
const https = require('https')
const agent = new https.Agent({
rejectUnauthorized: false
})
tom.test('--https', async function () {
const port = 9200 + this.index
class One {
middleware (options) {
return (ctx, next) => {
ctx.body = 'one'
next()
}
}
}
const Tom = require('test-runner').Tom
const Lws = require('../')
const a = require('assert').strict
const fetch = require('node-fetch')
const tom = module.exports = new Tom()
tom.test('simple http', async function () {
const port = 9100 + this.index
class One {
middleware (options) {
return (ctx, next) => {
ctx.body = 'one'
next()
}
}
}
const lws = Lws.create({
stack: [One],
port: port
})
const response = await fetch(`http://127.0.0.1:${port}`)