Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/bucket/delta.ts90
-rw-r--r--test/server/request/DataProcessorTest.ts2
2 files changed, 91 insertions, 1 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, () =>
diff --git a/test/server/request/DataProcessorTest.ts b/test/server/request/DataProcessorTest.ts
index d0e52d8..a3a4d0e 100644
--- a/test/server/request/DataProcessorTest.ts
+++ b/test/server/request/DataProcessorTest.ts
@@ -503,7 +503,7 @@ function createStubs(
function createStubUserRequest( internal: boolean )
{
- return {
+ return <UserRequest>{
getSession: () => ( {
isInternal: () => internal
} )