瀏覽代碼

Update tests.

Afshin T. Darian 6 年之前
父節點
當前提交
be985f0779
共有 1 個文件被更改,包括 13 次插入13 次删除
  1. 13 13
      tests/test-coreutils/src/ratelimiter.spec.ts

+ 13 - 13
tests/test-coreutils/src/regulator.spec.ts → tests/test-coreutils/src/ratelimiter.spec.ts

@@ -3,20 +3,20 @@
 
 import { expect } from 'chai';
 
-import { debounce } from '@jupyterlab/coreutils';
+import { Debouncer } from '@jupyterlab/coreutils';
 
-describe('debounce()', () => {
-  it('should debounce a function within an interval', async () => {
+describe('Debouncer', () => {
+  it('should debounce a function within a limit interval', async () => {
     let called = 0;
-    const interval = 500;
-    const debounced = debounce(async () => {
+    const limit = 500;
+    const debouncer = new Debouncer(async () => {
       called += 1;
-    }, interval);
-    const one = debounced.invoke();
-    const two = debounced.invoke();
-    const three = debounced.invoke();
-    const four = debounced.invoke();
-    const five = debounced.invoke();
+    }, limit);
+    const one = debouncer.invoke();
+    const two = debouncer.invoke();
+    const three = debouncer.invoke();
+    const four = debouncer.invoke();
+    const five = debouncer.invoke();
     await five;
     expect(called).to.equal(1);
     await four;
@@ -27,9 +27,9 @@ describe('debounce()', () => {
     expect(called).to.equal(1);
     await one;
     expect(called).to.equal(1);
-    await debounced.invoke();
+    await debouncer.invoke();
     expect(called).to.equal(2);
-    await debounced.invoke();
+    await debouncer.invoke();
     expect(called).to.equal(3);
   });
 });