Skip to content

Commit

Permalink
Added @ReactComponent decorator test;
Browse files Browse the repository at this point in the history
  • Loading branch information
DigitalBrainJS committed Apr 26, 2021
1 parent f50ff58 commit 71282be
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/src/decorators.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const {
done,
progress,
CanceledError,
ReactComponent,
E_REASON_TIMEOUT
} = require('../../lib/c-promise');

Expand Down Expand Up @@ -244,5 +245,27 @@ module.exports = {
const obj = new klass();

return obj.fn1();
},

"should support ReactComponent decorator": async function () {
@ReactComponent
class klass{
*componentDidMount(scope) {
assert.ok(scope instanceof CPromise);
yield delay(100);
return 123;
}

*componentWillUnmount(scope){
assert.ok(scope instanceof CPromise);
yield delay(100);
return 456;
}
}

const obj = new klass();

assert.strictEqual(await obj.componentDidMount(), 123);
assert.strictEqual(await obj.componentWillUnmount(), 456);
}
}

0 comments on commit 71282be

Please sign in to comment.