Skip to content

Commit

Permalink
Adjust after review/discussion.
Browse files Browse the repository at this point in the history
  • Loading branch information
budzanowski committed Dec 12, 2016
1 parent f9aebea commit 5946b8f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
36 changes: 16 additions & 20 deletions client/state/themes/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,27 +422,23 @@ export function installWpcomThemeOnJetpack( siteId, wpcomThemeId ) {
wpcomThemeId
} );

return new Promise( ( resolve, reject ) => {
wpcom.undocumented().installThemeOnJetpack( siteId, wpcomThemeId )
.then( ( theme ) => {
dispatch( receiveTheme( theme ) );
dispatch( {
type: THEME_INSTALL_ON_JETPACK_REQUEST_SUCCESS,
siteId,
wpcomThemeId
} );
resolve();
} )
.catch( ( error ) => {
dispatch( {
type: THEME_INSTALL_ON_JETPACK_REQUEST_FAILURE,
siteId,
wpcomThemeId,
error
} );
reject( error );
return wpcom.undocumented().installThemeOnJetpack( siteId, wpcomThemeId )
.then( ( theme ) => {
dispatch( receiveTheme( theme ) );
dispatch( {
type: THEME_INSTALL_ON_JETPACK_REQUEST_SUCCESS,
siteId,
wpcomThemeId
} );
} );
} )
.catch( ( error ) => {
dispatch( {
type: THEME_INSTALL_ON_JETPACK_REQUEST_FAILURE,
siteId,
wpcomThemeId,
error
} );
} );
};
}

Expand Down
6 changes: 3 additions & 3 deletions client/state/themes/test/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ describe( 'actions', () => {
} );

it( 'should dispatch wpcom theme install request failure action when theme was not found', () => {
installWpcomThemeOnJetpack( 'jetpackenabledsite.com', 'typist-wpcom' )( spy ).then( () => {
return installWpcomThemeOnJetpack( 'jetpackenabledsite.com', 'typist-wpcom' )( spy ).then( () => {
expect( spy ).to.have.been.calledWith( {
type: THEME_INSTALL_ON_JETPACK_REQUEST_FAILURE,
siteId: 'jetpackenabledsite.com',
Expand All @@ -692,11 +692,11 @@ describe( 'actions', () => {
} );

it( 'should dispatch wpcom theme install request failure action when theme is already installed', () => {
installWpcomThemeOnJetpack( 'jetpackenabledsite.com', 'pinboard-wpcom' )( spy ).then( () => {
return installWpcomThemeOnJetpack( 'jetpackenabledsite.com', 'pinboard-wpcom' )( spy ).then( () => {
expect( spy ).to.have.been.calledWith( {
type: THEME_INSTALL_ON_JETPACK_REQUEST_FAILURE,
siteId: 'jetpackenabledsite.com',
themeId: 'pinboard',
wpcomThemeId: 'pinboard-wpcom',
error: sinon.match( { message: 'The theme is already installed' } ),
} );
} );
Expand Down

0 comments on commit 5946b8f

Please sign in to comment.