Files
iD/test/spec/actions/change_preset.js
2016-10-04 21:56:09 -04:00

26 lines
1.1 KiB
JavaScript

describe('iD.actionChangePreset', function() {
var oldPreset = iD.presetPreset('old', {tags: {old: 'true'}}),
newPreset = iD.presetPreset('new', {tags: {new: 'true'}});
it('changes from one preset\'s tags to another\'s', function() {
var entity = iD.Node({tags: {old: 'true'}}),
graph = iD.Graph([entity]),
action = iD.actionChangePreset(entity.id, oldPreset, newPreset);
expect(action(graph).entity(entity.id).tags).to.eql({new: 'true'});
});
it('adds the tags of a new preset to an entity without an old preset', function() {
var entity = iD.Node(),
graph = iD.Graph([entity]),
action = iD.actionChangePreset(entity.id, null, newPreset);
expect(action(graph).entity(entity.id).tags).to.eql({new: 'true'});
});
it('removes the tags of an old preset from an entity without a new preset', function() {
var entity = iD.Node({tags: {old: 'true'}}),
graph = iD.Graph([entity]),
action = iD.actionChangePreset(entity.id, oldPreset, null);
expect(action(graph).entity(entity.id).tags).to.eql({});
});
});