parent
75626b30db
commit
6042b001f0
8 changed files with 203 additions and 1 deletions
9
util/prop.js
Normal file
9
util/prop.js
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
"use strict"
|
||||
|
||||
module.exports = function (store) {
|
||||
return {
|
||||
get: function() { return store },
|
||||
toJSON: function() { return store },
|
||||
set: function(value) { return store = value }
|
||||
}
|
||||
}
|
||||
|
|
@ -8,8 +8,10 @@
|
|||
<script src="../../ospec/ospec.js"></script>
|
||||
|
||||
<script src="../../util/withAttr.js"></script>
|
||||
<script src="../../util/prop.js"></script>
|
||||
<script src="test-withAttr.js"></script>
|
||||
|
||||
<script src="test-prop.js"></script>
|
||||
|
||||
<script>require("../../ospec/ospec").run()</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
16
util/tests/test-prop.js
Normal file
16
util/tests/test-prop.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
"use strict"
|
||||
|
||||
var o = require("../../ospec/ospec")
|
||||
var prop = require("../../util/prop")
|
||||
|
||||
o.spec("prop", function() {
|
||||
o("works", function() {
|
||||
var p = prop(1)
|
||||
|
||||
o(p.get()).equals(1)
|
||||
o(p.toJSON()).equals(1)
|
||||
o(p.set(2)).equals(2)
|
||||
o(p.get()).equals(2)
|
||||
o(p.toJSON()).equals(2)
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue