mirror of
https://github.com/noodlapp/noodl.git
synced 2026-01-12 07:12:52 +01:00
Co-Authored-By: Eric Tuvesson <eric.tuvesson@gmail.com> Co-Authored-By: mikaeltellhed <2311083+mikaeltellhed@users.noreply.github.com> Co-Authored-By: kotte <14197736+mrtamagotchi@users.noreply.github.com> Co-Authored-By: Anders Larsson <64838990+anders-topp@users.noreply.github.com> Co-Authored-By: Johan <4934465+joolsus@users.noreply.github.com> Co-Authored-By: Tore Knudsen <18231882+torekndsn@users.noreply.github.com> Co-Authored-By: victoratndl <99176179+victoratndl@users.noreply.github.com>
52 lines
1.7 KiB
TypeScript
52 lines
1.7 KiB
TypeScript
import { app } from '@electron/remote';
|
|
import { Git } from '@noodl/git';
|
|
|
|
import FileSystem from '@noodl-utils/filesystem';
|
|
import { mergeProject } from '@noodl-utils/projectmerger';
|
|
import Utils from '@noodl-utils/utils';
|
|
|
|
describe('Git stash tests', function () {
|
|
let git: Git;
|
|
let tempDir: string | undefined;
|
|
|
|
beforeEach(async function () {
|
|
// Logger.log(`[jest-before]: ${expect.getState().currentTestName}`)
|
|
|
|
tempDir = app.getPath('temp') + '/noodlunittests-git-' + Utils.guid() + '/';
|
|
FileSystem.instance.makeDirectorySync(tempDir);
|
|
|
|
git = new Git(mergeProject);
|
|
await git.initNewRepo(tempDir);
|
|
});
|
|
|
|
afterEach(function (done) {
|
|
// Logger.log(`\r\n[jest-after]: ${expect.getState().currentTestName}`)
|
|
FileSystem.instance.removeDirectoryRecursive(tempDir, done);
|
|
tempDir = undefined;
|
|
});
|
|
|
|
it('stash changes', async function () {
|
|
// cant stash when there are no commits
|
|
FileSystem.instance.writeFileSync(tempDir + 'file.txt', 'text');
|
|
await git.commit('initial commit');
|
|
|
|
FileSystem.instance.writeFileSync(tempDir + 'file1.txt', 'text');
|
|
expect(await git.stashPushChanges()).toBeTruthy();
|
|
|
|
const status1 = await git.status();
|
|
expect(status1).toEqual([]);
|
|
|
|
FileSystem.instance.writeFileSync(tempDir + 'file2.txt', 'text');
|
|
expect(await git.stashPopChanges()).toBe(true);
|
|
|
|
// NOTE: Got some issue on OSX where pop was called using spawn process.
|
|
// OSX didn't seem to like this and ignored the call, changed it to exec.
|
|
|
|
// Calling pop here again makes sure that the previous pop worked.
|
|
expect(await git.stashPopChanges()).toBe(false);
|
|
|
|
const status2 = await git.status();
|
|
expect(status2.length).toEqual(2);
|
|
});
|
|
});
|