test('cli errors if legacy --local flag is set', function (t) { const cwd = tempy.directory() writeConfig(cwd, { providers: ['airtap-ignored-foo'], browsers: [{ name: 'test' }] }) exec(`node ${bin} --local test.js`, { env, cwd }, (err, stdout, stderr) => { t.ok(err, 'should error') t.is(stderr.trim(), read('no-local.txt').trim()) t.end() }) })
/** * @param {string} str * @returns {Boolean} */ export function validUsername(str) { const valid_map = ['admin', 'editor'] return valid_map.indexOf(str.trim()) >= 0 }
function isRunning(pid, callback) { pid ? cp.exec(util.format(CHECK_RUNNING_CMD, pid), function (err, stdout, stderr) { callback(!err && !!stdout.toString().trim()); }) : callback(); }
function readFileText(filepath) { try { return fs.readFileSync(filepath, { encoding: 'utf8' }).trim(); } catch(e) {} }
export default function buildUrl(...paths) { const url = new URL( paths .map(p => p && (p + '').trim()) // Trim each string .filter(Boolean) // Remove empty strings or other falsy paths .join('/') ); // Replace 2+ consecutive slashes with 1. (e.g. `///` --> `/`) url.set('pathname', url.pathname.replace(/\/{2,}/g, '/')); return url.href; }
methods.trim().split(/[,;\s|]+/).forEach(function(method) { if (method && method.length <= 36 && !/[^\w.-]/.test(method)) { method = method.toUpperCase(); if (result.indexOf(method) === -1 && --count >= 0) { result.push(method); } } });
test(".MD File (Simple)", () => { //expect.assertions(1); return get("/mdx/heading").then(data => { const $ = cheerio.load(data); expect( $("body h1") .text() .trim() ).toBe("Heading"); }); });
fs.readFileSync(gitignorePath, "utf8") .split(/\r?\n/) .map((sourceLine) => { sourceLine = sourceLine.trim() if (sourceLine !== "") { return sourceLine.startsWith("/") ? sourceLine.slice(1) : "**/" + sourceLine } return sourceLine }) .filter(Boolean)
function getRawType(type) { if (type && typeof type != 'string') { type = type['content-type'] || type.contentType; } return typeof type === 'string' ? type.split(';')[0].trim().toLowerCase() : ''; }
require("child_process").exec(`ps -o comm --no-headers --sort=+pid -g ${pid} | tail -1`, (e, proc) => { if (e !== null) { reject(e); } else { resolve(proc.trim()); } });
columns.forEach((e, i, a) => { if (e && e.trim() === '*') { a[i] = ''; } });
test("React With Helmet", () => { //expect.assertions(1); return get("/react/withhelmet").then(data => { const $ = cheerio.load(data); expect( $("head title") .text() .trim() ).toBe("Page Title"); }); });
test('cli errors if legacy --electron flag is set', function (t) { const cwd = tempy.directory() writeConfig(cwd, { providers: ['airtap-ignored-foo'], browsers: [{ name: 'test' }] }) exec(`node ${bin} --electron test.js`, { env, cwd }, (err, stdout, stderr) => { t.ok(err, 'should error') t.is(stderr.trim(), read('no-electron.txt').trim()) t.end() }) })
export default function buildUrl(...paths) { const url = new URL( paths .map(p => p && (p + '').trim()) // Trim each string .filter(Boolean) // Remove empty strings or other falsy paths .join('/') ); // Replace 2+ consecutive slashes with 1. (e.g. `///` --> `/`) url.set('pathname', url.pathname.replace(/\/{2,}/g, '/')); return url.href; }