Skip to content

Commit

Permalink
Rename openModal
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonStoltz committed Nov 4, 2020
1 parent 42cc30b commit 267d233
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('LogRetentionLogic', () => {

const DEFAULT_VALUES = {
logRetention: null,
openModal: null,
openedModal: null,
logsRetentionUpdating: false,
};

Expand Down Expand Up @@ -82,33 +82,33 @@ describe('LogRetentionLogic', () => {
});

describe('actions', () => {
describe('setOpenModal', () => {
describe('openModal', () => {
describe('setOpenedModal', () => {
describe('openedModal', () => {
it('should be set to the provided value', () => {
mount();

LogRetentionLogic.actions.setOpenModal(ELogRetentionOptions.Analytics);
LogRetentionLogic.actions.setOpenedModal(ELogRetentionOptions.Analytics);

expect(LogRetentionLogic.values).toEqual({
...DEFAULT_VALUES,
openModal: ELogRetentionOptions.Analytics,
openedModal: ELogRetentionOptions.Analytics,
});
});
});
});

describe('closeModals', () => {
describe('openModal', () => {
it('resets openModal to null', () => {
describe('openedModal', () => {
it('resets openedModal to null', () => {
mount({
openModal: 'analytics',
openedModal: 'analytics',
});

LogRetentionLogic.actions.closeModals();

expect(LogRetentionLogic.values).toEqual({
...DEFAULT_VALUES,
openModal: null,
openedModal: null,
});
});
});
Expand Down Expand Up @@ -195,17 +195,17 @@ describe('LogRetentionLogic', () => {
jest.spyOn(LogRetentionLogic.actions, 'clearLogRetentionUpdating');
});

describe('openModal', () => {
describe('openedModal', () => {
it('should be reset to null', () => {
mount({
openModal: ELogRetentionOptions.Analytics,
openedModal: ELogRetentionOptions.Analytics,
});

LogRetentionLogic.actions.saveLogRetention(ELogRetentionOptions.Analytics, true);

expect(LogRetentionLogic.values).toEqual({
...DEFAULT_VALUES,
openModal: null,
openedModal: null,
});
});
});
Expand Down Expand Up @@ -265,19 +265,19 @@ describe('LogRetentionLogic', () => {
});
});

it('will call setOpenModal if already enabled', () => {
it('will call setOpenedModal if already enabled', () => {
mount({
logRetention: {
[ELogRetentionOptions.Analytics]: {
enabled: true,
},
},
});
jest.spyOn(LogRetentionLogic.actions, 'setOpenModal');
jest.spyOn(LogRetentionLogic.actions, 'setOpenedModal');

LogRetentionLogic.actions.toggleLogRetention(ELogRetentionOptions.Analytics);

expect(LogRetentionLogic.actions.setOpenModal).toHaveBeenCalledWith(
expect(LogRetentionLogic.actions.setOpenedModal).toHaveBeenCalledWith(
ELogRetentionOptions.Analytics
);
});
Expand Down Expand Up @@ -306,12 +306,12 @@ describe('LogRetentionLogic', () => {
logRetention: {},
});
jest.spyOn(LogRetentionLogic.actions, 'saveLogRetention');
jest.spyOn(LogRetentionLogic.actions, 'setOpenModal');
jest.spyOn(LogRetentionLogic.actions, 'setOpenedModal');

LogRetentionLogic.actions.toggleLogRetention(ELogRetentionOptions.API);

expect(LogRetentionLogic.actions.saveLogRetention).not.toHaveBeenCalled();
expect(LogRetentionLogic.actions.setOpenModal).not.toHaveBeenCalled();
expect(LogRetentionLogic.actions.setOpenedModal).not.toHaveBeenCalled();
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ interface ILogRetentionActions {
option: ELogRetentionOptions,
enabled: boolean
): { option: ELogRetentionOptions; enabled: boolean };
setOpenModal(option: ELogRetentionOptions): { option: ELogRetentionOptions };
setOpenedModal(option: ELogRetentionOptions): { option: ELogRetentionOptions };
toggleLogRetention(option: ELogRetentionOptions): { option: ELogRetentionOptions };
updateLogRetention(logRetention: ILogRetention): { logRetention: ILogRetention };
}

interface ILogRetentionValues {
logRetention: ILogRetention | null;
logsRetentionUpdating: boolean;
openModal: ELogRetentionOptions | null;
openedModal: ELogRetentionOptions | null;
}

export const LogRetentionLogic = kea<MakeLogicType<ILogRetentionValues, ILogRetentionActions>>({
Expand All @@ -37,7 +37,7 @@ export const LogRetentionLogic = kea<MakeLogicType<ILogRetentionValues, ILogRete
closeModals: true,
fetchLogRetention: true,
saveLogRetention: (option, enabled) => ({ enabled, option }),
setOpenModal: (option) => ({ option }),
setOpenedModal: (option) => ({ option }),
toggleLogRetention: (option) => ({ option }),
updateLogRetention: (logRetention) => ({ logRetention }),
}),
Expand Down Expand Up @@ -68,12 +68,12 @@ export const LogRetentionLogic = kea<MakeLogicType<ILogRetentionValues, ILogRete
toggleLogRetention: () => true,
},
],
openModal: [
openedModal: [
null,
{
closeModals: () => null,
saveLogRetention: () => null,
setOpenModal: (_, { option }) => option,
setOpenedModal: (_, { option }) => option,
},
],
}),
Expand Down Expand Up @@ -119,7 +119,7 @@ export const LogRetentionLogic = kea<MakeLogicType<ILogRetentionValues, ILogRete

const optionIsAlreadyEnabled = logRetention.enabled;
if (optionIsAlreadyEnabled) {
actions.setOpenModal(option);
actions.setOpenedModal(option);
} else {
actions.saveLogRetention(option, true);
}
Expand Down

0 comments on commit 267d233

Please sign in to comment.