Skip to content

Commit

Permalink
refactor: move test inside the file
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed Jan 6, 2021
1 parent 08f05a3 commit e7d803f
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions packages/common/src/editors/__tests__/autoCompleteEditor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,23 +126,6 @@ describe('AutoCompleteEditor', () => {
expect(disableSpy).toHaveBeenCalledWith(true);
});

describe('collectionOverride callback option', () => {
it('should create the editor and expect a different collection outputed when using the override', () => {
mockColumn.internalColumnEditor = {
collection: [{ value: 'other', label: 'Other' }, { value: 'male', label: 'Male' }, { value: 'female', label: 'Female' }],
collectionOverride: (inputCollection) => inputCollection.filter(item => item.value !== 'other')
};

editor = new AutoCompleteEditor(editorArguments);
editor.destroy();
editor.init();
const editorCount = divContainer.querySelectorAll('input.editor-text.editor-gender').length;

expect(editorCount).toBe(1);
expect(editor.elementCollection).toEqual([{ value: 'male', label: 'Male', labelPrefix: '', labelSuffix: '' }, { value: 'female', label: 'Female', labelPrefix: '', labelSuffix: '' }]);
});
});

it('should initialize the editor even when user define his own editor options', () => {
(mockColumn.internalColumnEditor as ColumnEditor).editorOptions = { minLength: 3 } as AutocompleteOption;
editor = new AutoCompleteEditor(editorArguments);
Expand Down Expand Up @@ -301,6 +284,23 @@ describe('AutoCompleteEditor', () => {
expect(autoCompleteSpy).toHaveBeenCalledWith('option', 'delay', 500);
});

describe('collectionOverride callback option', () => {
it('should create the editor and expect a different collection outputed when using the override', () => {
mockColumn.internalColumnEditor = {
collection: [{ value: 'other', label: 'Other' }, { value: 'male', label: 'Male' }, { value: 'female', label: 'Female' }],
collectionOverride: (inputCollection) => inputCollection.filter(item => item.value !== 'other')
};

editor = new AutoCompleteEditor(editorArguments);
editor.destroy();
editor.init();
const editorCount = divContainer.querySelectorAll('input.editor-text.editor-gender').length;

expect(editorCount).toBe(1);
expect(editor.elementCollection).toEqual([{ value: 'male', label: 'Male', labelPrefix: '', labelSuffix: '' }, { value: 'female', label: 'Female', labelPrefix: '', labelSuffix: '' }]);
});
});

describe('applyValue method', () => {
it('should apply the value to the gender property when it passes validation', () => {
(mockColumn.internalColumnEditor as ColumnEditor).validator = null as any;
Expand Down

0 comments on commit e7d803f

Please sign in to comment.