clone-class
Version:
Clone an ES6 Class as Another Class Name for Isolating Class Static Properties.
43 lines • 1.58 kB
JavaScript
import { test, } from 'tstest';
import { FixtureClass } from '../tests/fixtures/fixture-class.js';
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 FixtureClass(1, 2);
t.equal(instance.sum(), 3, 'should sum right for 1 + 2');
});
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
*/
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');
});
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