Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit c1dabef

Browse files
update with clone tests
1 parent 0140236 commit c1dabef

File tree

1 file changed

+95
-25
lines changed

1 file changed

+95
-25
lines changed

test/github-package.test.js

Lines changed: 95 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ describe('GithubPackage', function() {
434434
await contextUpdateAfter(githubPackage, () => githubPackage.activate());
435435
});
436436

437-
it('uses an absent repository', function() {
437+
it('uses an absent guess repository', function() {
438438
assert.isTrue(githubPackage.getActiveRepository().isAbsentGuess());
439439
});
440440
});
@@ -642,6 +642,10 @@ describe('GithubPackage', function() {
642642
assert.isTrue(contextPool.getContext(nonRepositoryPath).isPresent());
643643
});
644644

645+
it('is not cached', async function() {
646+
assert.isNull(await githubPackage.workdirCache.find(nonRepositoryPath));
647+
});
648+
645649
it('uses an empty repository', function() {
646650
assert.isTrue(githubPackage.getActiveRepository().isEmpty());
647651
});
@@ -980,39 +984,105 @@ describe('GithubPackage', function() {
980984
});
981985
});
982986

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;
988994

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);
993998

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+
});
9951018

996-
await githubPackage.clone(sourcePath, existingPath);
1019+
useLegacyPanels = !workspace.getLeftDock;
9971020

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();
9991028
});
10001029

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();
10041032

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+
});
10101035

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+
});
10121054

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+
});
10161086
});
10171087
});
10181088

0 commit comments

Comments
 (0)