From adfda9ec84ad33ef9fbdef7d0a27b6386fa69cae Mon Sep 17 00:00:00 2001 From: "Thang X. Vu" Date: Tue, 2 Jul 2024 10:57:23 +0700 Subject: [PATCH] test: update test snapshots --- .../__snapshots__/collections.test.ts.snap | 10 ++-- .../test/__snapshots__/deferred.test.ts.snap | 28 +++------- .../test/__snapshots__/instance.test.ts.snap | 5 +- shapes/test/__snapshots__/object.test.ts.snap | 32 +++++------ shapes/test/__snapshots__/record.test.ts.snap | 13 +---- shapes/test/__snapshots__/result.test.ts.snap | 54 +++---------------- shapes/test/__snapshots__/tuple.test.ts.snap | 8 +-- 7 files changed, 43 insertions(+), 107 deletions(-) diff --git a/shapes/test/__snapshots__/collections.test.ts.snap b/shapes/test/__snapshots__/collections.test.ts.snap index d60d993..ca0c1d1 100644 --- a/shapes/test/__snapshots__/collections.test.ts.snap +++ b/shapes/test/__snapshots__/collections.test.ts.snap @@ -26,9 +26,9 @@ snapshot[`\$.set(\$.u8) invalid 123 1`] = `ShapeAssertError: !(value instanceof snapshot[`\$.set(\$.u8) invalid [ 123 ] 1`] = `ShapeAssertError: !(value instanceof ShapeSet)`; -snapshot[`\$.set(\$.u8) invalid Set(1) { null } 1`] = `ShapeAssertError: !(value instanceof ShapeSet)`; +snapshot[`\$.set(\$.u8) invalid Set { null } 1`] = `ShapeAssertError: !(value instanceof ShapeSet)`; -snapshot[`\$.set(\$.u8) invalid Set(5) { 1, 2, 3, -1, 4 } 1`] = `ShapeAssertError: !(value instanceof ShapeSet)`; +snapshot[`\$.set(\$.u8) invalid Set { 1, 2, 3, -1, 4 } 1`] = `ShapeAssertError: !(value instanceof ShapeSet)`; snapshot[`\$.set(\$.u8) invalid ShapeSet { "\$value": \$.i8 } 1`] = `ShapeAssertError: #iterator[3] < 0`; @@ -83,8 +83,8 @@ snapshot[`\$.map(\$.str, \$.u8) invalid [ 123 ] 1`] = `ShapeAssertError: !(value snapshot[`\$.map(\$.str, \$.u8) invalid [ [ "a", 1 ] ] 1`] = `ShapeAssertError: !(value instanceof ShapeMap)`; -snapshot[`\$.map(\$.str, \$.u8) invalid Map(1) { "a" => null } 1`] = `ShapeAssertError: !(value instanceof ShapeMap)`; +snapshot[`\$.map(\$.str, \$.u8) invalid Map { "a" => null } 1`] = `ShapeAssertError: !(value instanceof ShapeMap)`; -snapshot[`\$.map(\$.str, \$.u8) invalid Map(4) { "a" => 1, "b" => 2, "c" => -1, "d" => 0 } 1`] = `ShapeAssertError: !(value instanceof ShapeMap)`; +snapshot[`\$.map(\$.str, \$.u8) invalid Map { "a" => 1, "b" => 2, "c" => -1, "d" => 0 } 1`] = `ShapeAssertError: !(value instanceof ShapeMap)`; -snapshot[`\$.map(\$.str, \$.u8) invalid Map(4) { "a" => 1, "b" => 2, null => 3, "d" => 0 } 1`] = `ShapeAssertError: !(value instanceof ShapeMap)`; +snapshot[`\$.map(\$.str, \$.u8) invalid Map { "a" => 1, "b" => 2, null => 3, "d" => 0 } 1`] = `ShapeAssertError: !(value instanceof ShapeMap)`; diff --git a/shapes/test/__snapshots__/deferred.test.ts.snap b/shapes/test/__snapshots__/deferred.test.ts.snap index 0722a07..9a3a23b 100644 --- a/shapes/test/__snapshots__/deferred.test.ts.snap +++ b/shapes/test/__snapshots__/deferred.test.ts.snap @@ -1,20 +1,14 @@ export const snapshot = {}; -snapshot[`\$0 = \$.option( - \$.object(\$.field("val", \$.u8), \$.field("next", \$.deferred(() => \$0))) -) undefined 1`] = `00`; +snapshot[`\$0 = \$.option(\$.object(\$.field("val", \$.u8), \$.field("next", \$.deferred(() => \$0)))) undefined 1`] = `00`; -snapshot[`\$0 = \$.option( - \$.object(\$.field("val", \$.u8), \$.field("next", \$.deferred(() => \$0))) -) { val: 1, next: undefined } 1`] = ` +snapshot[`\$0 = \$.option(\$.object(\$.field("val", \$.u8), \$.field("next", \$.deferred(() => \$0)))) { val: 1, next: undefined } 1`] = ` 01 01 00 `; -snapshot[`\$0 = \$.option( - \$.object(\$.field("val", \$.u8), \$.field("next", \$.deferred(() => \$0))) -) { val: 1, next: { val: 2, next: { val: 3, next: undefined } } } 1`] = ` +snapshot[`\$0 = \$.option(\$.object(\$.field("val", \$.u8), \$.field("next", \$.deferred(() => \$0)))) { val: 1, next: { val: 2, next: { val: 3, next: undefined } } } 1`] = ` 01 01 01 @@ -24,18 +18,10 @@ snapshot[`\$0 = \$.option( 00 `; -snapshot[`\$0 = \$.option( - \$.object(\$.field("val", \$.u8), \$.field("next", \$.deferred(() => \$0))) -) invalid null 1`] = `ShapeAssertError: value == null`; +snapshot[`\$0 = \$.option(\$.object(\$.field("val", \$.u8), \$.field("next", \$.deferred(() => \$0)))) invalid null 1`] = `ShapeAssertError: value == null`; -snapshot[`\$0 = \$.option( - \$.object(\$.field("val", \$.u8), \$.field("next", \$.deferred(() => \$0))) -) invalid { val: 1, next: null } 1`] = `ShapeAssertError: value.next == null`; +snapshot[`\$0 = \$.option(\$.object(\$.field("val", \$.u8), \$.field("next", \$.deferred(() => \$0)))) invalid { val: 1, next: null } 1`] = `ShapeAssertError: value.next == null`; -snapshot[`\$0 = \$.option( - \$.object(\$.field("val", \$.u8), \$.field("next", \$.deferred(() => \$0))) -) invalid { val: 1, next: { val: -1, next: undefined } } 1`] = `ShapeAssertError: value.next.val < 0`; +snapshot[`\$0 = \$.option(\$.object(\$.field("val", \$.u8), \$.field("next", \$.deferred(() => \$0)))) invalid { val: 1, next: { val: -1, next: undefined } } 1`] = `ShapeAssertError: value.next.val < 0`; -snapshot[`\$0 = \$.option( - \$.object(\$.field("val", \$.u8), \$.field("next", \$.deferred(() => \$0))) -) invalid { val: 1, next: { val: 2, next: { val: 3, next: { val: -1, next: undefined } } } } 1`] = `ShapeAssertError: value.next.next.next.val < 0`; +snapshot[`\$0 = \$.option(\$.object(\$.field("val", \$.u8), \$.field("next", \$.deferred(() => \$0)))) invalid { val: 1, next: { val: 2, next: { val: 3, next: { val: -1, next: undefined } } } } 1`] = `ShapeAssertError: value.next.next.next.val < 0`; diff --git a/shapes/test/__snapshots__/instance.test.ts.snap b/shapes/test/__snapshots__/instance.test.ts.snap index 2ef76c3..fb3991c 100644 --- a/shapes/test/__snapshots__/instance.test.ts.snap +++ b/shapes/test/__snapshots__/instance.test.ts.snap @@ -3,7 +3,8 @@ export const snapshot = {}; snapshot[`\$myError MyError { code: 1, message: "At war with my Arch system config", - payload: { a: "a", b: 2, c: true } } 1`] = ` + payload: { a: "a", b: 2, c: true }, +} 1`] = ` 01 84 41 @@ -51,7 +52,7 @@ snapshot[`\$myError invalid undefined 1`] = `ShapeAssertError: !(value instanceo snapshot[`\$myError invalid { code: 123, message: "foo", payload: { a: "abc", b: 2, c: true } } 1`] = `ShapeAssertError: !(value instanceof MyError)`; -snapshot[`\$myError invalid [Error: foo] 1`] = `ShapeAssertError: !(value instanceof MyError)`; +snapshot[`\$myError invalid Error: foo 1`] = `ShapeAssertError: !(value instanceof MyError)`; snapshot[`\$myError invalid MyError { code: -1, message: "a", payload: { a: "abc", b: 2, c: true } } 1`] = `ShapeAssertError: value#arguments[0] < 0`; diff --git a/shapes/test/__snapshots__/object.test.ts.snap b/shapes/test/__snapshots__/object.test.ts.snap index 7ad088a..77a3bf8 100644 --- a/shapes/test/__snapshots__/object.test.ts.snap +++ b/shapes/test/__snapshots__/object.test.ts.snap @@ -72,8 +72,8 @@ snapshot[`\$.object( \$.taggedUnion( "_tag", [ - Variant { tag: "a", shape: \$.object([]) }, - Variant { tag: "b", shape: \$.object(\$.field("x", \$.u8)) } + Variant { tag: "a", shape: \$.object(Array) }, + Variant { tag: "b", shape: \$.object(Array) } ] ), \$.field("bar", \$.u8) @@ -86,8 +86,8 @@ snapshot[`\$.object( \$.taggedUnion( "_tag", [ - Variant { tag: "a", shape: \$.object([]) }, - Variant { tag: "b", shape: \$.object(\$.field("x", \$.u8)) } + Variant { tag: "a", shape: \$.object(Array) }, + Variant { tag: "b", shape: \$.object(Array) } ] ), \$.field("bar", \$.u8) @@ -101,8 +101,8 @@ snapshot[`\$.object( \$.taggedUnion( "_tag", [ - Variant { tag: "a", shape: \$.object([]) }, - Variant { tag: "b", shape: \$.object(\$.field("x", \$.u8)) } + Variant { tag: "a", shape: \$.object(Array) }, + Variant { tag: "b", shape: \$.object(Array) } ] ), \$.field("bar", \$.u8) @@ -112,8 +112,8 @@ snapshot[`\$.object( \$.taggedUnion( "_tag", [ - Variant { tag: "a", shape: \$.object([]) }, - Variant { tag: "b", shape: \$.object(\$.field("x", \$.u8)) } + Variant { tag: "a", shape: \$.object(Array) }, + Variant { tag: "b", shape: \$.object(Array) } ] ), \$.field("bar", \$.u8) @@ -123,8 +123,8 @@ snapshot[`\$.object( \$.taggedUnion( "_tag", [ - Variant { tag: "a", shape: \$.object([]) }, - Variant { tag: "b", shape: \$.object(\$.field("x", \$.u8)) } + Variant { tag: "a", shape: \$.object(Array) }, + Variant { tag: "b", shape: \$.object(Array) } ] ), \$.field("bar", \$.u8) @@ -134,8 +134,8 @@ snapshot[`\$.object( \$.taggedUnion( "_tag", [ - Variant { tag: "a", shape: \$.object([]) }, - Variant { tag: "b", shape: \$.object(\$.field("x", \$.u8)) } + Variant { tag: "a", shape: \$.object(Array) }, + Variant { tag: "b", shape: \$.object(Array) } ] ), \$.field("bar", \$.u8) @@ -145,8 +145,8 @@ snapshot[`\$.object( \$.taggedUnion( "_tag", [ - Variant { tag: "a", shape: \$.object([]) }, - Variant { tag: "b", shape: \$.object(\$.field("x", \$.u8)) } + Variant { tag: "a", shape: \$.object(Array) }, + Variant { tag: "b", shape: \$.object(Array) } ] ), \$.field("bar", \$.u8) @@ -156,8 +156,8 @@ snapshot[`\$.object( \$.taggedUnion( "_tag", [ - Variant { tag: "a", shape: \$.object([]) }, - Variant { tag: "b", shape: \$.object(\$.field("x", \$.u8)) } + Variant { tag: "a", shape: \$.object(Array) }, + Variant { tag: "b", shape: \$.object(Array) } ] ), \$.field("bar", \$.u8) diff --git a/shapes/test/__snapshots__/record.test.ts.snap b/shapes/test/__snapshots__/record.test.ts.snap index cd63022..54d357d 100644 --- a/shapes/test/__snapshots__/record.test.ts.snap +++ b/shapes/test/__snapshots__/record.test.ts.snap @@ -82,18 +82,7 @@ snapshot[`\$.transform( snapshot[`\$.transform( { - "\$base": \$.array( - \$.tuple( - \$.str, - \$.transform( - { - "\$base": \$.array(\$.tuple(\$.str, \$.u8)), - encode: [Function: entries], - decode: [Function: fromEntries] - } - ) - ) - ), + "\$base": \$.array(\$.tuple(\$.str, \$.transform(Array))), encode: [Function: entries], decode: [Function: fromEntries] } diff --git a/shapes/test/__snapshots__/result.test.ts.snap b/shapes/test/__snapshots__/result.test.ts.snap index a89e9a9..4e9dafd 100644 --- a/shapes/test/__snapshots__/result.test.ts.snap +++ b/shapes/test/__snapshots__/result.test.ts.snap @@ -1,27 +1,13 @@ export const snapshot = {}; -snapshot[`\$.result( - \$.str, - \$.instance( - [class StrErr extends Error], - \$.tuple(\$.str), - [Function (anonymous)] - ) -) "ok" 1`] = ` +snapshot[`\$.result(\$.str, \$.instance([Class: StrErr], \$.tuple(\$.str), [Function (anonymous)])) "ok" 1`] = ` 00 08 6f 6b `; -snapshot[`\$.result( - \$.str, - \$.instance( - [class StrErr extends Error], - \$.tuple(\$.str), - [Function (anonymous)] - ) -) { [StrErr: err] str: "err", message: "StrErr: err" } 1`] = ` +snapshot[`\$.result(\$.str, \$.instance([Class: StrErr], \$.tuple(\$.str), [Function (anonymous)])) StrErr: err 1`] = ` 01 0c 65 @@ -29,38 +15,10 @@ snapshot[`\$.result( 72 `; -snapshot[`\$.result( - \$.str, - \$.instance( - [class StrErr extends Error], - \$.tuple(\$.str), - [Function (anonymous)] - ) -) invalid null 1`] = `ShapeAssertError: typeof value !== "string"`; +snapshot[`\$.result(\$.str, \$.instance([Class: StrErr], \$.tuple(\$.str), [Function (anonymous)])) invalid null 1`] = `ShapeAssertError: typeof value !== "string"`; -snapshot[`\$.result( - \$.str, - \$.instance( - [class StrErr extends Error], - \$.tuple(\$.str), - [Function (anonymous)] - ) -) invalid undefined 1`] = `ShapeAssertError: typeof value !== "string"`; +snapshot[`\$.result(\$.str, \$.instance([Class: StrErr], \$.tuple(\$.str), [Function (anonymous)])) invalid undefined 1`] = `ShapeAssertError: typeof value !== "string"`; -snapshot[`\$.result( - \$.str, - \$.instance( - [class StrErr extends Error], - \$.tuple(\$.str), - [Function (anonymous)] - ) -) invalid [Error: foo] 1`] = `ShapeAssertError: !(value instanceof StrErr)`; +snapshot[`\$.result(\$.str, \$.instance([Class: StrErr], \$.tuple(\$.str), [Function (anonymous)])) invalid Error: foo 1`] = `ShapeAssertError: !(value instanceof StrErr)`; -snapshot[`\$.result( - \$.str, - \$.instance( - [class StrErr extends Error], - \$.tuple(\$.str), - [Function (anonymous)] - ) -) invalid { [StrErr: null] str: null, message: "StrErr: null" } 1`] = `ShapeAssertError: typeof value#arguments[0] !== "string"`; +snapshot[`\$.result(\$.str, \$.instance([Class: StrErr], \$.tuple(\$.str), [Function (anonymous)])) invalid StrErr: null 1`] = `ShapeAssertError: typeof value#arguments[0] !== "string"`; diff --git a/shapes/test/__snapshots__/tuple.test.ts.snap b/shapes/test/__snapshots__/tuple.test.ts.snap index 06db31d..366b5cc 100644 --- a/shapes/test/__snapshots__/tuple.test.ts.snap +++ b/shapes/test/__snapshots__/tuple.test.ts.snap @@ -1,9 +1,11 @@ export const snapshot = {}; -snapshot[`\$.tuple(\$.str, \$.u8, \$.str, \$.u32) [ "HELLO!", +snapshot[`\$.tuple(\$.str, \$.u8, \$.str, \$.u32) [ + "HELLO!", 1, - "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore "... 346 more characters, - 4294967295 ] 1`] = ` + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore ...", + 4294967295, +] 1`] = ` 18 48 45