46 lines
2.0 KiB
JavaScript
46 lines
2.0 KiB
JavaScript
import { __decorate, __extends } from "tslib";
|
|
/**
|
|
* @jest-environment node
|
|
*/
|
|
import * as React from 'react';
|
|
import { renderToStaticMarkup } from 'react-dom/server';
|
|
import { customizable } from './customizable';
|
|
import { Customizations } from './Customizations';
|
|
var Foo = /** @class */ (function (_super) {
|
|
__extends(Foo, _super);
|
|
function Foo() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
Foo.prototype.render = function () {
|
|
return React.createElement("div", null, this.props.field);
|
|
};
|
|
Foo = __decorate([
|
|
customizable('Foo', ['field'])
|
|
], Foo);
|
|
return Foo;
|
|
}(React.Component));
|
|
describe('customizable (server-side rendering)', function () {
|
|
beforeEach(function () {
|
|
Customizations.reset();
|
|
});
|
|
it('can receive global customizations', function () {
|
|
Customizations.applySettings({ field: 'globalName' });
|
|
expect(renderToStaticMarkup(React.createElement(Foo, null))).toEqual('<div>globalName</div>');
|
|
});
|
|
it('can receive scoped customizations', function () {
|
|
Customizations.applySettings({ field: 'globalName' });
|
|
Customizations.applyScopedSettings('Foo', { field: 'scopedName' });
|
|
expect(renderToStaticMarkup(React.createElement(Foo, null))).toEqual('<div>scopedName</div>');
|
|
});
|
|
it('can ignore scoped customizations that do not apply', function () {
|
|
Customizations.applySettings({ field: 'globalName' });
|
|
Customizations.applyScopedSettings('Bar', { field: 'scopedName' });
|
|
expect(renderToStaticMarkup(React.createElement(Foo, null))).toEqual('<div>globalName</div>');
|
|
});
|
|
it('can accept props over global/scoped values', function () {
|
|
Customizations.applySettings({ field: 'globalName' });
|
|
Customizations.applyScopedSettings('Foo', { field: 'scopedName' });
|
|
expect(renderToStaticMarkup(React.createElement(Foo, { field: "name" }))).toEqual('<div>name</div>');
|
|
});
|
|
});
|
|
//# sourceMappingURL=customizable.server.test.js.map
|