Project import generated by Copybara.

GitOrigin-RevId: d9e9e3fb4e31372ec1fb43b178994ca78fa8fe70
diff --git a/static_src/shared/cron.test.js b/static_src/shared/cron.test.js
new file mode 100644
index 0000000..e2f9a8e
--- /dev/null
+++ b/static_src/shared/cron.test.js
@@ -0,0 +1,36 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import sinon from 'sinon';
+import {assert} from 'chai';
+import {CronTask} from './cron.js';
+
+let clock;
+
+describe('cron', () => {
+  beforeEach(() => {
+    clock = sinon.useFakeTimers();
+  });
+
+  afterEach(() => {
+    clock.restore();
+  });
+
+  it('calls task periodically', () => {
+    const task = sinon.spy();
+    const cronTask = new CronTask(task, 1000);
+
+    // Make sure task is not called until the cron task has been started.
+    assert.isFalse(task.called);
+
+    cronTask.start();
+    assert.isTrue(task.calledOnce);
+
+    clock.tick(1000);
+    assert.isTrue(task.calledTwice);
+
+    clock.tick(1000);
+    assert.isTrue(task.calledThrice);
+  });
+});