tape("https://github.com/pi-hole/docs", (test) => { const rootDir = "./test-repos/pi-hole-docs"; const globPatterns = [ join(rootDir, "**/*.md") ]; const configPath = join(rootDir, ".markdownlint.json"); lintTestRepo(test, globPatterns, configPath); });
test("fn.toArray", t => { const fn = $.toArray t.deepEqual(fn([]), [], "keeps `[]` as is") t.deepEqual(fn(null), [], "converts `null` to empty array") t.deepEqual(fn(undefined), [], "converts `undefined` to empty array") t.deepEqual(fn(-1), [-1], "converts `-1` to `[-1]`") t.deepEqual(fn(0), [0], "converts `0` to `[0]`") t.deepEqual(fn(1), [1], "converts `1` to `[1]`") t.deepEqual(fn("foo"), ["foo"]) t.deepEqual(fn(["foo"]), ["foo"]) t.end() })
test("Taskr.constructor (exits)", t => { const fn = () => this.plugin("hello", {}, function * () {}) const plugins = { plugins: [fn] } const t1 = new Taskr({ plugins, tasks:['foo'] }) // test for `tasks_force_object` ? t1.on("tasks_force_object", () => console.log('HELLO?')) t.true(!t1.file && !t1.plugins, "exits EARLY if invalid `tasks` type") const t2 = new Taskr({ plugins }) t.true(t2.hasOwnProperty('file') && t2.hasOwnProperty('tasks'), "constructs shape") t.true($.isEmptyObj(t2.plugins), "stops before `plugins` loop if no `tasks` or `file`") t.end() })
test("Taskr.constructor (defaults)", t => { const taskr = new Taskr() t.true(taskr instanceof Taskr, "returns a Taskr class") t.equal(taskr.file, undefined, "`taskr.file` is `undefined`") t.equal(taskr.root, process.cwd(), "`taskr.root` is `process.cwd()`") t.true($.isEmptyObj(taskr.tasks), "`taskr.tasks` is an empty object") t.true($.isEmptyObj(taskr.plugins), "`taskr.plugins` is an empty object") t.true(Array.isArray(taskr.plugNames), "`taskr.plugNames` is an array") t.true(taskr.plugNames.length === 0, "`taskr.plugNames` is empty") t.end() })
test('@taskr/clear: filepath (task)', co(function * (t) { t.plan(2); yield create({ * a(f) { const src = `${dir1}/foo`; yield f.$.write(src); t.true('clear' in f, 'attach `clear` to task instance'); yield f.clear(src); t.false(exists(src), 'file was deleted'); } }).start('a'); }));
test('cli errors if legacy --local and --open flags are set', function (t) { const cwd = tempy.directory() writeConfig(cwd, { providers: ['airtap-ignored-foo'], browsers: [{ name: 'test' }] }) exec(`node ${bin} --local --open test.js`, { env, cwd }, (err, stdout, stderr) => { t.ok(err, 'should error') t.is(stderr.trim(), read('no-local-open.txt').trim()) t.end() }) })