@@ -434,7 +434,7 @@ describe('GithubPackage', function() {
434
434
await contextUpdateAfter ( githubPackage , ( ) => githubPackage . activate ( ) ) ;
435
435
} ) ;
436
436
437
- it ( 'uses an absent repository' , function ( ) {
437
+ it ( 'uses an absent guess repository' , function ( ) {
438
438
assert . isTrue ( githubPackage . getActiveRepository ( ) . isAbsentGuess ( ) ) ;
439
439
} ) ;
440
440
} ) ;
@@ -642,6 +642,10 @@ describe('GithubPackage', function() {
642
642
assert . isTrue ( contextPool . getContext ( nonRepositoryPath ) . isPresent ( ) ) ;
643
643
} ) ;
644
644
645
+ it ( 'is not cached' , async function ( ) {
646
+ assert . isNull ( await githubPackage . workdirCache . find ( nonRepositoryPath ) ) ;
647
+ } ) ;
648
+
645
649
it ( 'uses an empty repository' , function ( ) {
646
650
assert . isTrue ( githubPackage . getActiveRepository ( ) . isEmpty ( ) ) ;
647
651
} ) ;
@@ -980,39 +984,105 @@ describe('GithubPackage', function() {
980
984
} ) ;
981
985
} ) ;
982
986
983
- /*describe('clone', function() {
984
- it('clones into an existing project path', async function() {
985
- const sourcePath = await cloneRepository();
986
- const existingPath = await getTempDir();
987
- project.setPaths([existingPath]);
987
+ describe ( 'clone()' , function ( ) {
988
+ let atomEnv , githubPackage ;
989
+ let workspace , project , commands , notificationManager ;
990
+ let tooltips , deserializers , config , keymaps , styles ;
991
+ let grammars , confirm , configDirPath , getLoadSettings ;
992
+ let renderFn , contextPool , currentWindow ;
993
+ let useLegacyPanels ;
988
994
989
- await contextUpdateAfter(githubPackage, () => githubPackage.activate());
990
- const repository = githubPackage.getActiveRepository();
991
- await repository.getLoadPromise();
992
- assert.isTrue(repository.isEmpty());
995
+ beforeEach ( async function ( ) {
996
+ atomEnv = global . buildAtomEnvironment ( ) ;
997
+ await disableFilesystemWatchers ( atomEnv ) ;
993
998
994
- assert.isNull(await githubPackage.workdirCache.find(existingPath));
999
+ workspace = atomEnv . workspace ;
1000
+ project = atomEnv . project ;
1001
+ commands = atomEnv . commands ;
1002
+ deserializers = atomEnv . deserializers ;
1003
+ notificationManager = atomEnv . notifications ;
1004
+ tooltips = atomEnv . tooltips ;
1005
+ config = atomEnv . config ;
1006
+ keymaps = atomEnv . keymaps ;
1007
+ confirm = atomEnv . confirm . bind ( atomEnv ) ;
1008
+ styles = atomEnv . styles ;
1009
+ grammars = atomEnv . grammars ;
1010
+ getLoadSettings = atomEnv . getLoadSettings . bind ( atomEnv ) ;
1011
+ currentWindow = atomEnv . getCurrentWindow ( ) ;
1012
+ configDirPath = path . join ( __dirname , 'fixtures' , 'atomenv-config' ) ;
1013
+ renderFn = sinon . stub ( ) . callsFake ( ( component , element , callback ) => {
1014
+ if ( callback ) {
1015
+ process . nextTick ( callback ) ;
1016
+ }
1017
+ } ) ;
995
1018
996
- await githubPackage.clone(sourcePath, existingPath) ;
1019
+ useLegacyPanels = ! workspace . getLeftDock ;
997
1020
998
- assert.strictEqual(await githubPackage.workdirCache.find(existingPath), existingPath);
1021
+ githubPackage = new GithubPackage ( {
1022
+ workspace, project, commands, notificationManager, tooltips,
1023
+ styles, grammars, keymaps, config, deserializers, confirm,
1024
+ getLoadSettings, currentWindow, configDirPath, renderFn,
1025
+ } ) ;
1026
+
1027
+ contextPool = githubPackage . getContextPool ( ) ;
999
1028
} ) ;
1000
1029
1001
- it('clones into a new project path', async function() {
1002
- const sourcePath = await cloneRepository();
1003
- const newPath = await getTempDir();
1030
+ afterEach ( async function ( ) {
1031
+ await githubPackage . deactivate ( ) ;
1004
1032
1005
- await contextUpdateAfter(githubPackage, () => githubPackage.activate());
1006
- const original = githubPackage.getActiveRepository();
1007
- await original.getLoadPromise();
1008
- assert.isTrue(original.isAbsentGuess());
1009
- assert.deepEqual(project.getPaths(), []);
1033
+ atomEnv . destroy ( ) ;
1034
+ } ) ;
1010
1035
1011
- await contextUpdateAfter(githubPackage, () => githubPackage.clone(sourcePath, newPath));
1036
+ context ( 'with an existing project' , function ( ) {
1037
+ let existingPath , sourcePath ;
1038
+
1039
+ // Setup files and the GitHub Package
1040
+ beforeEach ( async function ( ) {
1041
+ sourcePath = await cloneRepository ( ) ;
1042
+ existingPath = await getTempDir ( ) ;
1043
+ project . setPaths ( [ existingPath ] ) ;
1044
+
1045
+ await contextUpdateAfter ( githubPackage , ( ) => githubPackage . activate ( ) ) ;
1046
+ const repository = githubPackage . getActiveRepository ( ) ;
1047
+ await repository . getLoadPromise ( ) ;
1048
+ } ) ;
1049
+
1050
+ // Clone
1051
+ beforeEach ( async function ( ) {
1052
+ await githubPackage . clone ( sourcePath , existingPath ) ;
1053
+ } ) ;
1012
1054
1013
- assert.deepEqual(project.getPaths(), [newPath]);
1014
- const replaced = githubPackage.getActiveRepository();
1015
- assert.notStrictEqual(original, replaced);
1055
+ it ( 'clones into the existing project' , async function ( ) {
1056
+ assert . strictEqual ( await githubPackage . workdirCache . find ( existingPath ) , existingPath ) ;
1057
+ } ) ;
1058
+ } ) ;
1059
+
1060
+ context ( 'with no projects' , function ( ) {
1061
+ let newPath , sourcePath , originalRepo ;
1062
+
1063
+ // Setup files and the GitHub Package
1064
+ beforeEach ( async function ( ) {
1065
+ sourcePath = await cloneRepository ( ) ;
1066
+ newPath = await getTempDir ( ) ;
1067
+
1068
+ await contextUpdateAfter ( githubPackage , ( ) => githubPackage . activate ( ) ) ;
1069
+ originalRepo = githubPackage . getActiveRepository ( ) ;
1070
+ await originalRepo . getLoadPromise ( ) ;
1071
+ } ) ;
1072
+
1073
+ // Clone and Update context
1074
+ beforeEach ( async function ( ) {
1075
+ await contextUpdateAfter ( githubPackage , ( ) => githubPackage . clone ( sourcePath , newPath ) ) ;
1076
+ } ) ;
1077
+
1078
+ it ( 'creates a new project' , function ( ) {
1079
+ assert . deepEqual ( project . getPaths ( ) , [ newPath ] ) ;
1080
+ } )
1081
+
1082
+ it ( 'clones into a new project' , function ( ) {
1083
+ const replaced = githubPackage . getActiveRepository ( ) ;
1084
+ assert . notStrictEqual ( originalRepo , replaced ) ;
1085
+ } ) ;
1016
1086
} ) ;
1017
1087
} ) ;
1018
1088
0 commit comments