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
| import { describe, expect, it } from 'vitest';
|
| import { moveListItem } from '../listSort';
|
| describe('moveListItem', () => {
| it('按可拖动业务行索引向后移动字段', () => {
| const list = ['a', 'b', 'c'];
|
| moveListItem(list, 0, 2);
|
| expect(list).toEqual(['b', 'c', 'a']);
| });
|
| it('按可拖动业务行索引向前移动字段', () => {
| const list = ['a', 'b', 'c'];
|
| moveListItem(list, 2, 0);
|
| expect(list).toEqual(['c', 'a', 'b']);
| });
|
| it('忽略缺失或越界的索引', () => {
| const list = ['a', 'b', 'c'];
|
| moveListItem(list, undefined, 1);
| moveListItem(list, 1, 3);
|
| expect(list).toEqual(['a', 'b', 'c']);
| });
| });
|
|