// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import assert from 'assert'; import * as DraftUtils from './draft'; describe('DraftUtils', () => { test('should return correct @all (same for @channel)', () => { for (const data of [ { text: '', result: false, }, { text: 'all', result: false, }, { text: '@allison', result: false, }, { text: '@ALLISON', result: false, }, { text: '@all123', result: false, }, { text: '123@all', result: false, }, { text: 'hey@all', result: false, }, { text: 'hey@all.com', result: false, }, { text: '@all', result: true, }, { text: '@ALL', result: true, }, { text: '@all hey', result: true, }, { text: 'hey @all', result: true, }, { text: 'HEY @ALL', result: true, }, { text: 'hey @all!', result: true, }, { text: 'hey @all:+1:', result: true, }, { text: 'hey @ALL:+1:', result: true, }, { text: '`@all`', result: false, }, { text: '@someone `@all`', result: false, }, { text: '``@all``', result: false, }, { text: '```@all```', result: false, }, { text: '```\n@all\n```', result: false, }, { text: '```````\n@all\n```````', result: false, }, { text: '```code\n@all\n```', result: false, }, { text: '~~~@all~~~', result: true, }, { text: '~~~\n@all\n~~~', result: false, }, { text: ' /not_cmd @all', result: true, }, { text: '@channel', result: true, }, { text: '@channel.', result: true, }, { text: '@channel/test', result: true, }, { text: 'test/@channel', result: true, }, { text: '@all/@channel', result: true, }, { text: '@cha*nnel*', result: false, }, { text: '@cha**nnel**', result: false, }, { text: '*@cha*nnel', result: false, }, { text: '[@chan](https://google.com)nel', result: false, }, { text: '@cha![](https://myimage)nnel', result: false, }, ]) { const containsAtChannel = DraftUtils.textContainsAtAllAtChannel(data.text); assert.equal(containsAtChannel, data.result, data.text); } }); });