Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'test/bucket/delta.ts')
-rw-r--r--test/bucket/delta.ts90
1 files changed, 90 insertions, 0 deletions
diff --git a/test/bucket/delta.ts b/test/bucket/delta.ts
index ba1d192..a729f29 100644
--- a/test/bucket/delta.ts
+++ b/test/bucket/delta.ts
@@ -89,6 +89,96 @@ describe( 'Delta', () =>
dest_data: { foo: [ '' ] },
expected: {},
},
+ {
+ label: "",
+ src_data: { foo: [ 'bar', 'baz' ] },
+ dest_data: { foo: [ 'change', 'baz' ] },
+ data: { foo: [ 'change', 'baz' ] },
+ diff: { foo: [ 'change' ] },
+ },
+ {
+ label: "",
+ src_data: { foo: [ 'bar', 'baz' ] },
+ dest_data: { foo: [ 'bar', 'change' ] },
+ data: { foo: [ 'bar', 'change' ] },
+ diff: { foo: [ , 'change' ] },
+ },
+ {
+ label: "",
+ src_data: { foo: [ 'bar', 'baz' ] },
+ dest_data: { foo: [ undefined, 'change' ] },
+ data: { foo: [ 'bar', 'change' ] },
+ diff: { foo: [ , 'change' ] },
+ },
+ {
+ label: "",
+ src_data: { foo: [ 'bar', 'baz' ] },
+ dest_data: { foo: [ undefined, 'baz' ] },
+ data: { foo: [ 'bar', 'baz' ] },
+ diff: {},
+ },
+ {
+ label: "",
+ src_data: { foo: [ 'bar', 'baz' ] },
+ dest_data: { foo: [ 'bar', undefined ] },
+ data: { foo: [ 'bar', 'baz' ] },
+ diff: {},
+ },
+ {
+ label: "",
+ src_data: { foo: [ 'bar', 'baz' ] },
+ dest_data: { foo: [ 'bar', null ] },
+ data: { foo: [ 'bar' ] },
+ diff: { foo: [ , null ] },
+ },
+ {
+ label: "",
+ src_data: { foo: [ 'bar', 'baz' ] },
+ dest_data: { foo: [ 'bar', 'baz', null ] },
+ data: { foo: [ 'bar', 'baz' ] },
+ diff: {},
+ },
+ {
+ label: "",
+ src_data: { foo: [ 'bar', 'baz' ] },
+ dest_data: { foo: [ 'bar', 'baz', 'quux' ] },
+ data: { foo: [ 'bar', 'baz', 'quux' ] },
+ diff: { foo: [ , , 'quux' ]},
+ },
+ {
+ label: "",
+ src_data: { foo: [ 'bar', 'baz' ] },
+ dest_data: { foo: [] },
+ data: { foo: [ 'bar', 'baz' ] },
+ diff: {},
+ },
+
+ // null not at end of set means unchanged
+ {
+ label: "",
+ src_data: { foo: [ 'bar', 'baz', 'quux' ] },
+ dest_data: { foo: [ null, null, 'quux' ] },
+ data: { foo: [ 'bar', 'baz', 'quux' ] },
+ diff: {},
+ },
+ // but the last one is
+ {
+ label: "",
+ src_data: { foo: [ 'bar', 'baz', 'quux' ] },
+ dest_data: { foo: [ null, 'baz', null ] },
+ data: { foo: [ 'bar', 'baz' ] },
+ diff: { foo: [ , , null ] },
+ },
+ // given a string of nulls, only the last one is terminating; the
+ // rest are interpreted as undefined (because JSON serializes
+ // undefined values to `null' -_-)
+ {
+ label: "",
+ src_data: { foo: [ 'bar', 'baz', 'quux' ] },
+ dest_data: { foo: [ null, null, null ] },
+ data: { foo: [ 'bar', 'baz' ] },
+ diff: { foo: [ , , null ] },
+ },
] ).forEach( ( { label, src_data, dest_data, expected } ) =>
{
it( label, () =>