IBM / ipfs-social-proof

IPFS Social Proof: A decentralized identity and social proof system
MIT License
142 stars 27 forks source link

add initial tests for ipfs class #41

Closed cdeng001 closed 5 years ago

daviddahl commented 5 years ago

I just noticed you have not added any of the calls to done(). see: https://github.com/IBM/ipfs-social-proof/blob/master/test/remote-proofs.spec.js#L51-L66

cdeng001 commented 5 years ago

yeah, lmk if i missed or messed anything up

cdeng001 commented 5 years ago
const res = await ipfs.saveProofToIpfs("peaches");
expect(res)
      .to.be.an.instanceOf(Array)
      .that.has.same.deep.members([{ hash: "sneaky peaches" }]);

using done would refractor to

ipfs.saveProofToIpfs("peaches")
    .then((res) => {
        expect(res)
          .to.be.an.instanceOf(Array)
          .that.has.same.deep.members([{ hash: "sneaky peaches" }]);
    } ).then(() => {
        done()
    })

is this correct?

daviddahl commented 5 years ago

You can just call done after the expect() and not use a second .then() its good practice to add a .catch((ex) => { expect(ex).to.not.exist() })

cdeng001 commented 5 years ago

weird, doing that doesn't change the output of the tests the log messages are still popping up synchronously

cdeng001 commented 5 years ago

I think that mocha handles returned promises and since async always returns a promise, the test gets handled automatically without a done() call.