<commit_before>/*
*
*
**********TESTS FOR WARD LEVEL************
*
*
*/


describe("Tests for mfl.gis.controllers.gis_ward (Ward Level):", function () {
    "use strict";
    var controller, scope, root, state, httpBackend, SERVER_URL;

    beforeEach(function () {
        module("mflwebApp");
        module("mfl.gis_ward.controllers");
        module("mfl.gis.wrapper");
        module("mfl.gis.routes");

        inject(["$rootScope", "$controller","$httpBackend","$state","$stateParams",
                "SERVER_URL","gisWardsApi",
            function ($rootScope, $controller, $httpBackend, $state,$stateParams,
                  url,gisWardsApi) {
                root = $rootScope;
                scope = root.$new();
                state = $state;
                httpBackend = $httpBackend;
                SERVER_URL = url;
                gisWardsApi = gisWardsApi;
                $stateParams.ward_id = 4;
                controller = function (cntrl, data) {
                    return $controller(cntrl, data);
                };
            }]);
    });
    
    it("should load mfl.gis.controller.gis_ward", inject(["$httpBackend","$state",
                 "leafletData","gisWardsApi",
        function ($httpBackend, $state, leafletData,gisWardsApi) {
        var data = {
            results:{
                id :"",
                type:"",
                features: [],
                geometry:{},
                properties: {}
            }
        };
        $httpBackend.expectGET(
        SERVER_URL + "api/gis/ward_boundaries/?id=4")
            .respond(200, data);
        controller("mfl.gis.controllers.gis_ward", {
            "$scope": scope,
            "leafletData": leafletData,
            "gisWard": {
                data: {
                    properties: {
                        bound: {
                            coordinates: []
                        }
                    }
                }
            },
            "$http": {},
            "$state": {},
            "$stateParams": {ward_id: 4},
            "SERVER_URL": SERVER_URL,
            "gisWardsApi": gisWardsApi
        });
        $httpBackend.flush();
    }]));
    it("should fail to load data (Ward Level)",
       inject(["$httpBackend",
        function ($httpBackend) {
        var data = {
            results:{
                id :"",
                type:"",
                features:[],
                geometry:{},
                properties: {}
            }
        };
        controller("mfl.gis.controllers.gis_ward", {
            "$scope": scope,
            "gisWard": {
                data: {
                    properties: {
                        bound: {
                            coordinates: []
                        }
                    }
                }
            },
            "$http": {},
            "$state": {},
            "$stateParams": {},
            "SERVER_URL": SERVER_URL
        });
        $httpBackend.expectGET(
        SERVER_URL + "api/gis/ward_boundaries/?id=undefined")
            .respond(500, data);
        $httpBackend.flush();
    }]));

    it("should get leaflet data map(Ward Level)",
       inject(["$state", "leafletData","gisWardsApi",
               function ($state, leafletData,gisWardsApi) {
        spyOn(scope, "$on").andCallThrough();
        spyOn($state, "go");
        var obj = {
            then: angular.noop
        };
        var timeout = {
            timeout: angular.noop
        };
        spyOn(leafletData, "getMap").andReturn(obj);
        spyOn(obj, "then");
        spyOn(timeout, "timeout");
        controller("mfl.gis.controllers.gis_ward", {
            "$scope": scope,
            "leafletData": leafletData,
            "gisWard": {
                data: {
                    properties: {
                        bound: {<commit_msg>Added tests for showing facilites at ward level of gis<commit_after>/*
*
*
**********TESTS FOR WARD LEVEL************
*
*
*/


describe("Tests for mfl.gis.controllers.gis_ward (Ward Level):", function () {
    "use strict";
    var controller, scope, root, state, httpBackend, SERVER_URL;

    beforeEach(function () {
        module("mflwebApp");
        module("mfl.gis_ward.controllers");
        module("mfl.gis.wrapper");
        module("mfl.gis.routes");

        inject(["$rootScope", "$controller","$httpBackend","$state","$stateParams",
                "SERVER_URL","gisWardsApi","gisFacilitiesApi",
            function ($rootScope, $controller, $httpBackend, $state,$stateParams,
                  url,gisWardsApi, gisFacilitiesApi) {
                root = $rootScope;
                scope = root.$new();
                state = $state;
                httpBackend = $httpBackend;
                SERVER_URL = url;
                gisWardsApi = gisWardsApi;
                gisFacilitiesApi = gisFacilitiesApi;
                $stateParams.ward_id = 4;
                controller = function (cntrl, data) {
                    return $controller(cntrl, data);
                };
            }]);
    });
    
    it("should load mfl.gis.controller.gis_ward", inject(["$httpBackend","$state",
                 "leafletData","gisWardsApi",
        function ($httpBackend, $state, leafletData,gisWardsApi) {
        var data = {
            results:{
                id :"",
                type:"",
                features: [
                    {
                        id: "",
                        geometry:{
                            type:"",
                            coordinates:[0,1]
                        },
                        properties:{
                            facility_name:""
                        }
                    }
                ],
                geometry:{},
                properties: {}
            }
        };
        $httpBackend.expectGET(
        SERVER_URL + "api/gis/coordinates/?ward=4")
            .respond(200, data);
        controller("mfl.gis.controllers.gis_ward", {
            "$scope": scope,
            "leafletData": leafletData,
            "gisWard": {
                data: {
                    properties: {
                        bound: {
                            coordinates: []
                        },
                        ward_id:"4"
                    }
                }
            },
            "$http": {},
            "$state": {},
            "$stateParams": {ward_id: 4},
            "SERVER_URL": SERVER_URL,
            "gisWardsApi": gisWardsApi
        });
        $httpBackend.flush();
    }]));
    it("should fail to load data (Ward Level)",
       inject(["$httpBackend",
        function ($httpBackend) {
        var data = {
            results:{
                id :"",
                type:"",
                features: [
                    {
                        id: "",
                        geometry:{
                            type:"",
                            coordinates:[0,1]
                        },
                        properties:{
                            facility_name:""
                        }
                    }
                ],
                geometry:{},
                properties: {}
            }
        };
        controller("mfl.gis.controllers.gis_ward", {
            "$scope": scope,
            "gisWard": {
                data: {
                    properties: {
                        bound: {
                            coordinates: []
                        },
                        ward_id:"4"
                    }
                }
            },
            "$http": {},
            "$state": {},
            "$stateParams": {},
            "SERVER_URL": SERVER_URL
        });
        $httpBackend.expectGET(
        SERVER_URL + "api/gis/coordinates/?ward=4")
            .respond(500, data);
        $httpBackend.flush();
    }]));

    it("should get leaflet data map(Ward Level)",
       inject(["$state", "leafletData","gisWardsApi",
               function ($state, leafletData,gisWardsApi) {
        spyOn(scope, "$on").andCallThrough();
        spyOn($state, "go");
        var obj = {
            then: angular.noop
        };
        var timeout = {
            timeout: angular.noop
        };
        spyOn(leafletData, "getMap").andReturn(obj);
        spyOn(obj, "then");
        spyOn(timeout, "timeout");
        controller("mfl.gis.controllers.gis_ward", {
            "$scope": scope,
            "leafletData": leafletData,
            "gisWard": {
                data: {
                    properties: {
                        bound: {
{'fraction_non_alphanumeric': 0.13446353924756155, 'fraction_numerical': 0.0029029261495587553, 'mean_word_length': 1.1462746075255419, 'pattern_counts': {'":': 34, '<': 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': '2755078', 'n_tokens_mistral': 2341, 'n_tokens_neox': 2273, 'n_words': 370}