File size: 598 Bytes
5893f8f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import test from 'ava'
import SessionMap from '../lib/sessionMap.js'

const sMp = new SessionMap()
const initValue = {
  n: 1,
  obj: {
    s: 'alex',
    n: 2
  },
  arr: [1, 2, 3, 4],
  name: 'bb'
}

test.before(t => {
  sMp.update('a', initValue)
})

test('sessionMap get', t => {
  t.deepEqual(sMp.get('a'), initValue)
})

test('sessionMap find', t => {
  t.deepEqual(sMp.find('n', 1)[0], initValue)
})

test('sessionMap getValue', t => {
  t.is(sMp.getValue('a.obj.s'), 'alex')
})

test('sessionMap update', t => {
  sMp.update('a.obj.s', 'erdun')

  t.is(sMp.getValue('a.obj.s'), 'erdun')
})