* Refactor post draft component Re-styled ReadOnly channels Remove filename from upload error * Update canSubmit based on file attachment changes * Fix error message for max file size * Fix select autocomplete values on iOS * Style readonly and refactor accessory view for iOS * Make PostDraft scrollViewNativeID prop not required * Update ReadOnly to have a background with 0.40 opacity * Update max file size error message * Fix shift+enter with HW keyboard
160 lines
3.9 KiB
JavaScript
160 lines
3.9 KiB
JavaScript
// 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: '@channel',
|
|
result: false,
|
|
},
|
|
]) {
|
|
const containsAtChannel = DraftUtils.textContainsAtAllAtChannel(data.text);
|
|
assert.equal(containsAtChannel, data.result, data.text);
|
|
}
|
|
});
|
|
});
|