Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add uiFind icons, scroll to first match #367

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add scrollToFirstVisibleSpan tests
Signed-off-by: Everett Ross <reverett@uber.com>
  • Loading branch information
everett980 committed Apr 11, 2019
commit bb66f09b63b7089ef24633c58ef90ba4468310a3
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ describe('<VirtualizedTraceViewImpl>', () => {
detailToggle: jest.fn(),
findMatchesIDs: null,
registerAccessors: jest.fn(),
scrollToFirstVisibleSpan: jest.fn(),
setSpanNameColumnWidth: jest.fn(),
setTrace: jest.fn(),
spanNameColumnWidth: 0.5,
Expand Down Expand Up @@ -343,4 +344,34 @@ describe('<VirtualizedTraceViewImpl>', () => {
).toBe(true);
});
});

describe('handles needToScroll', () => {
beforeEach(() => {
props.scrollToFirstVisibleSpan.mockReset();
});

[[Set, 'childrenHiddenIDs'], [Map, 'detailStates']].forEach(([ConstructorFn, propName]) => {
it(`calls props.scrollToFirstVisibleSpan if ${propName} changes and ${propName}.needToScroll is true`, () => {
expect(props.scrollToFirstVisibleSpan).not.toHaveBeenCalled();

const collectionThatNeedsToScroll = new ConstructorFn();
collectionThatNeedsToScroll.needToScroll = true;

wrapper.setProps({ [propName]: collectionThatNeedsToScroll });
expect(props.scrollToFirstVisibleSpan).toHaveBeenCalledTimes(1);

wrapper.setProps({ [propName]: collectionThatNeedsToScroll });
expect(props.scrollToFirstVisibleSpan).toHaveBeenCalledTimes(1);

const differentCollectionThatAlsoNeedsToScroll = new ConstructorFn();
differentCollectionThatAlsoNeedsToScroll.needToScroll = true;
wrapper.setProps({ [propName]: differentCollectionThatAlsoNeedsToScroll });
expect(props.scrollToFirstVisibleSpan).toHaveBeenCalledTimes(2);

const differentCollectionThatDoesNotNeedToScroll = new ConstructorFn();
wrapper.setProps({ [propName]: differentCollectionThatDoesNotNeedToScroll });
expect(props.scrollToFirstVisibleSpan).toHaveBeenCalledTimes(2);
});
});
});
});