@@ -11,6 +11,8 @@ import {multiFilePatchBuilder} from '../builder/patch';
11
11
import Repository from '../../lib/models/repository' ;
12
12
import WorkdirContextPool from '../../lib/models/workdir-context-pool' ;
13
13
import ResolutionProgress from '../../lib/models/conflicts/resolution-progress' ;
14
+ import RemoteSet from '../../lib/models/remote-set' ;
15
+ import Remote from '../../lib/models/remote' ;
14
16
import RefHolder from '../../lib/models/ref-holder' ;
15
17
import { getEndpoint } from '../../lib/models/endpoint' ;
16
18
import GithubLoginModel from '../../lib/models/github-login-model' ;
@@ -626,10 +628,38 @@ describe('RootController', function() {
626
628
publishable = await buildRepository ( await cloneRepository ( ) ) ;
627
629
} ) ;
628
630
629
- it ( 'renders the modal publish dialog' , function ( ) {
630
- const wrapper = shallow ( React . cloneElement ( app , { repository : publishable } ) ) ;
631
+ it ( 'does not register the command while repository data is being fetched' , function ( ) {
632
+ const wrapper = shallow ( app ) ;
633
+ const inner = wrapper . find ( 'ObserveModel' ) . renderProp ( 'children' ) ( null ) ;
634
+ assert . isTrue ( inner . isEmptyRender ( ) ) ;
635
+ } ) ;
636
+
637
+ it ( 'does not register the command when the repository is not publishable' , function ( ) {
638
+ const wrapper = shallow ( app ) ;
639
+ const inner = wrapper . find ( 'ObserveModel' ) . renderProp ( 'children' ) ( { isPublishable : false } ) ;
640
+ assert . isTrue ( inner . isEmptyRender ( ) ) ;
641
+ } ) ;
642
+
643
+ it ( 'does not register the command when the repository already has a GitHub remote' , function ( ) {
644
+ const remotes = new RemoteSet ( [
645
+ new Remote ( 'origin' , '[email protected] :atom/github' ) ,
646
+ ] ) ;
647
+
648
+ const wrapper = shallow ( app ) ;
649
+ const inner = wrapper . find ( 'ObserveModel' ) . renderProp ( 'children' ) ( { isPublishable : true , remotes} ) ;
650
+ assert . isTrue ( inner . isEmptyRender ( ) ) ;
651
+ } ) ;
652
+
653
+ it ( 'renders the modal publish dialog' , async function ( ) {
654
+ const wrapper = shallow ( app ) ;
655
+ const observer = wrapper . find ( 'ObserveModel' ) ;
656
+
657
+ const payload = await observer . prop ( 'fetchData' ) ( publishable ) ;
658
+ assert . isTrue ( payload . isPublishable ) ;
659
+ assert . isTrue ( payload . remotes . filter ( each => each . isGithubRepo ( ) ) . isEmpty ( ) ) ;
660
+ const inner = observer . renderProp ( 'children' ) ( payload ) ;
631
661
632
- wrapper . find ( 'Command[command="github:publish-repository"]' ) . prop ( 'callback' ) ( ) ;
662
+ inner . find ( 'Command[command="github:publish-repository"]' ) . prop ( 'callback' ) ( ) ;
633
663
assert . strictEqual ( wrapper . find ( 'DialogsController' ) . prop ( 'request' ) . identifier , 'publish' ) ;
634
664
} ) ;
635
665
@@ -651,8 +681,11 @@ describe('RootController', function() {
651
681
sinon . stub ( publishable , 'push' ) . resolves ( ) ;
652
682
653
683
const wrapper = shallow ( React . cloneElement ( app , { repository : publishable } ) ) ;
654
-
655
- wrapper . find ( 'Command[command="github:publish-repository"]' ) . prop ( 'callback' ) ( ) ;
684
+ const inner = wrapper . find ( 'ObserveModel' ) . renderProp ( 'children' ) ( {
685
+ isPublishable : true ,
686
+ remotes : new RemoteSet ( ) ,
687
+ } ) ;
688
+ inner . find ( 'Command[command="github:publish-repository"]' ) . prop ( 'callback' ) ( ) ;
656
689
657
690
const req0 = wrapper . find ( 'DialogsController' ) . prop ( 'request' ) ;
658
691
await req0 . accept ( {
@@ -676,7 +709,11 @@ describe('RootController', function() {
676
709
677
710
it ( 'dismisses the CreateDialog on cancel' , function ( ) {
678
711
const wrapper = shallow ( React . cloneElement ( app , { repository : publishable } ) ) ;
679
- wrapper . find ( 'Command[command="github:publish-repository"]' ) . prop ( 'callback' ) ( ) ;
712
+ const inner = wrapper . find ( 'ObserveModel' ) . renderProp ( 'children' ) ( {
713
+ isPublishable : true ,
714
+ remotes : new RemoteSet ( ) ,
715
+ } ) ;
716
+ inner . find ( 'Command[command="github:publish-repository"]' ) . prop ( 'callback' ) ( ) ;
680
717
681
718
const req0 = wrapper . find ( 'DialogsController' ) . prop ( 'request' ) ;
682
719
req0 . cancel ( ) ;
@@ -685,19 +722,6 @@ describe('RootController', function() {
685
722
const req1 = wrapper . find ( 'DialogsController' ) . prop ( 'request' ) ;
686
723
assert . strictEqual ( req1 , dialogRequests . null ) ;
687
724
} ) ;
688
-
689
- it ( 'does not render the command if the current repository is absent' , function ( ) {
690
- const repository = Repository . absent ( ) ;
691
- const wrapper = shallow ( React . cloneElement ( app , { repository} ) ) ;
692
- assert . isFalse ( wrapper . exists ( 'Command[command="github:publish-repository"]' ) ) ;
693
- } ) ;
694
-
695
- it ( 'does not render the command if the current repository is empty' , async function ( ) {
696
- const emptyWorkdir = temp . mkdirSync ( { prefix : 'rootctrl-' } ) ;
697
- const repository = await buildRepository ( emptyWorkdir ) ;
698
- const wrapper = shallow ( React . cloneElement ( app , { repository} ) ) ;
699
- assert . isFalse ( wrapper . exists ( 'Command[command="github:publish-repository"]' ) ) ;
700
- } ) ;
701
725
} ) ;
702
726
703
727
describe ( 'openFiles(filePaths)' , ( ) => {
0 commit comments