mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 15:23:33 +00:00
[PM-6965] Add type Property to MigrationHelper (#8411)
* Add `type` Property to `MigrationHelper` * Fix Tests * Make `type` parameter required * Fix mockHelper.type * Remove `readonly` from `type`
This commit is contained in:
@@ -83,35 +83,35 @@ describe("MigrationBuilder", () => {
|
||||
});
|
||||
|
||||
it("should migrate", async () => {
|
||||
const helper = new MigrationHelper(0, mock(), mock());
|
||||
const helper = new MigrationHelper(0, mock(), mock(), "general");
|
||||
const spy = jest.spyOn(migrator, "migrate");
|
||||
await sut.migrate(helper);
|
||||
expect(spy).toBeCalledWith(helper);
|
||||
});
|
||||
|
||||
it("should rollback", async () => {
|
||||
const helper = new MigrationHelper(1, mock(), mock());
|
||||
const helper = new MigrationHelper(1, mock(), mock(), "general");
|
||||
const spy = jest.spyOn(rollback_migrator, "rollback");
|
||||
await sut.migrate(helper);
|
||||
expect(spy).toBeCalledWith(helper);
|
||||
});
|
||||
|
||||
it("should update version on migrate", async () => {
|
||||
const helper = new MigrationHelper(0, mock(), mock());
|
||||
const helper = new MigrationHelper(0, mock(), mock(), "general");
|
||||
const spy = jest.spyOn(migrator, "updateVersion");
|
||||
await sut.migrate(helper);
|
||||
expect(spy).toBeCalledWith(helper, "up");
|
||||
});
|
||||
|
||||
it("should update version on rollback", async () => {
|
||||
const helper = new MigrationHelper(1, mock(), mock());
|
||||
const helper = new MigrationHelper(1, mock(), mock(), "general");
|
||||
const spy = jest.spyOn(rollback_migrator, "updateVersion");
|
||||
await sut.migrate(helper);
|
||||
expect(spy).toBeCalledWith(helper, "down");
|
||||
});
|
||||
|
||||
it("should not run the migrator if the current version does not match the from version", async () => {
|
||||
const helper = new MigrationHelper(3, mock(), mock());
|
||||
const helper = new MigrationHelper(3, mock(), mock(), "general");
|
||||
const migrate = jest.spyOn(migrator, "migrate");
|
||||
const rollback = jest.spyOn(rollback_migrator, "rollback");
|
||||
await sut.migrate(helper);
|
||||
@@ -120,7 +120,7 @@ describe("MigrationBuilder", () => {
|
||||
});
|
||||
|
||||
it("should not update version if the current version does not match the from version", async () => {
|
||||
const helper = new MigrationHelper(3, mock(), mock());
|
||||
const helper = new MigrationHelper(3, mock(), mock(), "general");
|
||||
const migrate = jest.spyOn(migrator, "updateVersion");
|
||||
const rollback = jest.spyOn(rollback_migrator, "updateVersion");
|
||||
await sut.migrate(helper);
|
||||
@@ -130,7 +130,7 @@ describe("MigrationBuilder", () => {
|
||||
});
|
||||
|
||||
it("should be able to call instance methods", async () => {
|
||||
const helper = new MigrationHelper(0, mock(), mock());
|
||||
const helper = new MigrationHelper(0, mock(), mock(), "general");
|
||||
await sut.with(TestMigratorWithInstanceMethod, 0, 1).migrate(helper);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user