<commit_before>var parser = require('./parser/gitGraph').parser;
var ast = require("./gitGraphAst.js");
describe('when parsing a gitGraph',function() {
    "use strict";
    beforeEach(function () {
        parser.yy = ast;
        parser.yy.reset();
    });
    it('should handle a gitGraph defintion', function () {
        var str = 'gitGraph:\n' +
        'commit\n';

        parser.parse(str);
        var commits = parser.yy.getCommits();
        console.log(commits);

        expect(Object.keys(commits).length).toBe(1);
        expect(parser.yy.getCurrentBranch()).toBe("master");
        expect(parser.yy.getDirection()).toBe("LR");
        expect(Object.keys(parser.yy.getBranches()).length).toBe(1);
    });

    it('should handle set direction', function () {
        var str = 'gitGraph TB:\n' +
        'commit\n';

        parser.parse(str);
        var commits = parser.yy.getCommits();
        console.log(commits);

        expect(Object.keys(commits).length).toBe(1);
        expect(parser.yy.getCurrentBranch()).toBe("master");
        expect(parser.yy.getDirection()).toBe("TB");
        expect(Object.keys(parser.yy.getBranches()).length).toBe(1);
    });
    it('should checkout a branch', function () {
        var str = 'gitGraph:\n' +
        'branch new\n' +
        'checkout new\n'

        parser.parse(str);
        var commits = parser.yy.getCommits();

        expect(Object.keys(commits).length).toBe(0);
        expect(parser.yy.getCurrentBranch()).toBe("new");
    });

    it('should handle commit with args', function () {
        var str = 'gitGraph:\n' +
        'commit "a commit"\n';

        parser.parse(str);
        var commits = parser.yy.getCommits();
        console.log(commits);

        expect(Object.keys(commits).length).toBe(1);
        var key = Object.keys(commits)[0];
        expect(commits[key].message).toBe("a commit");
        expect(parser.yy.getCurrentBranch()).toBe("master");
    });

    it('should handle branch statement', function () {<commit_msg>add another test for checkout<commit_after>var parser = require('./parser/gitGraph').parser;
var ast = require("./gitGraphAst.js");
describe('when parsing a gitGraph',function() {
    "use strict";
    beforeEach(function () {
        parser.yy = ast;
        parser.yy.reset();
    });
    it('should handle a gitGraph defintion', function () {
        var str = 'gitGraph:\n' +
        'commit\n';

        parser.parse(str);
        var commits = parser.yy.getCommits();
        console.log(commits);

        expect(Object.keys(commits).length).toBe(1);
        expect(parser.yy.getCurrentBranch()).toBe("master");
        expect(parser.yy.getDirection()).toBe("LR");
        expect(Object.keys(parser.yy.getBranches()).length).toBe(1);
    });

    it('should handle set direction', function () {
        var str = 'gitGraph TB:\n' +
        'commit\n';

        parser.parse(str);
        var commits = parser.yy.getCommits();
        console.log(commits);

        expect(Object.keys(commits).length).toBe(1);
        expect(parser.yy.getCurrentBranch()).toBe("master");
        expect(parser.yy.getDirection()).toBe("TB");
        expect(Object.keys(parser.yy.getBranches()).length).toBe(1);
    });

    it('should checkout a branch', function () {
        var str = 'gitGraph:\n' +
        'branch new\n' +
        'checkout new\n'

        parser.parse(str);
        var commits = parser.yy.getCommits();

        expect(Object.keys(commits).length).toBe(0);
        expect(parser.yy.getCurrentBranch()).toBe("new");
    });

    it('should add commits to checked out branch', function () {
        var str = 'gitGraph:\n' +
        'branch new\n' +
        'checkout new\n' +
        'commit\n'+
        'commit\n'

        parser.parse(str);
        var commits = parser.yy.getCommits();

        expect(Object.keys(commits).length).toBe(2);
        expect(parser.yy.getCurrentBranch()).toBe("new");
        var branchCommit = parser.yy.getBranches()['new'];
        expect(branchCommit).not.toBeNull();
        expect(commits[branchCommit].parent).not.toBeNull();
    });
    it('should handle commit with args', function () {
        var str = 'gitGraph:\n' +
        'commit "a commit"\n';

        parser.parse(str);
        var commits = parser.yy.getCommits();
        console.log(commits);

        expect(Object.keys(commits).length).toBe(1);
        var key = Object.keys(commits)[0];
        expect(commits[key].message).toBe("a commit");
        expect(parser.yy.getCurrentBranch()).toBe("master");
    });

    it('should handle branch statement', function () {
{'fraction_non_alphanumeric': 0.17108119843682154, 'fraction_numerical': 0.003256621797655232, 'mean_word_length': 2.576863354037267, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3823416', 'n_tokens_mistral': 1395, 'n_tokens_neox': 1365, 'n_words': 234}