File size: 875 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import * as React from 'react';

import demoTest, { rootPropsTest } from '../../../tests/shared/demoTest';
import { fireEvent } from '../../../tests/utils';

demoTest('mentions', {
  testRootProps: false,
});

rootPropsTest(
  'mentions',
  (Mentions, props) => (
    <Mentions
      {...props}
      value="@"
      options={[
        {
          value: 'afc163',
          label: 'afc163',
        },
      ]}
    />
  ),
  {
    afterRender: (container) => {
      const char = '@';

      const myKeyEvent = {
        which: char.charCodeAt(0),
        key: char,
        target: {
          value: char,
          selectionStart: char.length,
        },
      };

      fireEvent.keyDown(container.querySelector('textarea')!, myKeyEvent);
    },
    findRootElements: () => document.querySelectorAll('.ant-mentions, .ant-mentions-dropdown'),
    expectCount: 2,
  },
);