2021-09-20 18:22:04 +02:00
|
|
|
import React from 'react';
|
|
|
|
import sinon from 'sinon';
|
|
|
|
import { mount } from 'enzyme';
|
|
|
|
import ExperimentalTab from './experimental-tab.container';
|
|
|
|
|
|
|
|
describe('Experimental Tab', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
|
|
|
const props = {
|
|
|
|
useTokenDetection: true,
|
|
|
|
setUseTokenDetection: sinon.spy(),
|
|
|
|
};
|
|
|
|
|
2022-03-22 20:14:59 +01:00
|
|
|
it('toggles Use Token detection', () => {
|
2021-09-20 18:22:04 +02:00
|
|
|
wrapper = mount(<ExperimentalTab.WrappedComponent {...props} />, {
|
|
|
|
context: {
|
|
|
|
t: (str) => str,
|
2022-03-29 15:46:24 +02:00
|
|
|
trackEvent: () => undefined,
|
2021-09-20 18:22:04 +02:00
|
|
|
},
|
|
|
|
});
|
|
|
|
const useTokenDetection = wrapper.find({ type: 'checkbox' }).at(0);
|
|
|
|
useTokenDetection.simulate('click');
|
|
|
|
expect(props.setUseTokenDetection.calledOnce).toStrictEqual(true);
|
|
|
|
});
|
2022-03-22 20:14:59 +01:00
|
|
|
|
|
|
|
/** TODO: Remove during TOKEN_DETECTION_V2 feature flag clean up */
|
|
|
|
it('should not show use token detection toggle', () => {
|
|
|
|
process.env.TOKEN_DETECTION_V2 = true;
|
|
|
|
wrapper = mount(<ExperimentalTab.WrappedComponent {...props} />, {
|
|
|
|
context: {
|
|
|
|
t: (str) => str,
|
2022-03-29 15:46:24 +02:00
|
|
|
trackEvent: () => undefined,
|
2022-03-22 20:14:59 +01:00
|
|
|
},
|
|
|
|
});
|
|
|
|
const useTokenDetectionText = wrapper.find({ text: 'Use Token Detection' });
|
|
|
|
expect(useTokenDetectionText).toHaveLength(0);
|
|
|
|
});
|
2021-09-20 18:22:04 +02:00
|
|
|
});
|