Browse Source

finish removing uses of then

Steven Silvester 6 years ago
parent
commit
3041aa84a8

+ 13 - 14
tests/test-coreutils/src/settingregistry.spec.ts

@@ -24,20 +24,19 @@ export class TestConnector extends StateDB
     super({ namespace: 'setting-registry-tests' });
   }
 
-  fetch(id: string): Promise<ISettingRegistry.IPlugin | null> {
-    return super.fetch(id).then((data: string) => {
-      if (!data && !this.schemas[id]) {
-        return null;
-      }
-
-      const schema = this.schemas[id] || { type: 'object' };
-      const composite = {};
-      const user = {};
-      const raw = data || '{ }';
-      const result = { id, data: { composite, user }, raw, schema };
-
-      return result;
-    });
+  async fetch(id: string): Promise<ISettingRegistry.IPlugin | null> {
+    const data: string = await super.fetch(id);
+    if (!data && !this.schemas[id]) {
+      return null;
+    }
+
+    const schema = this.schemas[id] || { type: 'object' };
+    const composite = {};
+    const user = {};
+    const raw = data || '{ }';
+    const result = { id, data: { composite, user }, raw, schema };
+
+    return result;
   }
 }
 

+ 5 - 11
tests/test-coreutils/src/statedb.spec.ts

@@ -51,18 +51,12 @@ describe('StateDB', () => {
       let value = 'qux';
 
       // By sharing a namespace, the two databases will share data.
-      let promise = prepopulate
-        .save('foo', 'bar')
-        .then(() => db.fetch('foo'))
-        .then(saved => {
-          expect(saved).to.equal('bar');
-        })
-        .then(() => db.fetch(key))
-        .then(saved => {
-          expect(saved).to.equal(value);
-        });
+      await prepopulate.save('foo', 'bar');
+      let saved = await db.fetch('foo');
+      expect(saved).to.equal('bar');
       transform.resolve({ type: 'merge', contents: { [key]: value } });
-      await promise;
+      saved = await db.fetch(key);
+      expect(saved).to.equal(value);
       await db.clear();
     });
   });

+ 26 - 25
tests/test-csvviewer/src/model.spec.ts

@@ -324,7 +324,7 @@ describe('csvviewer/model', () => {
       ]);
     });
 
-    it('handles delayed parsing of rows past the initial rows', () => {
+    it('handles delayed parsing of rows past the initial rows', async () => {
       const d = new DSVModel({
         data: `a,b,c\nc,d,e\nf,g,h\ni,j,k`,
         delimiter: ',',
@@ -348,30 +348,31 @@ describe('csvviewer/model', () => {
       ]);
 
       // Check everything is in order after all the data has been parsed asynchronously.
-      return d.ready.then(() => {
-        expect(d.rowCount('column-header')).to.equal(1);
-        expect(d.rowCount('body')).to.equal(3);
-        expect(d.columnCount('row-header')).to.equal(1);
-        expect(d.columnCount('body')).to.equal(3);
-        expect([0, 1, 2].map(i => d.data('column-header', 0, i))).to.deep.equal(
-          ['a', 'b', 'c']
-        );
-        expect([0, 1, 2].map(i => d.data('body', 0, i))).to.deep.equal([
-          'c',
-          'd',
-          'e'
-        ]);
-        expect([0, 1, 2].map(i => d.data('body', 1, i))).to.deep.equal([
-          'f',
-          'g',
-          'h'
-        ]);
-        expect([0, 1, 2].map(i => d.data('body', 2, i))).to.deep.equal([
-          'i',
-          'j',
-          'k'
-        ]);
-      });
+      await d.ready;
+      expect(d.rowCount('column-header')).to.equal(1);
+      expect(d.rowCount('body')).to.equal(3);
+      expect(d.columnCount('row-header')).to.equal(1);
+      expect(d.columnCount('body')).to.equal(3);
+      expect([0, 1, 2].map(i => d.data('column-header', 0, i))).to.deep.equal([
+        'a',
+        'b',
+        'c'
+      ]);
+      expect([0, 1, 2].map(i => d.data('body', 0, i))).to.deep.equal([
+        'c',
+        'd',
+        'e'
+      ]);
+      expect([0, 1, 2].map(i => d.data('body', 1, i))).to.deep.equal([
+        'f',
+        'g',
+        'h'
+      ]);
+      expect([0, 1, 2].map(i => d.data('body', 2, i))).to.deep.equal([
+        'i',
+        'j',
+        'k'
+      ]);
     });
   });
 });

+ 5 - 6
tests/test-imageviewer/src/widget.spec.ts

@@ -138,13 +138,12 @@ describe('ImageViewer', () => {
   });
 
   describe('#onUpdateRequest()', () => {
-    it('should render the image', () => {
+    it('should render the image', async () => {
       const img: HTMLImageElement = widget.node.querySelector('img');
-      return widget.ready.then(() => {
-        MessageLoop.sendMessage(widget, Widget.Msg.UpdateRequest);
-        expect(widget.methods).to.contain('onUpdateRequest');
-        expect(img.src).to.contain(IMAGE.content);
-      });
+      await widget.ready;
+      MessageLoop.sendMessage(widget, Widget.Msg.UpdateRequest);
+      expect(widget.methods).to.contain('onUpdateRequest');
+      expect(img.src).to.contain(IMAGE.content);
     });
   });
 

+ 3 - 4
tests/test-rendermime/src/registry.spec.ts

@@ -99,14 +99,13 @@ describe('rendermime/registry', () => {
         }).to.throw();
       });
 
-      it('should render json data', () => {
+      it('should render json data', async () => {
         const model = createModel({
           'application/json': { foo: 1 }
         });
         const w = r.createRenderer('application/json');
-        return w.renderModel(model).then(() => {
-          expect(w.node.textContent).to.equal('{\n  "foo": 1\n}');
-        });
+        await w.renderModel(model);
+        expect(w.node.textContent).to.equal('{\n  "foo": 1\n}');
       });
 
       it('should send a url resolver', async () => {