0.0.3 • Published 4 years ago

json-finger v0.0.3

Weekly downloads
6
License
ISC
Repository
github
Last release
4 years ago

json-finger

根据json结构提取finger对比两个json结构是否一致

详见单元测试

describe('simple usecase', () => {

  it('顺序问题验证 ', function() {
    let a  = toFinger({a:1,b:2});
    let b  = toFinger({b:2,a:1});
    expect(a).toEqual(b);
  });


  it('数字与字符问题 ', function() {
    let a  = toFinger({a:1,1:1231});
    let b  = toFinger({a:2,"1":1123});
    expect(a).toEqual(b);
  });

  it('数组问题验证 ', function() {
    let a  = toFinger({a:1,b:2,arr:[
        {a:1},
        {a:2},
        {a:3},
      ]});
    let b  = toFinger({b:2,a:1,arr:[
        {a:1},
        {a:3},
      ]});
    expect(a).toEqual(b);
  });
});


describe('option 测试', () => {
  it('ignore', async () => {
    let a  = toFinger({a:1,b:2},{
      isIgnore:()=>false
    });
    expect(a).toMatchSnapshot();
  });

  it('beforeFinger', async () => {
    let a  = toFinger({a:1,b:2},{
      beforeFinger:(fingerItems)=>{
        expect(fingerItems).toMatchSnapshot();
        return fingerItems;
      }
    });
    expect(a).toMatchSnapshot();
  });
});
0.0.3

4 years ago

0.0.2

4 years ago

0.0.1-beta.0

4 years ago

0.0.1

4 years ago