This commit is contained in:
2024-05-17 18:02:49 +08:00
parent 8407d51fb6
commit b5264dc222
4056 changed files with 308094 additions and 41932 deletions

31
node_modules/store/plugins/observe_test.js generated vendored Normal file
View File

@@ -0,0 +1,31 @@
module.exports = {
plugin: require('./observe'),
setup: setup,
}
function setup(store) {
test('observe', function() {
store.clearAll()
var count = -1
var expect = [undefined]
var obsId = store.observe('foo', function(val, oldVal) {
count += 1
assert(expect[count] == val)
assert(expect[count - 1] == oldVal)
}) // count == 1
store.unobserve(obsId)
expect.push('bar')
store.set('foo', 'bar')
store.observe('foo', function(val, oldVal) {
count += 1
assert(expect[count] == val)
assert(expect[count - 1] == oldVal)
}) // count == 2
expect.push('bar2')
store.set('foo', 'bar2') // count == 3
assert(count + 1 == expect.length)
})
}