Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: migrations file #6819

Merged
merged 10 commits into from
Jul 20, 2023
4 changes: 3 additions & 1 deletion app/store/migrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,8 @@ export const migrations = {
}
return state;
},
// If you are implementing a migration it will break the migration tests,
// please write a unit for your specific migration version
};

export const version = 19;
export const version = Object.keys(migrations).length - 1;
20 changes: 20 additions & 0 deletions app/store/migrations.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { migrations, version } from './migrations';

describe('Redux Persist Migrations', () => {
it('should apply last migration version and return state', () => {
const oldState = {
recents: '0x1',
};

const migration = migrations[version];

const newState = migration(oldState);

expect(newState).toBeDefined();
expect(newState.recents).toBeUndefined();
});
it('should have all migrations up to the latest version', () => {
// Assert that the latest migration index matches the version constant
expect(Object.keys(migrations).length - 1).toBe(version);
});
});