Skip to content

Commit

Permalink
feat(editors): convert jQuery to native element on slider editor
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed May 24, 2021
1 parent 6709f5d commit 3181cf0
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 88 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 4
insert_final_newline = true
insert_final_newline = false
trim_trailing_whitespace = true

[*]
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
* **services:** add onBeforeResizeByContent (onAfter) ([3e99fab](https://github.com/ghiscoding/slickgrid-universal/commit/3e99fabb8554161e4301c0596eaebd9e0d246de7))
* **styling:** add new marker material icons for project ([9b386fa](https://github.com/ghiscoding/slickgrid-universal/commit/9b386fa3e6af8e76cf4beb5aa0b5322db2f270af))
* **tree:** improve Tree Data speed considerably ([5487798](https://github.com/ghiscoding/slickgrid-universal/commit/548779801d06cc9ae7e319e72d351c8a868ed79f))
* **editors:** replace jQuery with native elements ([d6e8f4e](https://github.com/ghiscoding/slickgrid-universal/commit/d6e8f4e59823673df290b179d7ee277e3d7bb1af))

# [0.13.0](https://github.com/ghiscoding/slickgrid-universal/compare/v0.12.0...v0.13.0) (2021-04-27)

Expand Down
2 changes: 1 addition & 1 deletion packages/common/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
* add few pubsub events to help with big dataset ([360c62c](https://github.com/ghiscoding/slickgrid-universal/commit/360c62cb0979792dddef8fab39383266c0d855e3))
* add optional child value prefix to Tree Formatter ([9da9662](https://github.com/ghiscoding/slickgrid-universal/commit/9da966298120686929ab3dd2f276574d7f6c8c7e))
* **tree:** improve Tree Data speed considerably ([5487798](https://github.com/ghiscoding/slickgrid-universal/commit/548779801d06cc9ae7e319e72d351c8a868ed79f))

* **editors:** replace jQuery with native elements ([d6e8f4e](https://github.com/ghiscoding/slickgrid-universal/commit/d6e8f4e59823673df290b179d7ee277e3d7bb1af))



Expand Down
24 changes: 11 additions & 13 deletions packages/common/src/editors/__tests__/sliderEditor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ describe('SliderEditor', () => {

expect(editor.getValue()).toBe('213');
expect(editorElm).toBeTruthy();
expect(editorInputElm[0].defaultValue).toBe('0');
expect(editorInputElm.defaultValue).toBe('0');
});

it('should update slider number every time a change event happens on the input slider', () => {
Expand Down Expand Up @@ -231,7 +231,7 @@ describe('SliderEditor', () => {
editor.setValue(45);

const editorElm = divContainer.querySelector('.slider-editor input.editor-price') as HTMLInputElement;
editorElm.dispatchEvent(new CustomEvent('change'));
editorElm.dispatchEvent(new Event('change'));
expect(editor.isValueChanged()).toBe(true);
});

Expand All @@ -241,7 +241,7 @@ describe('SliderEditor', () => {
editor.loadValue(mockItemData);

const editorElm = divContainer.querySelector('.slider-editor input.editor-price') as HTMLInputElement;
editorElm.dispatchEvent(new CustomEvent('change'));
editorElm.dispatchEvent(new Event('change'));

expect(editor.isValueChanged()).toBe(false);
});
Expand All @@ -252,7 +252,7 @@ describe('SliderEditor', () => {
editor.loadValue(mockItemData);

const editorElm = divContainer.querySelector('.slider-editor input.editor-price') as HTMLInputElement;
editorElm.dispatchEvent(new CustomEvent('change'));
editorElm.dispatchEvent(new Event('change'));

expect(editor.isValueChanged()).toBe(false);
});
Expand All @@ -264,7 +264,7 @@ describe('SliderEditor', () => {
editor.loadValue(mockItemData);

const editorElm = divContainer.querySelector('.slider-editor input.editor-price') as HTMLInputElement;
editorElm.dispatchEvent(new CustomEvent('change'));
editorElm.dispatchEvent(new Event('change'));

expect(editor.isValueChanged()).toBe(false);
});
Expand Down Expand Up @@ -426,8 +426,7 @@ describe('SliderEditor', () => {
const spySave = jest.spyOn(editor, 'save');
const editorElm = editor.editorInputDomElement;

editorElm.trigger('mouseup');
editorElm[0].dispatchEvent(new (window.window as any).Event('mouseup'));
editorElm.dispatchEvent(new MouseEvent('mouseup', { bubbles: true, cancelable: true }));
jest.runAllTimers(); // fast-forward timer

expect(editor.isValueTouched()).toBe(true);
Expand Down Expand Up @@ -514,8 +513,8 @@ describe('SliderEditor', () => {
formValues: { price: 0 }, editors: {}, triggeredBy: 'user',
}, expect.anything());
expect(disableSpy).toHaveBeenCalledWith(true);
expect(editor.editorInputDomElement.attr('disabled')).toEqual('disabled');
expect(editor.editorInputDomElement.val()).toEqual('0');
expect(editor.editorInputDomElement.disabled).toBeTruthy();
expect(editor.editorInputDomElement.value).toEqual('0');
});

it('should call "show" and expect the DOM element to become disabled and empty when "onBeforeEditCell" returns false', () => {
Expand All @@ -539,8 +538,8 @@ describe('SliderEditor', () => {
formValues: {}, editors: {}, triggeredBy: 'user',
}, expect.anything());
expect(disableSpy).toHaveBeenCalledWith(true);
expect(editor.editorInputDomElement.attr('disabled')).toEqual('disabled');
expect(editor.editorInputDomElement.val()).toEqual('0');
expect(editor.editorInputDomElement.disabled).toBeTruthy();
expect(editor.editorInputDomElement.value).toEqual('0');
});

it('should expect "onCompositeEditorChange" to have been triggered with the new value showing up in its "formValues" object', () => {
Expand All @@ -555,8 +554,7 @@ describe('SliderEditor', () => {
editor.loadValue(mockItemData);
editor.setValue(93);
const editorElm = editor.editorInputDomElement;
editorElm.trigger('mouseup');
editorElm[0].dispatchEvent(new (window.window as any).Event('mouseup'));
editorElm.dispatchEvent(new MouseEvent('mouseup', { bubbles: true, cancelable: true }));

expect(getCellSpy).toHaveBeenCalled();
expect(editor.isValueTouched()).toBe(true);
Expand Down
Loading

0 comments on commit 3181cf0

Please sign in to comment.