瀏覽代碼

Use poll refresh, fix up test.

Ian Rose 6 年之前
父節點
當前提交
be4cc1a0d5
共有 2 個文件被更改,包括 7 次插入8 次删除
  1. 2 1
      packages/filebrowser/src/model.ts
  2. 5 7
      tests/test-filebrowser/src/model.spec.ts

+ 2 - 1
packages/filebrowser/src/model.ts

@@ -228,7 +228,8 @@ export class FileBrowserModel implements IDisposable {
    * Force a refresh of the directory contents.
    */
   async refresh(): Promise<void> {
-    await this.cd('.');
+    await this._poll.refresh();
+    await this._poll.tick;
   }
 
   /**

+ 5 - 7
tests/test-filebrowser/src/model.spec.ts

@@ -26,7 +26,8 @@ import {
 import {
   acceptDialog,
   dismissDialog,
-  signalToPromises
+  signalToPromises,
+  sleep
 } from '@jupyterlab/testutils';
 import { toArray } from '@phosphor/algorithm';
 
@@ -259,18 +260,15 @@ describe('filebrowser/model', () => {
           opener,
           manager: delayedServiceManager
         });
-        model = new FileBrowserModel({ manager, state });
+        model = new FileBrowserModel({ manager, state }); // Should delay 1000ms
 
-        const paths: string[] = [];
         // An initial refresh is called in the constructor.
         // If it is too slow, it can come in after the directory change,
         // causing a directory set by, e.g., the tree handler to be wrong.
         // This checks to make sure we are handling that case correctly.
-        const refresh = model.refresh().then(() => paths.push(model.path));
-        const cd = model.cd('src').then(() => paths.push(model.path));
-        await Promise.all([refresh, cd]);
+        await model.cd('src'); // should delay 500ms
+        await sleep(2000);
         expect(model.path).to.equal('src');
-        expect(paths).to.eql(['', 'src']);
 
         manager.dispose();
         delayedServiceManager.contents.dispose();