clone-class
Version:
Clone an ES6 Class as Another Class Name for Isolating Class Static Properties.
45 lines • 1.74 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tstest_1 = require("tstest");
const fixture_class_js_1 = require("../tests/fixtures/fixture-class.js");
(0, tstest_1.test)('Constructor<TYPE> smoke testing', async (t) => {
/**
* Make sure that `PROTOTYPE` is equal to `typeof FixtureClass`
* See also: https://stackoverflow.com/a/50116912/1123955
*/
const instance = new fixture_class_js_1.FixtureClass(1, 2);
t.equal(instance.sum(), 3, 'should sum right for 1 + 2');
});
(0, tstest_1.test)('Constructor<T> with private constructor class', async (t) => {
/**
* Issue #55
* https://github.com/huan/clone-class/issues/55
*/
class PrivateConstructorClass {
constructor() { }
}
const C = PrivateConstructorClass;
const c = new C();
t.ok(c, 'should be able to instanciate');
const typeTest = true;
t.ok(typeTest, 'should be same after constructor');
});
/**
* Huan(202110): TypeError: Cannot read property 'valueDeclaration' of undefined #58
* https://github.com/huan/clone-class/issues/58
*/
tstest_1.test.skip('class with static methods', async (t) => {
class StaticMethodClass {
static staticMethod() { }
constructor() { }
}
// const C: typeof StaticMethodClass = StaticMethodClass as any as Constructor<StaticMethodClass, typeof StaticMethodClass>
const C = StaticMethodClass;
t.ok(C, 'should be ok');
});
(0, tstest_1.test)('Constructor with default generic setting', async (t) => {
const typeTest = true;
t.ok(typeTest, 'should be ok without generic settings "<...>"');
});
//# sourceMappingURL=constructor.spec.js.map