-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use
wp:action-publish
to determine whether to display publish UI (#…
- Loading branch information
1 parent
4bcbe3c
commit ed5a779
Showing
6 changed files
with
38 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,46 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { merge } from 'lodash'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { PublishButtonLabel } from '../label'; | ||
|
||
describe( 'PublishButtonLabel', () => { | ||
const user = { | ||
data: { | ||
id: 1, | ||
post_type_capabilities: { | ||
publish_posts: true, | ||
}, | ||
}, | ||
}; | ||
|
||
const contributor = merge( {}, user, { | ||
data: { | ||
post_type_capabilities: { | ||
publish_posts: false, | ||
}, | ||
}, | ||
} ); | ||
|
||
it( 'should show publishing if publishing in progress', () => { | ||
const label = PublishButtonLabel( { user, isPublishing: true } ); | ||
const label = PublishButtonLabel( { hasPublishAction: true, isPublishing: true } ); | ||
expect( label ).toBe( 'Publishing…' ); | ||
} ); | ||
|
||
it( 'should show updating if published and saving in progress', () => { | ||
const label = PublishButtonLabel( { user, isPublished: true, isSaving: true } ); | ||
const label = PublishButtonLabel( { hasPublishAction: true, isPublished: true, isSaving: true } ); | ||
expect( label ).toBe( 'Updating…' ); | ||
} ); | ||
|
||
it( 'should show scheduling if scheduled and saving in progress', () => { | ||
const label = PublishButtonLabel( { user, isBeingScheduled: true, isSaving: true } ); | ||
const label = PublishButtonLabel( { hasPublishAction: true, isBeingScheduled: true, isSaving: true } ); | ||
expect( label ).toBe( 'Scheduling…' ); | ||
} ); | ||
|
||
it( 'should show publish if not published and saving in progress', () => { | ||
const label = PublishButtonLabel( { user, isPublished: false, isSaving: true } ); | ||
expect( label ).toBe( 'Publish' ); | ||
} ); | ||
|
||
it( 'should show publish if user unknown', () => { | ||
const label = PublishButtonLabel( { user: {} } ); | ||
const label = PublishButtonLabel( { hasPublishAction: true, isPublished: false, isSaving: true } ); | ||
expect( label ).toBe( 'Publish' ); | ||
} ); | ||
|
||
it( 'should show submit for review for contributor', () => { | ||
const label = PublishButtonLabel( { user: contributor } ); | ||
const label = PublishButtonLabel( { hasPublishAction: false } ); | ||
expect( label ).toBe( 'Submit for Review' ); | ||
} ); | ||
|
||
it( 'should show update for already published', () => { | ||
const label = PublishButtonLabel( { user, isPublished: true } ); | ||
const label = PublishButtonLabel( { hasPublishAction: true, isPublished: true } ); | ||
expect( label ).toBe( 'Update' ); | ||
} ); | ||
|
||
it( 'should show schedule for scheduled', () => { | ||
const label = PublishButtonLabel( { user, isBeingScheduled: true } ); | ||
const label = PublishButtonLabel( { hasPublishAction: true, isBeingScheduled: true } ); | ||
expect( label ).toBe( 'Schedule' ); | ||
} ); | ||
|
||
it( 'should show publish otherwise', () => { | ||
const label = PublishButtonLabel( { user } ); | ||
const label = PublishButtonLabel( { hasPublishAction: true } ); | ||
expect( label ).toBe( 'Publish' ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.