jest-metadata
Version:
🦸♂️ Superhero power for your Jest reporters! 🦸♀️
36 lines • 1.22 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PlantObject = void 0;
const tslib_1 = require("tslib");
const lodash_snakecase_1 = tslib_1.__importDefault(require("lodash.snakecase"));
class PlantObject {
id;
name;
color;
properties = {};
constructor(config) {
this.id = config.id;
this.name = config.name;
if (config.color) {
this.color = config.color;
}
if (config.properties) {
Object.assign(this.properties, config.properties);
}
}
toString() {
const id = (0, lodash_snakecase_1.default)(this.id);
const name = JSON.stringify(this.name);
const color = this.color ? ` ${this.color}` : '';
return [
`object ${name} as ${id}${color}`,
...Object.entries(this.properties).map(([key, value]) => {
const stringifiedValue = JSON.stringify(value, undefined, 2);
const escapedValue = stringifiedValue.replace(/\n/g, '\\n');
return `${id} : ${key} = ${escapedValue}`;
}),
].join('\n');
}
}
exports.PlantObject = PlantObject;
//# sourceMappingURL=PlantObject.js.map