1 |
|
2 |
|
3 |
|
4 | var util = require( './util' );
|
5 | var assert = require( 'assert' );
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | describe( 'wpcom.me', function() {
|
11 |
|
12 | var wpcom = util.wpcom();
|
13 | var me = wpcom.me();
|
14 |
|
15 | describe( 'wpcom.me.billingHistory', function() {
|
16 | it( 'should require billing history', function( done ) {
|
17 | me.billingHistory( function( err, data ) {
|
18 | if ( err ) throw err;
|
19 |
|
20 | assert.ok( data );
|
21 | assert.equal( 'object', typeof data.billing_history );
|
22 | assert.ok( data.billing_history instanceof Array );
|
23 |
|
24 | assert.equal( 'object', typeof data.upcoming_charges );
|
25 | assert.ok( data.upcoming_charges instanceof Array );
|
26 |
|
27 | done();
|
28 | } );
|
29 | } );
|
30 | } );
|
31 |
|
32 | describe( 'wpcom.me.get', function() {
|
33 | it( 'should require user information object', done => {
|
34 | me.get()
|
35 | .then( data => {
|
36 |
|
37 | assert.ok( data );
|
38 | assert.equal( 'object', typeof data );
|
39 |
|
40 |
|
41 | assert.equal( 'number', typeof data.ID );
|
42 |
|
43 | done();
|
44 | } )
|
45 | .catch( done );
|
46 | } );
|
47 |
|
48 | it( 'should require user passing query parameter', done => {
|
49 | me.get( { context: 'info' } )
|
50 | .then( data => {
|
51 |
|
52 | assert.ok( me );
|
53 | assert.equal( 'object', typeof data );
|
54 |
|
55 |
|
56 | assert.equal( 'number', typeof data.ID );
|
57 |
|
58 | done();
|
59 | } )
|
60 | .catch( done );
|
61 | } );
|
62 | } );
|
63 |
|
64 | describe( 'wpcom.me.groups', function() {
|
65 | it( 'should require groups', done => {
|
66 | me.groups()
|
67 | .then( data => {
|
68 | assert.equal( 'object', typeof data.groups );
|
69 | assert.ok( data.groups instanceof Array );
|
70 |
|
71 | done();
|
72 | } )
|
73 | .catch( done );
|
74 | } );
|
75 | } );
|
76 |
|
77 | describe( 'wpcom.me.keyringConnections', function() {
|
78 | it( 'should get current user\' keyring connections', done => {
|
79 | me.keyringConnections()
|
80 | .then( data => {
|
81 | assert.ok( data );
|
82 | assert.ok( data.connections instanceof Array );
|
83 | done();
|
84 | } )
|
85 | .catch( done );
|
86 | } );
|
87 | } );
|
88 |
|
89 | describe( 'wpcom.me.likes', function() {
|
90 | it( 'should require user likes', done => {
|
91 | me.likes()
|
92 | .then( data => {
|
93 | assert.equal( 'number', typeof data.found );
|
94 | assert.equal( 'object', typeof data.likes );
|
95 | assert.ok( data.likes instanceof Array );
|
96 |
|
97 | done();
|
98 | } )
|
99 | .catch( done );
|
100 | } );
|
101 | } );
|
102 |
|
103 | describe( 'wpcom.me.postsList', function() {
|
104 | it( 'should get posts list that current user belongs to', function( done ) {
|
105 | me.postsList()
|
106 | .then( data => {
|
107 | assert.equal( 'number', typeof data.found );
|
108 | assert.equal( 'object', typeof data.meta );
|
109 | assert.ok( data.posts instanceof Array );
|
110 | done();
|
111 | } )
|
112 | .catch( done );
|
113 | } );
|
114 | } );
|
115 |
|
116 | describe( 'wpcom.me.publicizeConnections', function() {
|
117 | it( 'should get current user\' publicize connections', done => {
|
118 | me.publicizeConnections()
|
119 | .then( data => {
|
120 | assert.ok( data );
|
121 | assert.ok( data.connections instanceof Array );
|
122 | done();
|
123 | } )
|
124 | .catch( done );
|
125 | } );
|
126 | } );
|
127 |
|
128 | describe( 'wpcom.me.sites', function() {
|
129 | it( 'should require user sites object', done => {
|
130 | me.sites()
|
131 | .then( () => done() )
|
132 | .catch( done );
|
133 | } );
|
134 | } );
|
135 | } );
|