{"size": 1326, "ext": "js", "max_stars_repo_path": "spec/git/status-spec.js", "max_stars_repo_name": "aagerblad/git-menu", "max_stars_repo_stars_event_min_datetime": "2019-02-18T07:44:07.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-28T03:41:53.000Z", "max_issues_repo_path": "spec/git/status-spec.js", "max_issues_repo_name": "aagerblad/git-menu", "max_issues_repo_issues_event_min_datetime": "2018-10-31T18:37:52.000Z", "max_issues_repo_issues_event_max_datetime": "2021-11-06T02:53:16.000Z", "max_forks_repo_path": "spec/git/status-spec.js", "max_forks_repo_name": "aagerblad/git-menu", "max_forks_repo_forks_event_min_datetime": "2019-08-05T10:53:12.000Z", "max_forks_repo_forks_event_max_datetime": "2021-08-02T14:10:49.000Z"}
{"max_stars_count": 12, "max_issues_count": 248, "max_forks_count": 7, "avg_line_length": 34.8947368421, "max_line_length": 135, "alphanum_fraction": 0.6907993967}
/** @babel */

import gitCmd from "../../lib/git-cmd";
import {getFilePath, removeGitRoot, createGitRoot, files} from "../mocks";

describe("git.status", function () {

	beforeEach(async function () {
		await atom.packages.activatePackage("git-menu");
		this.gitRoot = await createGitRoot();

		this.gitPath = getFilePath(this.gitRoot, ".git");
	});

	afterEach(async function () {
		await removeGitRoot(this.gitRoot);
	});

	it("should return status of t1", async function () {
		await gitCmd.cmd(this.gitRoot, ["init"]);
		const status = await gitCmd.status(this.gitRoot, getFilePath(this.gitRoot, [files.t1]));
		expect(status[0]).toEqual(jasmine.objectContaining({added: false, untracked: true, deleted: false, changed: false, file: files.t1}));
	});

	it("should return empty array on no status", async function () {
		spyOn(gitCmd, "cmd").and.returnValue(Promise.resolve(""));
		const status = await gitCmd.status(this.gitRoot, getFilePath(this.gitRoot, [files.t1]));
		expect(status).toEqual([]);
	});

	it("should return rejected promise on unknown status code", async function () {
		spyOn(gitCmd, "cmd").and.returnValue(Promise.resolve(`ZZ ${files.t1}`));
		const error = await gitCmd.status(this.gitRoot, getFilePath(this.gitRoot, [files.t1])).then(() => false, err => err);
		expect(error).toBeTruthy();
	});

});
