UNPKG

1.18 kBJavaScriptView Raw
1/**
2 * Test case for apemanstore.
3 * Runs with mocha.
4 */
5'use strict'
6
7const Apemanstore = require('../lib/apemanstore.js')
8const assert = require('assert')
9const co = require('co')
10
11describe('apemanstore', function () {
12 this.timeout(3000)
13
14 before(() => co(function * () {
15
16 }))
17
18 after(() => co(function * () {
19
20 }))
21
22 it('Apemanstore', () => co(function * () {
23 let store = new Apemanstore()
24 assert.ok(store)
25 store.set('spins', { rootSpinning: true })
26 assert.deepEqual(store.get('spins'), { rootSpinning: true })
27
28 let store2 = store.sub('entries/products')
29 store2.set('list', [ { name: 'Wonderful-Box' } ])
30 store2.push('list', { name: 'Yellow-Window' })
31 assert.deepEqual(store2.toJSON(), {
32 list: [
33 { name: 'Wonderful-Box' },
34 { name: 'Yellow-Window' }
35 ]
36 })
37
38 let store3 = store.sub('entries').sub('products').sub('meta')
39 store3.set('hasMore', false)
40 assert.deepEqual(store3.toJSON(), { hasMore: false })
41 store3.flip('hasMore')
42 assert.deepEqual(store3.toJSON(), { hasMore: true })
43
44 // console.log(JSON.stringify(store.toJSON(), null, 2))
45 }))
46})
47
48/* global describe, before, after, it */