tape("missingFilesAndStrings", (test) => { test.plan(2); markdownlint({}, function callback(err, result) { test.ifError(err); test.ok(result, "Did not get result for missing files/strings."); test.end(); }); });
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() }) })
test('listen on invalid port without callback rejects', t => { const fastify = Fastify() t.tearDown(fastify.close.bind(fastify)) return fastify.listen(-1) .catch(err => { t.ok(err) return true }) })
describe( 'wpcom.site.statsPublicize', function () { it( 'should request publicize data', ( done ) => { site .statsPublicize() .then( ( data ) => { assert.equal( 'string', typeof Date( data.day ) ); assert.ok( data.services instanceof Array ); done(); } ) .catch( done ); } ); } );
test('Should throw on duplicate reply decorator', t => { t.plan(1) const fastify = Fastify() const fooObj = {} fastify.decorateReply('foo', fooObj) try { fastify.decorateReply('foo', fooObj) t.fail() } catch (e) { t.ok(/has already been added/.test(e.message)) } })
describe( 'wpcom.site.post.comment.like.delete', function () { it( 'should remove your like from the comment', function ( done ) { testing_comment.like().del( function ( err, data ) { if ( err ) throw err; assert.ok( data ); assert.ok( data.success ); assert.equal( 0, data.like_count ); assert.ok( ! data.i_like ); done(); } ); } ); } );
test('Get serializerCompiler after setSerializerCompiler', t => { t.plan(2) const myCompiler = () => { } const fastify = Fastify() fastify.setSerializerCompiler(myCompiler) const sc = fastify.serializerCompiler t.ok(Object.is(myCompiler, sc)) fastify.ready(err => t.error(err)) })
tape("configBadFile", (test) => { test.plan(4); markdownlint.readConfig("./test/config/config-badfile.json", function callback(err, result) { test.ok(err, "Did not get an error for bad file."); test.ok(err instanceof Error, "Error not instance of Error."); // @ts-ignore test.equal(err.code, "ENOENT", "Error code for bad file not ENOENT."); test.ok(!result, "Got result for bad file."); test.end(); }); });
test('if a plugin raises an error and there is not a callback to handle it, the server must not start', t => { t.plan(2) const fastify = Fastify() fastify.register((instance, opts, next) => { next(new Error('err')) }) fastify.listen(0, err => { t.ok(err instanceof Error) t.is(err.message, 'err') }) })
test('Should throw if the basic use API has not been overridden', t => { t.plan(1) const fastify = Fastify() try { fastify.use() t.fail('Should throw') } catch (err) { t.ok(err instanceof FST_ERR_MISSING_MIDDLEWARE) } })
tape("configBadChildJson", (test) => { test.plan(3); markdownlint.readConfig("./test/config/config-badchildjson.json", function callback(err, result) { test.ok(err, "Did not get an error for bad child JSON."); test.ok(err instanceof Error, "Error not instance of Error."); test.ok(!result, "Got result for bad child JSON."); test.end(); }); });
describe( 'wpcom.site.statsTags', function () { it( 'should request tag data', ( done ) => { site .statsTags() .then( ( data ) => { assert.equal( 'string', typeof Date( data.day ) ); assert.ok( data.tags instanceof Array ); done(); } ) .catch( done ); } ); } );