@knapsack/app
Version:
Build Design Systems with Knapsack
54 lines • 2.27 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const ava_1 = __importDefault(require("ava"));
const file_utils_1 = require("@knapsack/file-utils");
const renderer_utils_1 = require("./renderer-utils");
const format = async (code, codeFormat = 'html') => {
try {
return (0, file_utils_1.formatCode)({ path: `fake-file.${codeFormat}`, contents: code });
}
catch (error) {
console.log(code);
console.log('^^^^^ Original Code ^^^^^');
throw new Error(error.message);
}
};
const slotOptionsComputed = {
cssClasses: ['foo', 'bar'],
styles: {
color: 'red',
flexDirection: 'row',
},
attributes: {
'data-foo': 'bar',
},
wrappingElementName: 'div',
};
(0, ava_1.default)('classAttributeName: className, stylesValueType: string', async (t) => {
const { openTag, closeTag } = (0, renderer_utils_1.createSlotOptionsHtmlTags)({
slotOptionsComputed,
classAttributeName: 'className',
stylesValueType: 'string',
});
t.is(await format(`${openTag}${closeTag}`), await format('<div data-foo="bar" className="foo bar" style="color: red; flex-direction: row;"></div>'));
});
(0, ava_1.default)('classAttributeName: class, stylesValueType: string', async (t) => {
const { openTag } = (0, renderer_utils_1.createSlotOptionsHtmlTags)({
slotOptionsComputed,
classAttributeName: 'class',
stylesValueType: 'string',
});
t.is(await format(openTag), await format('<div data-foo="bar" class="foo bar" style="color: red; flex-direction: row;">'));
});
(0, ava_1.default)('classAttributeName: className, stylesValueType: object', async (t) => {
const { openTag, closeTag } = (0, renderer_utils_1.createSlotOptionsHtmlTags)({
slotOptionsComputed,
classAttributeName: 'className',
stylesValueType: 'object',
});
t.is(await format(`${openTag}${closeTag}`, 'jsx'), await format('<div data-foo="bar" className="foo bar" style={{ color: "red", flexDirection: "row" }}></div>', 'jsx'));
});
//# sourceMappingURL=renderer-utils.test.js.map