aboutsummaryrefslogtreecommitdiffstats
path: root/apps/comments/tests/js/commentscollectionSpec.js
diff options
context:
space:
mode:
Diffstat (limited to 'apps/comments/tests/js/commentscollectionSpec.js')
-rw-r--r--apps/comments/tests/js/commentscollectionSpec.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/apps/comments/tests/js/commentscollectionSpec.js b/apps/comments/tests/js/commentscollectionSpec.js
index 0dc68cc167c..2f41a272f67 100644
--- a/apps/comments/tests/js/commentscollectionSpec.js
+++ b/apps/comments/tests/js/commentscollectionSpec.js
@@ -100,5 +100,49 @@ describe('OCA.Comments.CommentCollection', function() {
expect(collection.hasMoreResults()).toEqual(true);
});
+ describe('resetting read marker', function() {
+ var updateStub;
+ var clock;
+
+ beforeEach(function() {
+ updateStub = sinon.stub(OCA.Comments.CommentSummaryModel.prototype, 'save');
+ clock = sinon.useFakeTimers(Date.UTC(2016, 1, 3, 10, 5, 9));
+ });
+ afterEach(function() {
+ updateStub.restore();
+ clock.restore();
+ });
+
+ it('resets read marker to the default date', function() {
+ var successStub = sinon.stub();
+ collection.updateReadMarker(null, {
+ success: successStub
+ });
+
+ expect(updateStub.calledOnce).toEqual(true);
+ expect(updateStub.lastCall.args[0]).toEqual({
+ readMarker: new Date(Date.UTC(2016, 1, 3, 10, 5, 9)).toUTCString()
+ });
+
+ updateStub.yieldTo('success');
+
+ expect(successStub.calledOnce).toEqual(true);
+ });
+ it('resets read marker to the given date', function() {
+ var successStub = sinon.stub();
+ collection.updateReadMarker(new Date(Date.UTC(2016, 1, 2, 3, 4, 5)), {
+ success: successStub
+ });
+
+ expect(updateStub.calledOnce).toEqual(true);
+ expect(updateStub.lastCall.args[0]).toEqual({
+ readMarker: new Date(Date.UTC(2016, 1, 2, 3, 4, 5)).toUTCString()
+ });
+
+ updateStub.yieldTo('success');
+
+ expect(successStub.calledOnce).toEqual(true);
+ });
+ });
});