From 346517b94733924b918b7e8b1ca75c87040d962b Mon Sep 17 00:00:00 2001 From: jos Date: Wed, 20 Dec 2017 08:44:10 +0100 Subject: [PATCH] Fixed some unit tests --- test/actions.test.js | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/test/actions.test.js b/test/actions.test.js index 89de924..16dc815 100644 --- a/test/actions.test.js +++ b/test/actions.test.js @@ -18,14 +18,13 @@ import {patchEson} from '../src/patchEson' // TODO: test remove // TODO: test removeAll -// FIXME: sort root array -// test('sort root Array', t => { -// const eson = jsonToEson([1,3,2]) -// -// t.deepEqual(patchEson(eson, sort(eson, [])), jsonToEson([1,2,3])) -// t.deepEqual(patchEson(eson, sort(eson, [], 'asc')), jsonToEson([1,2,3])) -// t.deepEqual(patchEson(eson, sort(eson, [], 'desc')), jsonToEson([3,2,1])) -// }) +test('sort root Array', t => { + const eson = jsonToEson([1,3,2]) + + assertDeepEqualEson(t, patchEson(eson, sort(eson, [])).data, jsonToEson([1,2,3])) + assertDeepEqualEson(t, patchEson(eson, sort(eson, [], 'asc')).data, jsonToEson([1,2,3])) + assertDeepEqualEson(t, patchEson(eson, sort(eson, [], 'desc')).data, jsonToEson([3,2,1])) +}) test('sort nested Array', t => { const eson = jsonToEson({arr: [4,1,8,5,3,9,2,7,6]}) @@ -47,14 +46,13 @@ test('sort nested Array reverse order', t => { }) -// FIXME: sort root object -// test('sort root Object', t => { -// const eson = jsonToEson({c: 2, b: 3, a:4}) -// -// t.deepEqual(esonToJson(patchEson(eson, sort(eson, [])).data[META].props), ['a', 'b', 'c']) -// t.deepEqual(esonToJson(patchEson(eson, sort(eson, [], 'asc')).data[META].props), ['a', 'b', 'c']) -// t.deepEqual(esonToJson(patchEson(eson, sort(eson, [], 'desc')).data[META].props), ['c', 'b', 'a']) -// }) +test('sort root Object', t => { + const eson = jsonToEson({c: 2, b: 3, a:4}) + + t.deepEqual(patchEson(eson, sort(eson, [])).data[META].props, ['a', 'b', 'c']) + t.deepEqual(patchEson(eson, sort(eson, [], 'asc')).data[META].props, ['a', 'b', 'c']) + t.deepEqual(patchEson(eson, sort(eson, [], 'desc')).data[META].props, ['c', 'b', 'a']) +}) test('sort nested Object', t => { const eson = jsonToEson({obj: {c: 2, b: 3, a:4}})