diff --git a/packages/omi/test/index.test.js b/packages/omi/test/index.test.js index 1e26873be..3d2cd7796 100644 --- a/packages/omi/test/index.test.js +++ b/packages/omi/test/index.test.js @@ -1,5 +1,6 @@ import { getUpdatePath } from '../src/define' import { matchGlobalData, needUpdate, fixPath } from '../src/render' +import { npn, nProps } from '../src/util' //proxy test //https://github.com/Palindrom/JSONPatcherProxy/blob/master/test/spec/proxySpec.js @@ -16,7 +17,6 @@ test('getUpdatePath', () => { path = getUpdatePath({ a: 1, b: { c: null } }) expect(path).toEqual({ a: true, 'b.c': true }) - path = getUpdatePath({ a: 1, b: { c: [] }, d: {} }) expect(path).toEqual({ a: true, 'b.c': true, d: true }) @@ -31,8 +31,6 @@ test('getUpdatePath', () => { expect(path).toEqual({ a: true, 'b.c[1]': true, 'b.c[0].e': true, d: true }) }) - - test('matchGlobalData', () => { expect(matchGlobalData(['a'], { a: 1 })).toEqual(true) @@ -47,8 +45,6 @@ test('matchGlobalData', () => { }) - - test('needUpdate', () => { const path = { 'a': true, 'b.c': true, 'd[2][1]': true } expect(needUpdate({ a: 1 }, path)).toEqual(true) @@ -67,10 +63,17 @@ test('needUpdate', () => { }) - - test('fixPath', () => { const path = '/a/b/2/d/e' expect(fixPath(path)).toEqual('a.b[2].d.e') expect(fixPath('/a/b/1/2/3')).toEqual('a.b[1][2][3]') +}) + +test('npn', () => { + expect(npn('ab-cd')).toEqual('abCd') + expect(npn('ab-cd-ef')).toEqual('abCdEf') +}) + +test('nProps', () => { + expect(nProps({ a: { value: 1 }, b: { value: 2 }, abC: { value: 3 } })).toEqual({ a: 1, b: 2, abC: 3 }) }) \ No newline at end of file