diff --git a/Cargo.toml b/Cargo.toml index 05ba7e4..27d69e3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,17 +23,17 @@ path = "src/lib.rs" crate-type = ["cdylib", "rlib"] [dependencies] -idb = { version = "0.6.2", features = ["builder"] } -thiserror = "1.0.61" -wasm-bindgen = "0.2.92" +idb = { version = "0.6", features = ["builder"] } +thiserror = "1" +wasm-bindgen = "0.2" [dev-dependencies] -serde = { version = "1.0.164", features = ["derive"] } -serde_json = "1.0.97" -serde-wasm-bindgen = "0.5.0" -wasm-bindgen-test = "0.3.37" -js-sys = "0.3.69" -num-traits = { version = "0.2.19", default-features = false } +serde = { version = "1", features = ["derive"] } +serde_json = "1" +serde-wasm-bindgen = "0.6" +wasm-bindgen-test = "0.3" +js-sys = "0.3" +num-traits = { version = "0.2", default-features = false } [profile.release] # Tell `rustc` to optimize for small code size. diff --git a/tests/web.rs b/tests/web.rs index c0e5489..e9983ff 100644 --- a/tests/web.rs +++ b/tests/web.rs @@ -46,9 +46,12 @@ struct InvoiceRequest<'a> { /// Creates a database async fn create_db() -> Rexie { assert!(Rexie::delete("test").await.is_ok()); + create_db_with_version(1).await +} +async fn create_db_with_version(version: u32) -> Rexie { let rexie = Rexie::builder("test") - .version(1) + .version(version) .add_object_store( ObjectStore::new("employees") .key_path("id") @@ -69,8 +72,12 @@ async fn create_db() -> Rexie { /// Checks basic details of the database async fn basic_test_db(rexie: &Rexie) { + basic_test_db_with_version(rexie, 1).await; +} + +async fn basic_test_db_with_version(rexie: &Rexie, version: u32) { assert_eq!(rexie.name(), "test"); - assert_eq!(rexie.version(), Ok(1)); + assert_eq!(rexie.version(), Ok(version)); assert_eq!( rexie.store_names(), vec!["departments", "employees", "invoices"] @@ -524,3 +531,15 @@ async fn test_add_all_pass() { close_and_delete_db(rexie).await; } + +#[wasm_bindgen_test] +async fn test_db_reopen() { + let rexie = create_db().await; + basic_test_db(&rexie).await; + rexie.close(); + + let rexie = create_db_with_version(2).await; + basic_test_db_with_version(&rexie, 2).await; + + close_and_delete_db(rexie).await; +}