-
Notifications
You must be signed in to change notification settings - Fork 414
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#671: updated substring replacement function regex
- Loading branch information
1 parent
0e2fbaa
commit f331d8c
Showing
11 changed files
with
7,855 additions
and
7,969 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
frontend/static/__tests__/dtale/replacement/partial-test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import { ReactWrapper } from 'enzyme'; | ||
import { act } from 'react-dom/test-utils'; | ||
|
||
import { SaveAs } from '../../../popups/create/CreateColumnState'; | ||
import CreateReplace, { CreateReplaceProps } from '../../../popups/create/CreateReplace'; | ||
import * as ReplaceUtils from '../../../popups/create/CreateReplace'; | ||
import { ReplacementType } from '../../../popups/replacement/CreateReplacementState'; | ||
|
||
import * as TestSupport from './CreateReplacement.test.support'; | ||
|
||
describe('Strings', () => { | ||
const spies = new TestSupport.Spies(); | ||
let result: ReactWrapper; | ||
|
||
beforeEach(async () => { | ||
spies.setupMockImplementations(); | ||
spies.useSelectorSpy.mockReturnValue({ | ||
dataId: '1', | ||
chartData: { visible: true, propagateState: spies.propagateStateSpy, selectedCol: 'col3' }, | ||
}); | ||
result = await spies.setupWrapper(); | ||
result = await spies.clickBuilder(result, 'Replace Substring'); | ||
}); | ||
|
||
afterEach(() => spies.afterEach()); | ||
|
||
afterAll(() => spies.afterAll()); | ||
|
||
const findReplace = (): ReactWrapper<CreateReplaceProps, Record<string, any>> => result.find(CreateReplace); | ||
|
||
it('handles partial replacement w/ new col', async () => { | ||
expect(findReplace()).toHaveLength(1); | ||
result = await spies.setName(result, 'cut_col'); | ||
await act(async () => { | ||
findReplace() | ||
.find('div.form-group') | ||
.first() | ||
.find('input') | ||
.simulate('change', { target: { value: 'nan' } }); | ||
}); | ||
result = result.update(); | ||
await act(async () => { | ||
findReplace() | ||
.find('div.form-group') | ||
.at(1) | ||
.find('input') | ||
.simulate('change', { target: { value: 'nan' } }); | ||
}); | ||
result = result.update(); | ||
await spies.validateCfg(result, { | ||
type: ReplacementType.PARTIAL, | ||
cfg: { search: 'nan', replacement: 'nan', col: 'col3', caseSensitive: false, regex: false }, | ||
col: 'col3', | ||
saveAs: SaveAs.NEW, | ||
name: 'cut_col', | ||
}); | ||
}); | ||
|
||
it('handles partial replacement', async () => { | ||
const validationSpy = jest.spyOn(ReplaceUtils, 'validateReplaceCfg'); | ||
await act(async () => { | ||
findReplace() | ||
.find('div.form-group') | ||
.first() | ||
.find('input') | ||
.simulate('change', { target: { value: 'A' } }); | ||
}); | ||
result = result.update(); | ||
await act(async () => { | ||
findReplace().find('div.form-group').at(2).find('i').simulate('click'); | ||
}); | ||
result = result.update(); | ||
await act(async () => { | ||
findReplace().find('div.form-group').last().find('i').simulate('click'); | ||
}); | ||
result = result.update(); | ||
await act(async () => { | ||
findReplace() | ||
.find('div.form-group') | ||
.at(1) | ||
.find('input') | ||
.simulate('change', { target: { value: 'nan' } }); | ||
}); | ||
result = result.update(); | ||
result = await spies.executeSave(result); | ||
expect(validationSpy).toHaveBeenLastCalledWith(expect.any(Function), { | ||
search: 'A', | ||
replacement: 'nan', | ||
col: 'col3', | ||
caseSensitive: true, | ||
regex: true, | ||
}); | ||
validationSpy.mockRestore(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.