diff --git a/index.html b/index.html index fd5e3aeba..348fabb32 100644 --- a/index.html +++ b/index.html @@ -169,6 +169,7 @@ + diff --git a/js/id/actions/revert.js b/js/id/actions/revert.js new file mode 100644 index 000000000..21da5bf7e --- /dev/null +++ b/js/id/actions/revert.js @@ -0,0 +1,5 @@ +iD.actions.Revert = function(entity) { + return function(graph) { + return graph.revert(entity); + }; +}; diff --git a/test/index.html b/test/index.html index ae6159606..d72a3840b 100644 --- a/test/index.html +++ b/test/index.html @@ -147,6 +147,7 @@ + @@ -250,6 +251,7 @@ + diff --git a/test/index_packaged.html b/test/index_packaged.html index fe590c099..e3ea2f00c 100644 --- a/test/index_packaged.html +++ b/test/index_packaged.html @@ -54,6 +54,7 @@ + diff --git a/test/spec/actions/revert.js b/test/spec/actions/revert.js new file mode 100644 index 000000000..cdfa19da1 --- /dev/null +++ b/test/spec/actions/revert.js @@ -0,0 +1,11 @@ +describe('iD.actions.Revert', function() { + it('reverts an entity', function() { + var n1 = iD.Node({id: 'n' }), + n2 = n1.update({}), + graph = iD.Graph([n1]).replace(n2); + + expect(graph.entity('n')).to.equal(n2); + graph = iD.actions.Revert(n2)(graph) + expect(graph.entity('n')).to.equal(n1); + }); +});