testbeats
Version:
Publish test results to Microsoft Teams, Google Chat, Slack and InfluxDB
45 lines (38 loc) • 821 B
JavaScript
const { BasePlatform } = require("./base.platform");
class SlackPlatform extends BasePlatform {
/**
* @param {string|number} text
*/
bold(text) {
if (text) {
return `*${text}*`;
}
return text;
}
/**
* @param {string[]} items - Array of strings to convert to bullet points
* @returns {string} - Formatted bullet points as a string
*/
bullets(items) {
if (!items || !Array.isArray(items) || items.length === 0) {
return '';
}
return this.merge(items.map(item => `• ${item}`));
}
code(text) {
if (text) {
return `\`\`\`${text}\`\`\``;
}
return text;
}
link(text, url) {
if (url) {
if (!text) {
text = url;
}
return `<${url}|${text}>`;
}
return text;
}
}
module.exports = { SlackPlatform }