Skip to content

Commit

Permalink
Fix failing unit test by closing DB consistently in db.delete().
Browse files Browse the repository at this point in the history
Added the option to allow a delete for the purpose of recreation: db.delete({disableAutoOpen: false}).
We did something between before but need to be consistent here.
  • Loading branch information
dfahlander committed Feb 12, 2024
1 parent e146c0c commit 7dcdca1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/classes/dexie/dexie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,12 +349,12 @@ export class Dexie implements IDexie {
}
}

delete(): Promise<void> {
delete(closeOptions = {disableAutoOpen: true}): Promise<void> {
const hasArguments = arguments.length > 0;
const state = this._state;
return new Promise((resolve, reject) => {
const doDelete = () => {
this.close({disableAutoOpen: false});
this.close(closeOptions);
var req = this._deps.indexedDB.deleteDatabase(this.name);
req.onsuccess = wrap(() => {
_onDatabaseDeleted(this._deps, this.name);
Expand Down
2 changes: 1 addition & 1 deletion src/public/types/dexie.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export interface Dexie {

close(closeOptions?: {disableAutoOpen: boolean}): void;

delete(): PromiseExtended<void>;
delete(closeOptions?: {disableAutoOpen: boolean}): PromiseExtended<void>;

isOpen(): boolean;

Expand Down

0 comments on commit 7dcdca1

Please sign in to comment.