style: quality

This commit is contained in:
jansenk
2023-06-12 10:25:04 -04:00
parent e2535b2467
commit 491d870cd2
4 changed files with 16 additions and 15 deletions

View File

@@ -1,5 +1,5 @@
export const analyticsEvents = {
socialSharingSettingChanged: 'edx.social.video_sharing_setting.changed'
}
socialSharingSettingChanged: 'edx.social.video_sharing_setting.changed',
};
export default analyticsEvents
export default analyticsEvents;

View File

@@ -1,7 +1,7 @@
import { useSelector } from 'react-redux';
import analyticsEvents from './constants';
import { sendTrackEvent } from '@edx/frontend-platform/analytics';
import { selectors } from '../../../../../../data/redux';
import analyticsEvents from './constants';
export const handleSocialSharingCheckboxChange = ({ updateField }) => {
const analytics = useSelector(selectors.app.analytics);
@@ -12,7 +12,7 @@ export const handleSocialSharingCheckboxChange = ({ updateField }) => {
{
...analytics,
value: event.target.checked,
}
},
);
updateField({
allowVideoSharing: {
@@ -22,3 +22,5 @@ export const handleSocialSharingCheckboxChange = ({ updateField }) => {
});
};
};
export default handleSocialSharingCheckboxChange;

View File

@@ -1,4 +1,3 @@
import { actions } from '../../../../../../data/redux/app';
import { sendTrackEvent } from '@edx/frontend-platform/analytics';
import analyticsEvents from './constants';
import * as hooks from './hooks';
@@ -18,25 +17,25 @@ jest.mock('@edx/frontend-platform/analytics', () => ({
sendTrackEvent: jest.fn(),
}));
describe('SocialShareWidget hooks', () => {
describe('handleSocialSharingCheckboxChange when', () => {
var onClick, updateField;
let onClick;
let updateField;
describe.each([true, false])('box is toggled', (checked) => {
beforeAll(() => {
jest.resetAllMocks()
updateField = jest.fn()
jest.resetAllMocks();
updateField = jest.fn();
onClick = hooks.handleSocialSharingCheckboxChange({ updateField });
expect(typeof onClick).toBe('function');
onClick({ target: { checked } });
});
it("field is updated", () => {
expect(updateField).toBeCalledWith({"allowVideoSharing": {"value": checked}});
it('field is updated', () => {
expect(updateField).toBeCalledWith({ allowVideoSharing: { value: checked } });
});
it("event tracking is called", () => {
it('event tracking is called', () => {
expect(sendTrackEvent).toBeCalledWith(
analyticsEvents.socialSharingSettingChanged,
{"value": checked}
{ value: checked },
);
});
});

View File

@@ -14,7 +14,7 @@ import {
import { selectors, actions } from '../../../../../../data/redux';
import CollapsibleFormWidget from '../CollapsibleFormWidget';
import messages from './messages';
import * as hooks from './hooks'
import * as hooks from './hooks';
/**
* Collapsible Form widget controlling video thumbnail