2022-04-20 10:08:49 -07:00
|
|
|
import { getSettings } from 'soapbox/actions/settings';
|
|
|
|
import { createTestStore, rootState } from 'soapbox/jest/test-helpers';
|
2022-04-12 06:51:28 -07:00
|
|
|
|
2022-04-20 10:08:49 -07:00
|
|
|
import { ONBOARDING_VERSION, endOnboarding } from '../onboarding';
|
2022-04-12 06:51:28 -07:00
|
|
|
|
|
|
|
describe('endOnboarding()', () => {
|
2022-04-20 10:08:49 -07:00
|
|
|
it('updates the onboardingVersion setting', async() => {
|
|
|
|
const store = createTestStore(rootState);
|
2022-04-12 06:51:28 -07:00
|
|
|
|
2022-04-20 10:08:49 -07:00
|
|
|
// Sanity check:
|
|
|
|
// `onboardingVersion` should be `0` by default
|
|
|
|
const initialVersion = getSettings(store.getState()).get('onboardingVersion');
|
|
|
|
expect(initialVersion).toBe(0);
|
2022-04-12 06:51:28 -07:00
|
|
|
|
|
|
|
await store.dispatch(endOnboarding());
|
|
|
|
|
2022-04-20 10:08:49 -07:00
|
|
|
// After dispatching, `onboardingVersion` is updated
|
|
|
|
const updatedVersion = getSettings(store.getState()).get('onboardingVersion');
|
|
|
|
expect(updatedVersion).toBe(ONBOARDING_VERSION);
|
|
|
|
|
|
|
|
// Sanity check: `updatedVersion` is greater than `initialVersion`
|
|
|
|
expect(updatedVersion > initialVersion).toBe(true);
|
2022-04-12 06:51:28 -07:00
|
|
|
});
|
|
|
|
});
|