forked from jakearchibald/idb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f113db4
commit c8cd1a9
Showing
5 changed files
with
72 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import "babelify/node_modules/babel-core/node_modules/regenerator/runtime"; | ||
import assert from "assert"; | ||
|
||
describe('IDB interface', () => { | ||
before(() => { | ||
return IDB.delete('tmp-db'); | ||
}); | ||
|
||
it('exists on window', () => { | ||
assert('IDB' in self); | ||
}); | ||
|
||
it('has open and delete methods', () => { | ||
assert('open' in IDB); | ||
assert('delete' in IDB); | ||
}); | ||
|
||
it('stuff', async () => { | ||
let db = await IDB.open('tmp-db', 1, upgradeDb => { | ||
switch (upgradeDb.oldVersion) { | ||
case 0: | ||
upgradeDb.createObjectStore("my-store", { | ||
keyPath: '' | ||
}); | ||
} | ||
}); | ||
|
||
let tx = db.transaction('my-store', 'readwrite'); | ||
let store = tx.objectStore('my-store'); | ||
store.put('foo'); | ||
store.put('bar'); | ||
store.put('baz'); | ||
|
||
let cursor = await db.transaction('my-store').objectStore('my-store').openCursor(); | ||
|
||
while (cursor) { | ||
console.log(cursor.value); | ||
cursor = await cursor.continue(); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters