describe( 'wpcom.site.postTypesList', function () { it( 'should get post types list of the site', function ( done ) { site .postTypesList() .then( ( data ) => { assert.ok( data.found >= 1 ); assert.ok( data.post_types instanceof Array ); done(); } ) .catch( done ); } ); } );
after( function ( done ) { // delete testing_post post testing_post.delete( function ( err ) { if ( err ) throw err; done(); } ); } );
server.addHook('preHandler', (request, reply, done) => { expectType<FastifyRequest>(request) expectType<FastifyReply>(reply) expectAssignable<(err?: FastifyError) => void>(done) expectAssignable<(err?: NodeJS.ErrnoException) => void>(done) expectType<void>(done(new Error())) })
it("createdAt doesn't change", function(done) { const object = new TestObject({ foo: 'bar' }); object.save().then(function() { const objectAgain = new TestObject(); objectAgain.id = object.id; objectAgain.fetch().then(function() { equal(object.createdAt.getTime(), objectAgain.createdAt.getTime()); done(); }); }); });
it('invalid key name', function(done) { const item = new Parse.Object('Item'); ok( !item.set({ 'foo^bar': 'baz' }), 'Item should not be updated with invalid key.' ); item.save({ 'foo^bar': 'baz' }).then(fail, () => done()); });
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(); } ); } ); } );
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 ); } ); } );
it('toJSON saved object', function(done) { create({ foo: 'bar' }, function(model) { const objJSON = model.toJSON(); ok(objJSON.foo, "expected json to contain key 'foo'"); ok(objJSON.objectId, "expected json to contain key 'objectId'"); ok(objJSON.createdAt, "expected json to contain key 'createdAt'"); ok(objJSON.updatedAt, "expected json to contain key 'updatedAt'"); done(); }); });
it('save adds no data keys (other than createdAt and updatedAt)', function(done) { const object = new TestObject(); object.save().then(function() { const keys = Object.keys(object.attributes).sort(); equal(keys.length, 2); done(); }); });
it('destroyAll no objects', function(done) { Parse.Object.destroyAll([]) .then(function(success) { ok(success, 'Should be able to destroy no objects'); done(); }) .catch(done.fail); });
describe( 'wpcom.site.media.delete', function () { it( 'should delete a media', ( done ) => { site .media( testing_media.ID ) .del() .then( ( data ) => { assert.equal( testing_media.ID, data.ID ); done(); } ) .catch( done ); } ); } );
describe( 'wpcom.site.post.comment.like.add', function () { it( 'should add a comment like', function ( done ) { testing_comment.like().add( function ( err, data ) { if ( err ) throw err; assert.ok( data ); assert.equal( 1, data.like_count ); assert.ok( data.i_like ); done(); } ); } ); } );
describe( 'wpcom.site.get', function () { it( 'should require site data', ( done ) => { site .get() .then( ( data ) => { assert.equal( 'number', typeof data.ID ); assert.equal( 'string', typeof data.name ); done(); } ) .catch( done ); } ); } );
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 ); } ); } );