Create method history.hasChanges

This commit is contained in:
Brandon Liu
2013-01-19 22:29:11 -08:00
parent 3b722ed503
commit d83ec7f1eb
2 changed files with 18 additions and 0 deletions
+6
View File
@@ -109,6 +109,12 @@ iD.History = function() {
};
},
hasChanges: function() {
return !!d3.sum(d3.values(this.changes()).map(function(c) {
return c.length;
}));;
},
imagery_used: function(source) {
if (source) imagery_used = source;
else return _.without(
+12
View File
@@ -126,6 +126,18 @@ describe("iD.History", function () {
});
});
describe("#hasChanges", function() {
it("is true when any of change's values are nonempty", function() {
var node = iD.Node();
history.perform(function (graph) { return graph.replace(node); });
expect(history.hasChanges()).to.eql(true);
});
it("is false when any of change's values are empty", function() {
expect(history.hasChanges()).to.eql(false);
});
});
describe("#reset", function () {
it("clears the version stack", function () {
history.perform(action, "annotation");