1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

confirm if leaving a modified form without saving

This commit is contained in:
Aki Sasaki 2020-08-18 13:50:23 -07:00
parent 965d20db2a
commit 83365a3756
4 changed files with 94 additions and 6 deletions

View file

@ -38,5 +38,48 @@ describe("AnnotationStorage", function () {
expect(value).toEqual("an other string");
done();
});
it("should call onSetModified() if value is changed", function (done) {
const annotationStorage = new AnnotationStorage();
let called = false;
const callback = function () {
called = true;
};
annotationStorage.onSetModified = callback;
annotationStorage.getOrCreateValue("asdf", "original");
expect(called).toBe(false);
// not changing value
annotationStorage.setValue("asdf", "original");
expect(called).toBe(false);
// changing value
annotationStorage.setValue("asdf", "modified");
expect(called).toBe(true);
done();
});
});
describe("ResetModified", function () {
it("should call onResetModified() if set", function (done) {
const annotationStorage = new AnnotationStorage();
let called = false;
const callback = function () {
called = true;
};
annotationStorage.onResetModified = callback;
annotationStorage.getOrCreateValue("asdf", "original");
// not changing value
annotationStorage.setValue("asdf", "original");
annotationStorage.resetModified();
expect(called).toBe(false);
// changing value
annotationStorage.setValue("asdf", "modified");
annotationStorage.resetModified();
expect(called).toBe(true);
done();
});
});
});