UNPKG

1.3 kBJavaScriptView Raw
1
2/**
3 * Module dependencies
4 */
5var util = require( './util' );
6var assert = require( 'assert' );
7
8/**
9 * Testing data
10 */
11var fixture = require( './fixture' );
12
13describe( 'wpcom.site.wpcomPlugin', function() {
14 // Global instances
15 var wpcom = util.wpcom();
16 var site = wpcom.site( fixture.site_business );
17
18 // Create a testing_wpcomPlugin before to start tests
19 var testingWPComPlugin;
20 before( done => {
21 site.wpcomPluginsList()
22 .then( res => {
23 var pluginId = res.plugins[0].slug;
24 testingWPComPlugin = site.wpcomPlugin( pluginId );
25 done();
26 } )
27 .catch( done );
28 } );
29
30 describe( 'wpcom.site.wpcomPlugin.activate', function() {
31 it( 'should activate the wpcom plugin', done => {
32 testingWPComPlugin.activate()
33 .then( data => {
34 assert.ok( data );
35 assert.ok( data instanceof Object, 'data is not an object' );
36 assert.equal( data.active, true );
37 done();
38 } )
39 .catch( done );
40 } );
41 } );
42
43 describe( 'wpcom.site.wpcomPlugin.deactivate', function() {
44 it( 'should deactivate the wpcom plugin', done => {
45 testingWPComPlugin.deactivate()
46 .then( data => {
47 assert.ok( data );
48 assert.ok( data instanceof Object, 'data is not an object' );
49 assert.equal( data.active, false );
50 done();
51 } )
52 .catch( done );
53 } );
54 } );
55} );