From c10b83f28f0e2a032d947977e8c698fb5ff1030b Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Sun, 26 Apr 2015 01:08:31 -0400 Subject: [PATCH] iD.actions.Revert (see #537) --- index.html | 1 + js/id/actions/revert.js | 5 +++++ test/index.html | 2 ++ test/index_packaged.html | 1 + test/spec/actions/revert.js | 11 +++++++++++ 5 files changed, 20 insertions(+) create mode 100644 js/id/actions/revert.js create mode 100644 test/spec/actions/revert.js 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); + }); +});