<NME> hotTableHelpers.spec.ts
<BEF> import {
  rewriteSettings,
  hotInit,
  prepareSettings,
  propFactory,
  propWatchFactory,
  updateHotSettings
} from '../src/helpers';

describe('rewriteSettings', () => {
    const fakeWatcher = () => {};
    fakeWatcher.prototype.sampleMethod = () => {};
    fakeWatcher.prototype.sampleProperty = null;

    const fakeWatcherInstance = new fakeWatcher();
    fakeWatcherInstance.testedProperty = null;
    fakeWatcherInstance.testedMethod = () => {};

    expect(typeof fakeWatcherInstance.sampleMethod).toEqual('function');
    expect(typeof fakeWatcherInstance.testedMethod).toEqual('function');
    expect(fakeWatcherInstance.sampleProperty).toEqual(null);
    expect(fakeWatcherInstance.testedProperty).toEqual(null);

    let cleanObject: any = rewriteSettings(fakeWatcherInstance);

    expect(typeof cleanObject.sampleMethod).toEqual('undefined');
    expect(typeof cleanObject.testedMethod).toEqual('function');
    expect(cleanObject.sampleProperty).toEqual(void 0);
    expect(cleanObject.testedProperty).toEqual(null);
    expect(Object.prototype.toString.call(cleanObject)).toEqual('[object Object]');
  });
  });
});

describe('hotInit', () => {
  it('should initialize Handsontable and assign it to the `table` property of the provided object', () => {
    const container = document.createElement('DIV');
    container.id = 'hotContainer';
    document.body.appendChild(container);

    const fakeVueComponent: any = {
      $el: document.getElementById('hotContainer')
    };

    expect(typeof fakeVueComponent.hotInstance).toEqual('undefined');

    hotInit.call(fakeVueComponent);

    expect(typeof fakeVueComponent.hotInstance).toEqual('object');
    expect(typeof fakeVueComponent.hotInstance.guid).toEqual('string');

    container.parentNode.removeChild(container);
  });
});

describe('propFactory', () => {
  it('should generate an object containing all the available Handsontable properties and plugin hooks', () => {
    const props: any = propFactory();
    expect(typeof props.startRows).toEqual('object');
    expect(typeof props.startCols).toEqual('object');
    expect(typeof props.data).toEqual('object');
    expect(typeof props.fixedRowsTop).toEqual('object');
    expect(typeof props.afterCreateRow).toEqual('object');
    expect(typeof props.afterGetCellMeta).toEqual('object');
    expect(typeof props.beforeInit).toEqual('object');
    expect(typeof props.randomProp).toEqual('undefined');
  });
});

describe('prepareSettings', () => {
  it('should prepare the settings passed to the component props to be used within Handsontable', () => {
    const propsMock = {
      id: 'hot-id',
      readOnly: true,
      colHeaders: true,
      afterChange: () => 'afterChangeResult',
      settings: {
        rowHeaders: true,
        data: [[1, 2], [3, 4]],
        afterUpdateSettings: () => 'afterUpdateSettingsResult'
      }
    };

    const preparedSettings = prepareSettings(propsMock);

    expect(preparedSettings.readOnly).toBe(true);
    expect(preparedSettings.colHeaders).toBe(true);
    expect(preparedSettings.rowHeaders).toBe(true);
    expect(preparedSettings.data).toEqual([[1, 2], [3, 4]]);
    expect(preparedSettings.afterUpdateSettings()).toBe('afterUpdateSettingsResult');
    expect(preparedSettings.afterChange()).toBe('afterChangeResult');
    expect(preparedSettings.id).toBe(void 0);
    expect(preparedSettings.settings).toBe(void 0);
    expect(preparedSettings.wrapperRendererCacheSize).toBe(void 0);
  });
});
  });
});

describe('updateHotSettings', () => {
  it('should update the previously initialized Handsontable instance with a single changed property', () => {
    const container = document.createElement('DIV');
    container.id = 'hotContainer';
    document.body.appendChild(container);

    const fakeVueComponent: any = {
      $el: document.getElementById('hotContainer')
    };

    expect(typeof fakeVueComponent.hotInstance).toEqual('undefined');

    hotInit.call(fakeVueComponent);

    updateHotSettings.call(fakeVueComponent, 'startCols', 19, {});

    expect(fakeVueComponent.hotInstance.getSettings().startCols).toEqual(19);

    container.parentNode.removeChild(container);
  });
});

describe('prepareSettings', () => {
  it('should prepare the settings object to be used with Handsontable', () => {
    const onPrefixedPropObj = {

<MSG> Add hot-column, hot-editor and hot-renderer. (#105)

* Add the HotColumn component to be used as a child of HotTable to define the column settings. [WIP]

* Fill missing typings.

* Update package-lock.

* Add additional tests.

* Add $router and $store tests + move cache to the HotTable class.

* Fix tests

* Specify additional types.

* Prevent throwing the license key warning in the tests.

* Change the renderer cache type to LRU Map, add tests for the renderer cache.

* Update parts of the test cases to use '@vue/test-utils'

* Fix a problem with HotColumn overwriting the settings passed to HotTable.

* Add 'Symbol' as a possible default value for the 'settings' prop + prevent the test cases from throwing warnings about auto column/row size.

* Remove misleading 'settings' and hook type declarations.

* Don't re-render the TD's contents if it's already rendererd in the viewport.

* Add a base editor component for vue components to extend.

* Rewrite the BaseVueHotEditor to a class.

* Fix tests.

* Update package-lock.

* Make hot-column inject `isRenderer` and `isEditor` properties to the renderer/editor components.

* Add a possibility to declare global editors/renderers as components.

* Add a possibility do set the column settings using a 'settings' prop on 'hot-column'.

* Change where isEditor prop is injected, correct tests etc.

* Correct typo.

* Bump the dependencies to the latest versions.

* Post CR updates:
- rename BaseVueHotEditor to BaseEditorComponent
- make editor components mount into #vueHotEditors element in DOM
- destroy the initial global editors/renderers

* Rename the editor container to `vueHotComponents`, because both editors and renderers are being mounter there (the renderers are later moved to the table cells).

* Remove the unneeded store and router rewriting and fix npm audit errors.

* Remove some of the querySelector logic and additional cleanup.

* Post CR updates.

<DFF> @@ -1,10 +1,8 @@
 import {
   rewriteSettings,
-  hotInit,
   prepareSettings,
   propFactory,
-  propWatchFactory,
-  updateHotSettings
+  propWatchFactory
 } from '../src/helpers';
 
 describe('rewriteSettings', () => {
@@ -32,27 +30,6 @@ describe('rewriteSettings', () => {
   });
 });
 
-describe('hotInit', () => {
-  it('should initialize Handsontable and assign it to the `table` property of the provided object', () => {
-    const container = document.createElement('DIV');
-    container.id = 'hotContainer';
-    document.body.appendChild(container);
-
-    const fakeVueComponent: any = {
-      $el: document.getElementById('hotContainer')
-    };
-
-    expect(typeof fakeVueComponent.hotInstance).toEqual('undefined');
-
-    hotInit.call(fakeVueComponent);
-
-    expect(typeof fakeVueComponent.hotInstance).toEqual('object');
-    expect(typeof fakeVueComponent.hotInstance.guid).toEqual('string');
-
-    container.parentNode.removeChild(container);
-  });
-});
-
 describe('propFactory', () => {
   it('should generate an object containing all the available Handsontable properties and plugin hooks', () => {
     const props: any = propFactory();
@@ -98,28 +75,6 @@ describe('propWatchFactory', () => {
   });
 });
 
-describe('updateHotSettings', () => {
-  it('should update the previously initialized Handsontable instance with a single changed property', () => {
-    const container = document.createElement('DIV');
-    container.id = 'hotContainer';
-    document.body.appendChild(container);
-
-    const fakeVueComponent: any = {
-      $el: document.getElementById('hotContainer')
-    };
-
-    expect(typeof fakeVueComponent.hotInstance).toEqual('undefined');
-
-    hotInit.call(fakeVueComponent);
-
-    updateHotSettings.call(fakeVueComponent, 'startCols', 19, {});
-
-    expect(fakeVueComponent.hotInstance.getSettings().startCols).toEqual(19);
-
-    container.parentNode.removeChild(container);
-  });
-});
-
 describe('prepareSettings', () => {
   it('should prepare the settings object to be used with Handsontable', () => {
     const onPrefixedPropObj = {

Add hot-column, hot-editor and hot-renderer. (#105)