File size: 740 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 |
import unsetEmptyArray from '../../logic/unsetEmptyArray';
import unset from '../../utils/unset';
jest.mock('../../utils/unset', () => ({
__esModule: true,
default: jest.fn(),
}));
describe('unsetEmptyArray', () => {
const mockedUnset = unset as jest.MockedFunction<typeof unset>;
beforeAll(() => {
mockedUnset.mockClear();
});
it('should call unset when the array is empty', () => {
const ref = { foo: [] as unknown[] };
unsetEmptyArray(ref, 'foo');
expect(mockedUnset).toHaveBeenCalledWith(ref, 'foo');
});
it('should not call unset when the array is not empty', () => {
const ref = { foo: ['data'] };
unsetEmptyArray(ref, 'foo');
expect(mockedUnset).not.toHaveBeenCalled();
});
});
|