import { geoProjection as d3_geoProjection } from 'd3-geo';
import { select as d3_select } from 'd3-selection';


describe('iD.svgVertices', function () {
    var context;
    var surface;
    var projection = d3_geoProjection(function(x, y) { return [x, -y]; })
        .translate([0, 0])
        .scale(iD.geoZoomToScale(17))
        .clipExtent([[0, 0], [Infinity, Infinity]]);


    beforeEach(function () {
        context = iD.coreContext().assetPath('../dist/').init();
        d3_select(document.createElement('div'))
            .attr('class', 'main-map')
            .call(context.map().centerZoom([0, 0], 17));
        surface = context.surface();
    });


    it('adds the .shared class to vertices that are members of two or more ways', function () {
        var node = new iD.osmNode({loc: [0, 0]});
        var way1 = new iD.osmWay({nodes: [node.id], tags: {highway: 'residential'}});
        var way2 = new iD.osmWay({nodes: [node.id], tags: {highway: 'residential'}});
        var graph = new iD.coreGraph([node, way1, way2]);
        var filter = function() { return true; };
        var extent = iD.geoExtent([0, 0], [1, 1]);

        surface.call(iD.svgVertices(projection, context), graph, [node], filter, extent);
        expect(surface.select('.vertex').classed('shared')).toBe(true);
    });
});
