tape("configBadChildFileSync", (test) => { test.plan(1); test.throws( function badChildFileCall() { markdownlint.readConfigSync("./test/config/config-badchildfile.json"); }, /ENOENT/, "Did not get correct exception for bad child file." ); test.end(); });
tape("configBadHybridSync", (test) => { test.plan(1); test.throws( function badHybridCall() { markdownlint.readConfigSync( "./test/config/config-badcontent.txt", [ JSON.parse, require("toml").parse, require("js-yaml").safeLoad ]); }, // eslint-disable-next-line max-len /Unable to parse '[^']*'; Unexpected token \S+ in JSON at position \d+; Expected [^;]+ or end of input but "\S+" found.; end of the stream or a document separator is expected at line \d+, column \d+:[^;]*/, "Did not get correct exception for bad content." ); test.end(); });
tape("customRulesOnErrorNull", (test) => { test.plan(1); const options = { "customRules": [ { "names": [ "name" ], "description": "description", "tags": [ "tag" ], "function": function onErrorNull(params, onError) { onError(null); } } ], "strings": { "string": "String" } }; test.throws( function nullErrorCall() { markdownlint.sync(options); }, /Property 'lineNumber' of onError parameter is incorrect./, "Did not get correct exception for null object." ); test.end(); });
"customRules": [ badRule ] }; test.throws( function badRuleCall() { markdownlint.sync(options);
tape("customRulesThrowForFileSync", (test) => { test.plan(1); const exceptionMessage = "Test exception message"; test.throws( function customRuleThrowsCall() { markdownlint.sync({ "customRules": [ { "names": [ "name" ], "description": "description", "tags": [ "tag" ], "function": function throws() { throw new Error(exceptionMessage); } } ], "files": [ "./test/custom-rules.md" ] }); }, new RegExp(exceptionMessage), "Did not get correct exception for function thrown." ); test.end(); });
tape("badFileSync", (test) => { test.plan(1); test.throws( function badFileCall() { markdownlint.sync({ "files": [ "./badFile" ] }); }, /ENOENT/, "Did not get correct exception for bad file." ); test.end(); });
test('required fields', function (t) { t.plan(6) t.throws(createServer.bind(null), TypeError, 'options are required') t.throws(createServer.bind(null, { agreeTos: true }), /Email is required/, 'email is required') t.throws(createServer.bind(null, { email: 'a@b.com' }), /Must agree to LE TOS/, 'tos is required') t.throws(createServer.bind(null, { agreeTos: true, email: 'a@b.com' }), /Domains option must be an array or a function/, 'domains is required') t.throws(createServer.bind(null, { agreeTos: true, email: 'a@b.com', domains: [] }), /You must specify at least one domain/, 'domains is required') createServer({ email: 'a@b.com', agreeTos: true, domains: ['localhost'], // We only use ports here to avoid EACCES. ports: { http: 3000, https: 3001 } }) .once('error', t.fail) .once('listening', function () { this.close() t.pass('server should start') }) })
test.throws( function invalidErrorCall() { markdownlint.sync(options);
test('should delegate checkIntegrity to executable and fail the check', t => { var delegate = new Delegation([ '--integrity', `${path.join(__dirname, 'fixture/md5check.sh')}` ]) delegate.checkIntegrity(path.join(helper.paths.fixture, 'tobeornottobe.txt'), 'foobar', (err, result) => { t.throws(() => { throw err }, /Error: Command failed/) t.deepEqual(result, false) t.end() }) })
test('set/get tts volume undefined', (t) => { t.throws(() => { AudioManager.setVolume(undefined, 1) }, new RegExp('undefined')) t.end() })
test('set/get tts volume string', (t) => { t.plan(1) t.throws(() => { AudioManager.setVolume(AudioManager.STREAM_TTS, 'a') }, /TypeError: vol must be a number/) t.end() })
tape("configBadJsonSync", (test) => { test.plan(1); test.throws( function badJsonCall() { markdownlint.readConfigSync("./test/config/config-badjson.json"); }, /Unable to parse '[^']*'; Unexpected token \S+ in JSON at position \d+/, "Did not get correct exception for bad JSON." ); test.end(); });
tape("configBadChildJsonSync", (test) => { test.plan(1); test.throws( function badChildJsonCall() { markdownlint.readConfigSync("./test/config/config-badchildjson.json"); }, /Unable to parse '[^']*'; Unexpected token \S+ in JSON at position \d+/, "Did not get correct exception for bad child JSON." ); test.end(); });
tape("configBadFileSync", (test) => { test.plan(1); test.throws( function badFileCall() { markdownlint.readConfigSync("./test/config/config-badfile.json"); }, /ENOENT/, "Did not get correct exception for bad file." ); test.end(); });
test.throws( function badErrorCall() { markdownlint.sync(options);