import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
import { createWrapper } from 'app/test/vitest/helper';
import WorkerNotificationsManager from 'src/pages/Worker/Card/WorkerNotificationsManager.vue';
import { ref } from 'vue';

describe('WorkerNotificationsManager', () => {
    let vm;

    beforeAll(() => {
        vm = createWrapper(WorkerNotificationsManager, {
            global: {
                stubs: ['CrudModel'],
            },
        }).vm;
    });

    afterEach(() => {
        vi.clearAllMocks();
    });

    describe('swapEntry()', () => {
        it('should swap notification', async () => {
            const from = ref(new Map());
            const to = ref(new Map());
            from.value.set(1, { notificationFk: 1 });
            to.value.set(2, { notificationFk: 2 });

            await vm.swapEntry(from.value, to.value, 1);
            expect(to.value.size).toBe(2);
            expect(from.value.size).toBe(0);
        });
    });
});
