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 () => {
|
||||
const withParams: With = {
|
||||
status: '',
|
||||
|
|
|
@ -167,10 +167,11 @@ export class Client {
|
|||
}
|
||||
|
||||
private mentionText(mention: string) {
|
||||
if (groupMention.includes(mention)) {
|
||||
return `<!${mention}> `;
|
||||
} else if (mention !== '') {
|
||||
const text = mention
|
||||
const normalized = mention.replace(/ /g, '');
|
||||
if (groupMention.includes(normalized)) {
|
||||
return `<!${normalized}> `;
|
||||
} else if (normalized !== '') {
|
||||
const text = normalized
|
||||
.split(',')
|
||||
.map(userId => `<@${userId}>`)
|
||||
.join(' ');
|
||||
|
|
Загрузка…
Ссылка в новой задаче