@@ -830,7 +830,10 @@ describe('GithubPackage', function() {
830
830
831
831
fs . writeFileSync ( path . join ( workdirPath1 , 'c.txt' ) , 'ch-ch-ch-changes' , 'utf8' ) ;
832
832
fs . writeFileSync ( path . join ( workdirPath2 , 'c.txt' ) , 'ch-ch-ch-changes' , 'utf8' ) ;
833
+ } ) ;
833
834
835
+ // Setup up GitHub Package and file watchers
836
+ beforeEach ( async function ( ) {
834
837
project . setPaths ( [ workdirPath1 , workdirPath2 ] ) ;
835
838
await githubPackage . activate ( ) ;
836
839
@@ -845,7 +848,10 @@ describe('GithubPackage', function() {
845
848
}
846
849
847
850
await Promise . all ( watcherPromises ) ;
851
+ } ) ;
848
852
853
+ // Stub the repositories functions
854
+ beforeEach ( function ( ) {
849
855
[ atomGitRepository1 , atomGitRepository2 ] = githubPackage . project . getRepositories ( ) ;
850
856
sinon . stub ( atomGitRepository1 , 'refreshStatus' ) ;
851
857
sinon . stub ( atomGitRepository2 , 'refreshStatus' ) ;
@@ -856,11 +862,17 @@ describe('GithubPackage', function() {
856
862
sinon . stub ( repository2 , 'observeFilesystemChange' ) ;
857
863
} ) ;
858
864
865
+ // Destroy Atom Environment and the GitHub Package
866
+ afterEach ( async function ( ) {
867
+ await githubPackage . deactivate ( ) ;
868
+
869
+ atomEnv . destroy ( ) ;
870
+ } ) ;
871
+
859
872
it ( 'refreshes the appropriate Repository and Atom GitRepository when a file is changed in workspace 1' , async function ( ) {
860
873
if ( process . platform === 'linux' ) {
861
874
this . skip ( ) ;
862
875
}
863
- this . retries ( 5 ) ; // FLAKE
864
876
865
877
fs . writeFileSync ( path . join ( workdirPath1 , 'a.txt' ) , 'some changes' , 'utf8' ) ;
866
878
@@ -872,7 +884,6 @@ describe('GithubPackage', function() {
872
884
if ( process . platform === 'linux' ) {
873
885
this . skip ( ) ;
874
886
}
875
- this . retries ( 5 ) ; // FLAKE
876
887
877
888
fs . writeFileSync ( path . join ( workdirPath2 , 'b.txt' ) , 'other changes' , 'utf8' ) ;
878
889
@@ -895,24 +906,77 @@ describe('GithubPackage', function() {
895
906
} ) ;
896
907
} ) ;
897
908
898
- /*describe('initialize', function() {
899
- it('creates and sets a repository for the given project path', async function() {
900
- const nonRepositoryPath = await getTempDir();
901
- project.setPaths([nonRepositoryPath]);
909
+ describe ( 'initialize()' , function ( ) {
910
+ let atomEnv , githubPackage ;
911
+ let workspace , project , commands , notificationManager ;
912
+ let tooltips , deserializers , config , keymaps , styles ;
913
+ let grammars , confirm , configDirPath , getLoadSettings ;
914
+ let renderFn , contextPool , currentWindow ;
915
+ let useLegacyPanels ;
902
916
903
- await contextUpdateAfter(githubPackage, () => githubPackage.activate());
904
- await githubPackage.getActiveRepository().getLoadPromise();
917
+ beforeEach ( async function ( ) {
918
+ atomEnv = global . buildAtomEnvironment ( ) ;
919
+ await disableFilesystemWatchers ( atomEnv ) ;
920
+
921
+ workspace = atomEnv . workspace ;
922
+ project = atomEnv . project ;
923
+ commands = atomEnv . commands ;
924
+ deserializers = atomEnv . deserializers ;
925
+ notificationManager = atomEnv . notifications ;
926
+ tooltips = atomEnv . tooltips ;
927
+ config = atomEnv . config ;
928
+ keymaps = atomEnv . keymaps ;
929
+ confirm = atomEnv . confirm . bind ( atomEnv ) ;
930
+ styles = atomEnv . styles ;
931
+ grammars = atomEnv . grammars ;
932
+ getLoadSettings = atomEnv . getLoadSettings . bind ( atomEnv ) ;
933
+ currentWindow = atomEnv . getCurrentWindow ( ) ;
934
+ configDirPath = path . join ( __dirname , 'fixtures' , 'atomenv-config' ) ;
935
+ renderFn = sinon . stub ( ) . callsFake ( ( component , element , callback ) => {
936
+ if ( callback ) {
937
+ process . nextTick ( callback ) ;
938
+ }
939
+ } ) ;
940
+
941
+ useLegacyPanels = ! workspace . getLeftDock ;
942
+
943
+ githubPackage = new GithubPackage ( {
944
+ workspace, project, commands, notificationManager, tooltips,
945
+ styles, grammars, keymaps, config, deserializers, confirm,
946
+ getLoadSettings, currentWindow, configDirPath, renderFn,
947
+ } ) ;
905
948
906
- assert.isTrue( githubPackage.getActiveRepository().isEmpty() );
907
- assert.isFalse(githubPackage.getActiveRepository().isAbsent() );
949
+ contextPool = githubPackage . getContextPool ( ) ;
950
+ } ) ;
908
951
909
- await githubPackage.initialize(nonRepositoryPath);
952
+ afterEach ( async function ( ) {
953
+ await githubPackage . deactivate ( ) ;
910
954
911
- assert.isTrue(githubPackage.getActiveRepository().isPresent());
912
- assert.strictEqual(
913
- githubPackage.getActiveRepository(),
914
- await contextPool.getContext(nonRepositoryPath).getRepository(),
915
- );
955
+ atomEnv . destroy ( ) ;
956
+ } ) ;
957
+
958
+ context ( 'with a non-repository project' , function ( ) {
959
+ let nonRepositoryPath ;
960
+ beforeEach ( async function ( ) {
961
+ nonRepositoryPath = await getTempDir ( ) ;
962
+ project . setPaths ( [ nonRepositoryPath ] ) ;
963
+
964
+ await contextUpdateAfter ( githubPackage , ( ) => githubPackage . activate ( ) ) ;
965
+ await githubPackage . getActiveRepository ( ) . getLoadPromise ( ) ;
966
+
967
+ await githubPackage . initialize ( nonRepositoryPath ) ;
968
+ } ) ;
969
+
970
+ it ( 'creates a repository for the project' , function ( ) {
971
+ assert . isTrue ( githubPackage . getActiveRepository ( ) . isPresent ( ) ) ;
972
+ } ) ;
973
+
974
+ it ( 'uses the newly created repository for the project' , async function ( ) {
975
+ assert . strictEqual (
976
+ githubPackage . getActiveRepository ( ) ,
977
+ await contextPool . getContext ( nonRepositoryPath ) . getRepository ( ) ,
978
+ ) ;
979
+ } ) ;
916
980
} ) ;
917
981
} ) ;
918
982
0 commit comments