<commit_before>describe("A swipe gesture directive", function () {

    beforeEach(module("angular-leap"));

    var directions = ["left", "right", "up", "down"];

    var _Leap;
    var _LeapController;

    beforeEach(inject(function ($window) {
        _LeapController = function(){};
        _LeapController.prototype.connect = function(){};
        _LeapController.prototype.on = function(){};


        _Leap = function () {};
        _Leap.Controller = _LeapController;

        $window.Leap = _Leap;
    }));

    it("should be executed and register gesture event listener ", inject(function ($rootScope, $compile) {
        spyOn(_LeapController.prototype,"connect");
        spyOn(_LeapController.prototype,"on");

        var html = "<div leap-swipe-" + directions[0] + "='test=test+1'></div>";
        var scope = $rootScope.$new();
        var element = $compile(html)(scope);

        expect(_LeapController.prototype.connect).toHaveBeenCalled();
        expect(_LeapController.prototype.on).toHaveBeenCalled();
        expect(_LeapController.prototype.on.calls[0].args[0]).toEqual("gesture");
    }));


    it("should be executed and register gesture event listener ", inject(function ($rootScope, $compile) {
        spyOn(_LeapController.prototype,"on");


        var html = "<div leap-swipe-" + directions[0] + "='test=test+1'></div>";
        var scope = $rootScope.$new();
        var element = $compile(html)(scope);


        spyOn(scope,"$apply");
        // Simulate Swipe Event, execute function
        _LeapController.prototype.on.calls[0].args[1]({
            type: "swipe",
            direction:[1,0]
        });

        expect(scope.$apply).toHaveBeenCalled();
    }));


    it("should use the timeout function to prevent unwanted double event triggers", inject(function ($rootScope, $compile,$timeout) {
        spyOn(_LeapController.prototype,"on");
<commit_msg>add more swipe test for different directions<commit_after>describe("A swipe gesture directive", function () {

    beforeEach(module("angular-leap"));

    var directions = ["left", "right", "up", "down"];

    var _Leap;
    var _LeapController;

    beforeEach(inject(function ($window) {
        _LeapController = function(){};
        _LeapController.prototype.connect = function(){};
        _LeapController.prototype.on = function(){};


        _Leap = function () {};
        _Leap.Controller = _LeapController;

        $window.Leap = _Leap;
    }));

    it("should be executed and register gesture event listener ", inject(function ($rootScope, $compile) {
        spyOn(_LeapController.prototype,"connect");
        spyOn(_LeapController.prototype,"on");

        var html = "<div leap-swipe-" + directions[0] + "='test=test+1'></div>";
        var scope = $rootScope.$new();
        var element = $compile(html)(scope);

        expect(_LeapController.prototype.connect).toHaveBeenCalled();
        expect(_LeapController.prototype.on).toHaveBeenCalled();
        expect(_LeapController.prototype.on.calls[0].args[0]).toEqual("gesture");
    }));


    //TODO: Write generic tesFOrDirection func to reduce redundant code
    it("should be executed and register gesture event listener for left", inject(function ($rootScope, $compile) {


        spyOn(_LeapController.prototype,"on");
        var html = "<div leap-swipe-" + directions[0] + "='test=test+1'></div>";
        var scope = $rootScope.$new();
        var element = $compile(html)(scope);
        spyOn(scope,"$apply");
        // Simulate Swipe Event, execute function
        _LeapController.prototype.on.calls[0].args[1]({
            type: "swipe",
            direction:[1,0]
        });
        expect(scope.$apply).toHaveBeenCalled();
    }));


    it("should be executed and register gesture event listener for right", inject(function ($rootScope, $compile) {
        spyOn(_LeapController.prototype,"on");


        var html = "<div leap-swipe-right='test=test+1'></div>";
        var scope = $rootScope.$new();
        var element = $compile(html)(scope);


        spyOn(scope,"$apply");
        // Simulate Swipe Event, execute function
        _LeapController.prototype.on.calls[0].args[1]({
            type: "swipe",
            direction:[-1,0]
        });

        expect(scope.$apply).toHaveBeenCalled();
    }));

    it("should be executed and register gesture event listener for up", inject(function ($rootScope, $compile) {
        spyOn(_LeapController.prototype,"on");


        var html = "<div leap-swipe-up='test=test+1'></div>";
        var scope = $rootScope.$new();
        var element = $compile(html)(scope);


        spyOn(scope,"$apply");
        // Simulate Swipe Event, execute function
        _LeapController.prototype.on.calls[0].args[1]({
            type: "swipe",
            direction:[0,1]
        });

        expect(scope.$apply).toHaveBeenCalled();
    }));


    it("should be executed and register gesture event listener for down", inject(function ($rootScope, $compile) {
        spyOn(_LeapController.prototype,"on");


        var html = "<div leap-swipe-down='test=test+1'></div>";
        var scope = $rootScope.$new();
        var element = $compile(html)(scope);


        spyOn(scope,"$apply");
        // Simulate Swipe Event, execute function
        _LeapController.prototype.on.calls[0].args[1]({
            type: "swipe",
            direction:[0,-1]
        });

        expect(scope.$apply).toHaveBeenCalled();
    }));





    it("should use the timeout function to prevent unwanted double event triggers", inject(function ($rootScope, $compile,$timeout) {
        spyOn(_LeapController.prototype,"on");

{'fraction_non_alphanumeric': 0.15335576412254295, 'fraction_numerical': 0.006197981228971135, 'mean_word_length': 2.933147632311978, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '6628479', 'n_tokens_mistral': 1632, 'n_tokens_neox': 1599, 'n_words': 338}