{"size": 2769, "ext": "js", "max_stars_repo_path": "public/js/leaflet/Leaflet.Pin/spec/leaflet.pin.test.js", "max_stars_repo_name": "xgs736214763/location", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "public/js/leaflet/Leaflet.Pin/spec/leaflet.pin.test.js", "max_issues_repo_name": "xgs736214763/location", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "public/js/leaflet/Leaflet.Pin/spec/leaflet.pin.test.js", "max_forks_repo_name": "xgs736214763/location", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 32.5764705882, "max_line_length": 75, "alphanum_fraction": 0.4922354641}
describe('Leaflet.Pin', function () {

    var map;

    beforeEach(function () {
        map = new L.Map(L.DomUtil.create('div'), {
            pin: true,
            pinControl: true
        });
    });

    describe('#add and parse guide layers', function () {
        var featureGroup;
        var marker;
        var poly;

        beforeEach(function () {
            poly = new L.polyline([[50.1, 50,2], [50.1, 50.6]]);
            featureGroup = new L.FeatureGroup();
            featureGroup.addLayer(new L.Marker([50.0, 50.0]));
            featureGroup.addLayer(new L.Marker([50.0, 50.1]));
            featureGroup.addLayer(new L.Marker([50.0, 50.2]));
            map.addGuideLayer(featureGroup);
            marker = new L.Marker([50.0, 50.3]);
            map.addLayer(marker);
            map.addGuideLayer(marker);
        });

        it('correctly parse guide layers', function () {
            expect(map._guideList.length).toEqual(4);
        });

        it('update guide layer for marker', function () {
            var latlng;
            map.updateGuideLayer(marker._leaflet_id, L.latLng(50.1, 50.5));
            for (var i = 0; i < map._guideList.length; i++) {
                if (map._guideList[i]._leaflet_id == marker._leaflet_id) {
                    latlng = map._guideList[i].getLatLng();
                    break;
                }
            }
            expect(latlng.equals(L.latLng(50.1, 50.5))).toBeTruthy();
        });

        it('update guide layer for poly', function () {
            var latlngs,
                newLatLngs = [L.latLng(50.1, 51.2), L.latLng(50.1, 51.6)],
                poly = new L.polyline([[50.1, 50,2], [50.1, 50.6]]),
                equals = false;

            map.addLayer(poly);
            map.addGuideLayer(poly);

            map.updateGuideLayer(poly._leaflet_id, newLatLngs);

            for (var i = 0; i < map._guideList.length; i++) {
                if (map._guideList[i]._leaflet_id == poly._leaflet_id) {
                    latlngs = map._guideList[i].getLatLngs();
                    break;
                }
            }

            for (var j = 0; j < latlngs.length; j++) {
                if (latlngs[j].equals(newLatLngs[j])) {
                    equals = true;
                }
            }

            expect(equals).toBeTruthy();
        });

        it('add layer to FeatureGroup guide layer', function () {
            featureGroup.addLayer(poly);

            expect(map._guideList.length).toEqual(5);
        });

        it('remove layer from FeatureGroup guide layer', function () {
            featureGroup.addLayer(poly);
            featureGroup.removeLayer(poly);
            
            expect(map._guideList.length).toEqual(4);
        })
    });
});