Files
starface-outlook-sync-addin/node_modules/@fluentui/utilities/lib-amd/customizations/customizable.server.test.js
T
Stefan Hacker 37ad745546 first commit
2026-04-03 09:38:48 +02:00

42 lines
2.4 KiB
JavaScript

define(["require", "exports", "tslib", "react", "react-dom/server", "./customizable", "./Customizations"], function (require, exports, tslib_1, React, server_1, customizable_1, Customizations_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Foo = /** @class */ (function (_super) {
tslib_1.__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 = tslib_1.__decorate([
(0, customizable_1.customizable)('Foo', ['field'])
], Foo);
return Foo;
}(React.Component));
describe('customizable (server-side rendering)', function () {
beforeEach(function () {
Customizations_1.Customizations.reset();
});
it('can receive global customizations', function () {
Customizations_1.Customizations.applySettings({ field: 'globalName' });
expect((0, server_1.renderToStaticMarkup)(React.createElement(Foo, null))).toEqual('<div>globalName</div>');
});
it('can receive scoped customizations', function () {
Customizations_1.Customizations.applySettings({ field: 'globalName' });
Customizations_1.Customizations.applyScopedSettings('Foo', { field: 'scopedName' });
expect((0, server_1.renderToStaticMarkup)(React.createElement(Foo, null))).toEqual('<div>scopedName</div>');
});
it('can ignore scoped customizations that do not apply', function () {
Customizations_1.Customizations.applySettings({ field: 'globalName' });
Customizations_1.Customizations.applyScopedSettings('Bar', { field: 'scopedName' });
expect((0, server_1.renderToStaticMarkup)(React.createElement(Foo, null))).toEqual('<div>globalName</div>');
});
it('can accept props over global/scoped values', function () {
Customizations_1.Customizations.applySettings({ field: 'globalName' });
Customizations_1.Customizations.applyScopedSettings('Foo', { field: 'scopedName' });
expect((0, server_1.renderToStaticMarkup)(React.createElement(Foo, { field: "name" }))).toEqual('<div>name</div>');
});
});
});
//# sourceMappingURL=customizable.server.test.js.map