reactant
Version:
A framework for building React web applications
40 lines (37 loc) • 852 B
JavaScript
import { __assign } from './node_modules/tslib/tslib.es6.js';
import { createApp } from './createApp.js';
/**
* ## Description
*
* You can use `testBed` to build your test code without `render`(`render` function is optional.).
*
* ## Example
*
* ```ts
* @injectable()
* class Bar {
* getValue() {
* return 'bar';
* }
* }
*
* @injectable()
* class Foo {
* constructor(public bar: Bar) {}
* }
*
* const foo = testBed({
* modules: [{ provide: Bar, useValue: { getValue: () => 'test' } }],
* main: Foo,
* });
*
* expect(foo.instance.bar.getValue()).toBe('test');
* ```
*/
function testBed(config) {
return createApp(__assign(__assign({}, config), { render: config.render ||
(function () {
console.log("No render function is configured.");
}) }));
}
export { testBed };