Merge pull request #32 from 8398a7/feature/26
[#26] If csv contains space, normalize it.
This commit is contained in:
Коммит
6a706b2cad
|
@ -246,6 +246,39 @@ describe('8398a7/action-slack', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('removes csv space', async () => {
|
||||||
|
const withParams: With = {
|
||||||
|
status: '',
|
||||||
|
mention: 'user_id, user_id2',
|
||||||
|
author_name: '',
|
||||||
|
only_mention_fail: '',
|
||||||
|
username: '',
|
||||||
|
icon_emoji: '',
|
||||||
|
icon_url: '',
|
||||||
|
channel: '',
|
||||||
|
};
|
||||||
|
let client = new Client(withParams, process.env.GITHUB_TOKEN, '');
|
||||||
|
const msg = 'hello';
|
||||||
|
|
||||||
|
let text = `<@user_id> <@user_id2> ${successMsg}\n${msg}`;
|
||||||
|
attachments[0].color = 'good';
|
||||||
|
expect(await client.success(msg)).toStrictEqual({
|
||||||
|
attachments,
|
||||||
|
text,
|
||||||
|
});
|
||||||
|
|
||||||
|
withParams.mention = '';
|
||||||
|
withParams.only_mention_fail = 'user_id, user_id2';
|
||||||
|
client = new Client(withParams, process.env.GITHUB_TOKEN, '');
|
||||||
|
|
||||||
|
text = `<@user_id> <@user_id2> ${failMsg}\n${msg}`;
|
||||||
|
attachments[0].color = 'danger';
|
||||||
|
expect(await client.fail(msg)).toStrictEqual({
|
||||||
|
attachments,
|
||||||
|
text,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('returns the expected template', async () => {
|
it('returns the expected template', async () => {
|
||||||
const withParams: With = {
|
const withParams: With = {
|
||||||
status: '',
|
status: '',
|
||||||
|
|
|
@ -167,10 +167,11 @@ export class Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
private mentionText(mention: string) {
|
private mentionText(mention: string) {
|
||||||
if (groupMention.includes(mention)) {
|
const normalized = mention.replace(/ /g, '');
|
||||||
return `<!${mention}> `;
|
if (groupMention.includes(normalized)) {
|
||||||
} else if (mention !== '') {
|
return `<!${normalized}> `;
|
||||||
const text = mention
|
} else if (normalized !== '') {
|
||||||
|
const text = normalized
|
||||||
.split(',')
|
.split(',')
|
||||||
.map(userId => `<@${userId}>`)
|
.map(userId => `<@${userId}>`)
|
||||||
.join(' ');
|
.join(' ');
|
||||||
|
|
Загрузка…
Ссылка в новой задаче