Skip to content

Commit

Permalink
accountsReducer tests [nfc]: Group lastDismissedServerPushSetupNotice…
Browse files Browse the repository at this point in the history
… tests
  • Loading branch information
chrisbobbe committed Jan 23, 2024
1 parent 18dd4d2 commit 11b32cb
Showing 1 changed file with 44 additions and 38 deletions.
82 changes: 44 additions & 38 deletions src/account/__tests__/accountsReducer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,54 +223,60 @@ describe('accountsReducer', () => {
});

describe('EventTypes.realm, op update_dict', () => {
const stateWithDismissedNotice = [
{ ...eg.plusReduxState.accounts[0], lastDismissedServerPushSetupNotice: new Date() },
];
const stateWithoutDismissedNotice = [
{ ...eg.plusReduxState.accounts[0], lastDismissedServerPushSetupNotice: null },
];

const eventWith = (data: RealmUpdateDictEvent['data']) => ({
type: EVENT,
event: { id: 0, type: EventTypes.realm, op: 'update_dict', property: 'default', data },
});

test('data.push_notifications_enabled is true, on state with dismissed notice', () => {
expect(
accountsReducer(stateWithDismissedNotice, eventWith({ push_notifications_enabled: true })),
).toEqual(stateWithoutDismissedNotice);
});
describe('lastDismissedServerPushSetupNotice', () => {
const stateWithDismissedNotice = [
{ ...eg.plusReduxState.accounts[0], lastDismissedServerPushSetupNotice: new Date() },
];
const stateWithoutDismissedNotice = [
{ ...eg.plusReduxState.accounts[0], lastDismissedServerPushSetupNotice: null },
];

test('data.push_notifications_enabled is true, on state without dismissed notice', () => {
const actualState = accountsReducer(
stateWithoutDismissedNotice,
eventWith({ push_notifications_enabled: true }),
);
expect(actualState).toEqual(stateWithoutDismissedNotice);
});
test('data.push_notifications_enabled is true, on state with dismissed notice', () => {
const actualState = accountsReducer(
stateWithDismissedNotice,
eventWith({ push_notifications_enabled: true }),
);
expect(actualState).toEqual(stateWithoutDismissedNotice);
});

test('data.push_notifications_enabled is false, on state with dismissed notice', () => {
expect(
accountsReducer(stateWithDismissedNotice, eventWith({ push_notifications_enabled: false })),
).toEqual(stateWithDismissedNotice);
});
test('data.push_notifications_enabled is true, on state without dismissed notice', () => {
const actualState = accountsReducer(
stateWithoutDismissedNotice,
eventWith({ push_notifications_enabled: true }),
);
expect(actualState).toEqual(stateWithoutDismissedNotice);
});

test('data.push_notifications_enabled is false, on state without dismissed notice', () => {
const actualState = accountsReducer(
stateWithoutDismissedNotice,
eventWith({ push_notifications_enabled: false }),
);
expect(actualState).toEqual(stateWithoutDismissedNotice);
});
test('data.push_notifications_enabled is false, on state with dismissed notice', () => {
const actualState = accountsReducer(
stateWithDismissedNotice,
eventWith({ push_notifications_enabled: false }),
);
expect(actualState).toEqual(stateWithDismissedNotice);
});

test('data.push_notifications_enabled is absent, on state with dismissed notice', () => {
const actualState = accountsReducer(stateWithDismissedNotice, eventWith({}));
expect(actualState).toEqual(stateWithDismissedNotice);
});
test('data.push_notifications_enabled is false, on state without dismissed notice', () => {
const actualState = accountsReducer(
stateWithoutDismissedNotice,
eventWith({ push_notifications_enabled: false }),
);
expect(actualState).toEqual(stateWithoutDismissedNotice);
});

test('data.push_notifications_enabled is absent, on state with dismissed notice', () => {
const actualState = accountsReducer(stateWithDismissedNotice, eventWith({}));
expect(actualState).toEqual(stateWithDismissedNotice);
});

test('data.push_notifications_enabled is absent, on state without dismissed notice', () => {
const actualState = accountsReducer(stateWithoutDismissedNotice, eventWith({}));
expect(actualState).toEqual(stateWithoutDismissedNotice);
test('data.push_notifications_enabled is absent, on state without dismissed notice', () => {
const actualState = accountsReducer(stateWithoutDismissedNotice, eventWith({}));
expect(actualState).toEqual(stateWithoutDismissedNotice);
});
});
});
});

0 comments on commit 11b32cb

Please sign in to comment.