[Feature] Dashboard filter indicators (#7908)

* dashboard filter indicators

* add/fix unit tests
This commit is contained in:
Grace Guo
2019-08-21 17:34:08 -07:00
committed by GitHub
parent 0fd7364503
commit 40776bd547
74 changed files with 2455 additions and 454 deletions

View File

@@ -28,6 +28,19 @@ describe('AnchorLink', () => {
anchorLinkId: 'CHART-123',
};
beforeEach(() => {
global.window = Object.create(window);
Object.defineProperty(window, 'location', {
value: {
hash: '#' + props.anchorLinkId,
},
});
});
afterEach(() => {
delete global.window.location.value;
});
it('should scroll the AnchorLink into view upon mount', () => {
const callback = sinon.spy();
const clock = sinon.useFakeTimers();
@@ -35,11 +48,7 @@ describe('AnchorLink', () => {
scrollIntoView: callback,
});
const wrapper = shallow(<AnchorLink {...props} />);
wrapper.instance().getLocationHash = () => (props.anchorLinkId);
wrapper.update();
wrapper.instance().componentDidMount();
shallow(<AnchorLink {...props} />);
clock.tick(2000);
expect(callback.callCount).toEqual(1);
stub.restore();