mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 17:23:02 +00:00
Consolidate localization behavior and init to a coreLocalizer function and singleton Explicitly support `en-US` locale Rename coreData to coreFileFetcher and export a singleton rather than using a property of coreContext Add `apiConnections` property of coreContext to simplify adding a source switcher Replace some init functions with re-callable, promise-supporting `ensureLoaded` functions Make coreContext itself load the UI if a container has been specified at init time Fix code tests
111 lines
3.9 KiB
JavaScript
111 lines
3.9 KiB
JavaScript
describe('iD.behaviorSelect', function() {
|
|
var a, b, context, behavior, container;
|
|
|
|
beforeEach(function() {
|
|
container = d3.select('body').append('div');
|
|
context = iD.coreContext().init().container(container);
|
|
|
|
a = iD.osmNode({loc: [0, 0]});
|
|
b = iD.osmNode({loc: [0, 0]});
|
|
|
|
context.perform(iD.actionAddEntity(a), iD.actionAddEntity(b));
|
|
|
|
container.call(context.map())
|
|
.append('div')
|
|
.attr('class', 'inspector-wrap');
|
|
|
|
context.surface().select('.data-layer.osm').selectAll('circle')
|
|
.data([a, b])
|
|
.enter().append('circle')
|
|
.attr('class', function(d) { return d.id; });
|
|
|
|
context.enter(iD.modeBrowse(context));
|
|
|
|
behavior = iD.behaviorSelect(context);
|
|
context.install(behavior);
|
|
});
|
|
|
|
afterEach(function() {
|
|
context.uninstall(behavior);
|
|
context.mode().exit();
|
|
container.remove();
|
|
});
|
|
|
|
specify('refuse to enter select mode with no ids', function() {
|
|
context.enter(iD.modeSelect(context, []));
|
|
expect(context.mode().id, 'empty array').to.eql('browse');
|
|
context.enter(iD.modeSelect(context, undefined));
|
|
expect(context.mode().id, 'undefined').to.eql('browse');
|
|
});
|
|
|
|
specify('refuse to enter select mode with nonexistent ids', function() {
|
|
context.enter(iD.modeSelect(context, ['w-1']));
|
|
expect(context.mode().id).to.eql('browse');
|
|
});
|
|
|
|
specify('click on entity selects the entity', function(done) {
|
|
var el = context.surface().selectAll('.' + a.id).node();
|
|
happen.mousedown(el);
|
|
happen.mouseup(el);
|
|
window.setTimeout(function() {
|
|
expect(context.selectedIDs()).to.eql([a.id]);
|
|
done();
|
|
}, 50);
|
|
});
|
|
|
|
specify('click on empty space clears the selection', function(done) {
|
|
context.enter(iD.modeSelect(context, [a.id]));
|
|
var el = context.surface().node();
|
|
happen.mousedown(el);
|
|
happen.mouseup(el);
|
|
window.setTimeout(function() {
|
|
expect(context.mode().id).to.eql('browse');
|
|
done();
|
|
}, 50);
|
|
});
|
|
|
|
specify('shift-click on unselected entity adds it to the selection', function(done) {
|
|
context.enter(iD.modeSelect(context, [a.id]));
|
|
var el = context.surface().selectAll('.' + b.id).node();
|
|
happen.mousedown(el, { shiftKey: true });
|
|
happen.mouseup(el, { shiftKey: true });
|
|
window.setTimeout(function() {
|
|
expect(context.selectedIDs()).to.eql([a.id, b.id]);
|
|
done();
|
|
}, 50);
|
|
});
|
|
|
|
specify('shift-click on selected entity removes it from the selection', function(done) {
|
|
context.enter(iD.modeSelect(context, [a.id, b.id]));
|
|
var el = context.surface().selectAll('.' + b.id).node();
|
|
happen.mousedown(el, { shiftKey: true });
|
|
happen.mouseup(el, { shiftKey: true });
|
|
window.setTimeout(function() {
|
|
expect(context.selectedIDs()).to.eql([a.id]);
|
|
done();
|
|
}, 50);
|
|
});
|
|
|
|
specify('shift-click on last selected entity clears the selection', function(done) {
|
|
context.enter(iD.modeSelect(context, [a.id]));
|
|
var el = context.surface().selectAll('.' + a.id).node();
|
|
happen.mousedown(el, { shiftKey: true });
|
|
happen.mouseup(el, { shiftKey: true });
|
|
window.setTimeout(function() {
|
|
expect(context.mode().id).to.eql('browse');
|
|
done();
|
|
}, 50);
|
|
});
|
|
|
|
specify('shift-click on empty space leaves the selection unchanged', function(done) {
|
|
context.enter(iD.modeSelect(context, [a.id]));
|
|
var el = context.surface().node();
|
|
happen.mousedown(el, { shiftKey: true });
|
|
happen.mouseup(el, { shiftKey: true });
|
|
window.setTimeout(function() {
|
|
expect(context.selectedIDs()).to.eql([a.id]);
|
|
done();
|
|
}, 50);
|
|
});
|
|
});
|