-
Notifications
You must be signed in to change notification settings - Fork 149
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
71d4474
commit 83fbad0
Showing
5 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,14 @@ | ||
/*! | ||
* The buffer module from node.js, for the browser. | ||
* | ||
* @author Feross Aboukhadijeh <https://feross.org> | ||
* @license MIT | ||
*/ | ||
|
||
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */ | ||
|
||
/*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */ | ||
|
||
/*! run-parallel-limit. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */ | ||
|
||
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */ |
Large diffs are not rendered by default.
Oops, something went wrong.
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,14 @@ | ||
/*! | ||
* The buffer module from node.js, for the browser. | ||
* | ||
* @author Feross Aboukhadijeh <https://feross.org> | ||
* @license MIT | ||
*/ | ||
|
||
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */ | ||
|
||
/*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */ | ||
|
||
/*! run-parallel-limit. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */ | ||
|
||
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */ |
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,52 @@ | ||
const si = require('../../') | ||
const test = require('tape') | ||
|
||
const sandbox = 'test/sandbox/' | ||
const indexName = sandbox + 'LAST_UPDATED' | ||
|
||
let timestamp | ||
|
||
test('create index', t => { | ||
t.plan(1) | ||
si({ name: indexName }).then(db => { | ||
global[indexName] = db | ||
t.ok(db, !undefined) | ||
}) | ||
}) | ||
|
||
test('timestamp was created', t => { | ||
t.plan(1) | ||
global[indexName].INDEX.STORE.get(['~LAST_UPDATED']).then(lastUpdated => { | ||
timestamp = lastUpdated | ||
return t.pass('timestamp created') | ||
}) | ||
}) | ||
|
||
test('can read LAST_UPDATED timestamp with API', t => { | ||
t.plan(1) | ||
global[indexName].LAST_UPDATED().then(res => t.equals(res, timestamp)) | ||
}) | ||
|
||
test('is valid timestamp', t => { | ||
t.plan(1) | ||
global[indexName].INDEX.STORE.get(['~LAST_UPDATED']).then(lastUpdated => | ||
t.ok(new Date(lastUpdated)) | ||
) | ||
}) | ||
|
||
test('update index', t => { | ||
t.plan(1) | ||
global[indexName] | ||
.PUT([ | ||
{ | ||
_id: 0, | ||
body: 'test doc' | ||
} | ||
]) | ||
.then(res => t.ok(true)) | ||
}) | ||
|
||
test('LAST_UPDATED timestamp has increased', t => { | ||
t.plan(1) | ||
global[indexName].LAST_UPDATED().then(res => t.ok(res > timestamp)) | ||
}) |