Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
cool
Browse files Browse the repository at this point in the history
  • Loading branch information
KATT committed Sep 30, 2023
1 parent 0391e86 commit 6830366
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 25 deletions.
14 changes: 0 additions & 14 deletions src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,3 @@ export const expectError = (fn: () => unknown) => {
expect(err).toBeInstanceOf(Error);
return err as Error;
};

export function setup(opts: TsonOptions) {
const nonce: TsonOptions["nonce"] = () => "__tson";
const withDefaults: TsonOptions = {
nonce,
...opts,
};
return {
deserialize: tsonDeserializer(withDefaults),
parse: tsonParser(withDefaults),
serializer: tsonSerializer(withDefaults),
stringify: tsonStringifier(withDefaults),
};
}
22 changes: 11 additions & 11 deletions src/tson.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import {
UnknownObjectGuardError,
tsonUnknown,
} from "./handlers/tsonUnknown.js";
import { expectError, setup } from "./setup.js";
import { createTupleson } from "./tson.js";

test("Date", () => {
const ctx = setup({
const ctx = createTupleson({
types: {
Date: tsonDate,
},
Expand All @@ -28,7 +28,7 @@ test("Date", () => {
});

test("number", () => {
const t = setup({
const t = createTupleson({
types: {
number: tsonNumber,
},
Expand Down Expand Up @@ -64,7 +64,7 @@ test("number", () => {
});

test("undefined", () => {
const ctx = setup({
const ctx = createTupleson({
types: {
undefined: tsonUndefined,
},
Expand All @@ -80,7 +80,7 @@ test("undefined", () => {
});

test("Map", () => {
const t = setup({
const t = createTupleson({
types: {
Map: tsonMap,
},
Expand All @@ -94,7 +94,7 @@ test("Map", () => {
});

test("Set", () => {
const t = setup({
const t = createTupleson({
types: {
Set: tsonSet,
},
Expand All @@ -108,7 +108,7 @@ test("Set", () => {
});

test("bigint", () => {
const t = setup({
const t = createTupleson({
types: {
Map: tsonMap,
Set: tsonSet,
Expand Down Expand Up @@ -149,7 +149,7 @@ test("bigint", () => {

test("guard unwanted objects", () => {
// Sets are okay, but not Maps
const t = setup({
const t = createTupleson({
types: {
Set: tsonSet,
// defined last so it runs last
Expand Down Expand Up @@ -192,7 +192,7 @@ test("guard unwanted objects", () => {
});

test("regex", () => {
const t = setup({
const t = createTupleson({
types: {
RegExp: tsonRegExp,
},
Expand Down Expand Up @@ -223,7 +223,7 @@ test("regex", () => {
});

test("lets have a look at the stringified output", () => {
const t = setup({
const t = createTupleson({
types: {
Map: tsonMap,
Set: tsonSet,
Expand Down Expand Up @@ -289,7 +289,7 @@ test("lets have a look at the stringified output", () => {
});

test("types", () => {
const t = setup({
const t = createTupleson({
types: {
bigint: tsonBigint,
},
Expand Down

0 comments on commit 6830366

Please sign in to comment.