fixed uniqueid so that it is a function as expected by index.js and elsewhere
also added test for uniqueid. only test that two calls to uniqueid return unique enties. had to modify the output slightly and added a counter to the system otherwise two back to back calls would return the same value.
This commit is contained in:
@@ -1 +1,8 @@
|
|||||||
module.exports = "pjax" + (new Date().getTime())
|
module.exports = (function() {
|
||||||
|
var counter = 0
|
||||||
|
return function() {
|
||||||
|
var id = ("pjax" + (new Date().getTime())) + "_" + counter
|
||||||
|
counter++
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
|||||||
12
tests/lib/uniqueid.js
Normal file
12
tests/lib/uniqueid.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
var tape = require("tape")
|
||||||
|
|
||||||
|
var uniqueid = require("../../lib/uniqueid.js")
|
||||||
|
|
||||||
|
tape("test uniqueid", function(t) {
|
||||||
|
var a = uniqueid()
|
||||||
|
var b = uniqueid()
|
||||||
|
|
||||||
|
t.notEqual(a,b,"Two calls to uniqueid produce different values")
|
||||||
|
|
||||||
|
t.end()
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user