Skip to content

The open alternative to Salesforce, designed for AI.

848 B
Raw Blame
import { createWorkerInputSelectionStore } from '../createWorkerInputSelectionStore';
import { installInputSelectionPolyfill } from '../installInputSelectionPolyfill';

describe('installInputSelectionPolyfill', () => {
  it.each(['select', 'setSelectionRange'])(
    'should let an element override %s like a native method',
    (methodName) => {
      const elementPrototype = {};

      installInputSelectionPolyfill({
        elementPrototypes: [elementPrototype],
        selectionStore: createWorkerInputSelectionStore(),
      });

      const element: Record<string, unknown> = Object.create(elementPrototype);
      const overridingMethod = jest.fn();

      expect(element[methodName]).toEqual(expect.any(Function));

      element[methodName] = overridingMethod;

      expect(element[methodName]).toBe(overridingMethod);
    },
  );
});