UNPKG

1.41 kBJavaScriptView Raw
1/**
2 * Module dependencies
3 */
4var util = require( './util' );
5var assert = require( 'assert' );
6
7/**
8 * Testing data
9 */
10var fixture = require( './fixture' );
11
12describe( 'wpcom', function() {
13 // Global instances
14 var wpcom = util.wpcom();
15 var site = wpcom.site( util.site() );
16 var testing_post;
17
18 describe( 'wpcom.util.req.post', function() {
19 describe( 'create a post without query {} and body {}', function() {
20 it( 'should get 400 error code', function( done ) {
21 var path = '/sites/' + site._id + '/posts/new';
22 wpcom.req.post( path )
23 .then( () => done( 'No error returned' ) )
24 .catch( err=>{
25 assert.ok( err );
26 assert.equal( 400, err.statusCode );
27 done();
28 } );
29 } );
30 } );
31
32 describe( 'create a post without query {}', function() {
33 it( 'should create a new post', function( done ) {
34 var path = '/sites/' + site._id + '/posts/new';
35 wpcom.req.post( path, null, fixture.post )
36 .then( data => {
37 testing_post = data;
38 assert.ok( data );
39 done();
40 } )
41 .catch( done );
42 } );
43 } );
44 } );
45
46 describe( 'wpcom.util.req.del', function() {
47 it( 'should delete added post', function( done ) {
48 var path = '/sites/' + site._id + '/posts/' + testing_post.ID + '/delete';
49 wpcom.req.post( path )
50 .then( data => {
51 assert.ok( data.ID, testing_post.ID );
52 done();
53 } )
54 .catch( done );
55 } );
56 } );
57} );