Skip to content

When component emit update:modelValue,why v-model value not change #871

@aringlai

Description

@aringlai

test case

test('WDraggable 1 to 2', async () => {
        const list = ref([1, 2, 3, 4, 5]);
        const wrapper = mount(WDraggable, {
            props: {
                modelValue: list
            },
            slots: {
                default: slotsRender
            }
        });
        await nextTick();
        const children = wrapper.findAll('li');
        await children[0].trigger('mousedown');
        expect(children[0].attributes('draggable')).toBe('true');
        await children[1].trigger('dragover');
        await children[1].trigger('dragend');
        await nextTick();
        expect(list.value.join(',')).toBe('2,1,3,4,5');
    });

test result:

  ● Draggable › WDraggable 1 to 2

    expect(received).toBe(expected) // Object.is equality

    Expected: "2,1,3,4,5"
    Received: "1,2,3,4,5"

      37 |         await children[1].trigger('dragover');
      38 |         await children[1].trigger('dragend');
    > 39 |         expect(list.value.join(',')).toBe('2,1,3,4,5');
         |                                      ^
      40 |     });
      41 |
      42 |     test('WDraggable disabled', async () => {

when trigger dragover event,WDraggable component will emit update:modelValue with the param is "[2,1,3,4,5]",I expect list = [2,1,3,4,5],but actually list = [1,2,3,4,5]

Why the v-model value(list) not change?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions