Skip to content

Commit 9119a1e

Browse files
committed
fix(util-dynamodb): revert marshall.spec.ts and minor formatting
1 parent 1105751 commit 9119a1e

File tree

2 files changed

+52
-47
lines changed

2 files changed

+52
-47
lines changed

packages/util-dynamodb/src/marshall.spec.ts

Lines changed: 45 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,64 +4,62 @@ import { marshall } from "./marshall";
44
jest.mock("./convertToAttr");
55

66
describe("marshall", () => {
7-
describe("mocked convertToAttr", () => {
8-
const mockOutput = { S: "mockOutput" };
9-
(convertToAttr as jest.Mock).mockReturnValue({ M: mockOutput });
7+
const mockOutput = { S: "mockOutput" };
8+
(convertToAttr as jest.Mock).mockReturnValue({ M: mockOutput });
109

11-
afterEach(() => {
12-
jest.clearAllMocks();
13-
});
10+
afterEach(() => {
11+
jest.clearAllMocks();
12+
});
1413

15-
it("with object as an input", () => {
16-
const input = { a: "A", b: "B" };
17-
expect(marshall(input)).toEqual(mockOutput);
18-
expect(convertToAttr).toHaveBeenCalledTimes(1);
19-
expect(convertToAttr).toHaveBeenCalledWith(input, undefined);
20-
});
14+
it("with object as an input", () => {
15+
const input = { a: "A", b: "B" };
16+
expect(marshall(input)).toEqual(mockOutput);
17+
expect(convertToAttr).toHaveBeenCalledTimes(1);
18+
expect(convertToAttr).toHaveBeenCalledWith(input, undefined);
19+
});
2120

22-
["convertEmptyValues", "removeUndefinedValues"].forEach((option) => {
23-
describe(`options.${option}`, () => {
24-
[false, true].forEach((value) => {
25-
it(`passes ${value} to convertToAttr`, () => {
26-
const input = { a: "A", b: "B" };
27-
expect(marshall(input, { [option]: value })).toEqual(mockOutput);
28-
expect(convertToAttr).toHaveBeenCalledTimes(1);
29-
expect(convertToAttr).toHaveBeenCalledWith(input, { [option]: value });
30-
});
21+
["convertEmptyValues", "removeUndefinedValues"].forEach((option) => {
22+
describe(`options.${option}`, () => {
23+
[false, true].forEach((value) => {
24+
it(`passes ${value} to convertToAttr`, () => {
25+
const input = { a: "A", b: "B" };
26+
expect(marshall(input, { [option]: value })).toEqual(mockOutput);
27+
expect(convertToAttr).toHaveBeenCalledTimes(1);
28+
expect(convertToAttr).toHaveBeenCalledWith(input, { [option]: value });
3129
});
3230
});
3331
});
32+
});
3433

35-
it("with type as an input", () => {
36-
type TestInputType = { a: string; b: string };
37-
const input: TestInputType = { a: "A", b: "B" };
34+
it("with type as an input", () => {
35+
type TestInputType = { a: string; b: string };
36+
const input: TestInputType = { a: "A", b: "B" };
3837

39-
expect(marshall(input)).toEqual(mockOutput);
40-
expect(convertToAttr).toHaveBeenCalledTimes(1);
41-
expect(convertToAttr).toHaveBeenCalledWith(input, undefined);
42-
});
38+
expect(marshall(input)).toEqual(mockOutput);
39+
expect(convertToAttr).toHaveBeenCalledTimes(1);
40+
expect(convertToAttr).toHaveBeenCalledWith(input, undefined);
41+
});
4342

44-
it("with Interface as an input", () => {
45-
interface TestInputInterface {
46-
a: string;
47-
b: string;
48-
}
49-
const input: TestInputInterface = { a: "A", b: "B" };
43+
it("with Interface as an input", () => {
44+
interface TestInputInterface {
45+
a: string;
46+
b: string;
47+
}
48+
const input: TestInputInterface = { a: "A", b: "B" };
5049

51-
expect(marshall(input)).toEqual(mockOutput);
52-
expect(convertToAttr).toHaveBeenCalledTimes(1);
53-
expect(convertToAttr).toHaveBeenCalledWith(input, undefined);
54-
});
50+
expect(marshall(input)).toEqual(mockOutput);
51+
expect(convertToAttr).toHaveBeenCalledTimes(1);
52+
expect(convertToAttr).toHaveBeenCalledWith(input, undefined);
53+
});
5554

56-
it("with class instance as an input", () => {
57-
class TestInputClass {
58-
constructor(private readonly a: string, private readonly b: string) {}
59-
}
60-
const input = new TestInputClass("A", "B");
55+
it("with class instance as an input", () => {
56+
class TestInputClass {
57+
constructor(private readonly a: string, private readonly b: string) {}
58+
}
59+
const input = new TestInputClass("A", "B");
6160

62-
expect(marshall(input)).toEqual(mockOutput);
63-
expect(convertToAttr).toHaveBeenCalledTimes(1);
64-
expect(convertToAttr).toHaveBeenCalledWith(input, undefined);
65-
});
61+
expect(marshall(input)).toEqual(mockOutput);
62+
expect(convertToAttr).toHaveBeenCalledTimes(1);
63+
expect(convertToAttr).toHaveBeenCalledWith(input, undefined);
6664
});
6765
});

packages/util-dynamodb/src/marshallTypes.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,24 @@ describe("marshall type discernment", () => {
77
const value = "hello";
88
expect(marshall(value)).toEqual(convertToAttr(value));
99
});
10+
1011
it("marshals number", () => {
1112
const value = 1578;
1213
expect(marshall(value)).toEqual(convertToAttr(value));
1314
});
15+
1416
it("marshals binary", () => {
1517
const value = new Uint8Array([0, 1, 0, 1]);
1618
expect(marshall(value)).toEqual(convertToAttr(value));
1719
});
20+
1821
it("marshals boolean", () => {
1922
let value = false;
2023
expect(marshall(value)).toEqual(convertToAttr(value));
2124
value = true;
2225
expect(marshall(value)).toEqual(convertToAttr(value));
2326
});
27+
2428
it("marshals null", () => {
2529
const value = null;
2630
expect(marshall(value)).toEqual(convertToAttr(value));
@@ -29,10 +33,12 @@ describe("marshall type discernment", () => {
2933
const value = new Set(["a", "b"]);
3034
expect(marshall(value)).toEqual(convertToAttr(value));
3135
});
36+
3237
it("marshals number set", () => {
3338
const value = new Set([1, 2]);
3439
expect(marshall(value)).toEqual(convertToAttr(value));
3540
});
41+
3642
it("marshals binary set", () => {
3743
const value = new Set([new Uint8Array([1, 0]), new Uint8Array([0, 1])]);
3844
expect(marshall(value)).toEqual(convertToAttr(value));
@@ -52,6 +58,7 @@ describe("marshall type discernment", () => {
5258
},
5359
});
5460
});
61+
5562
it("marshals and unwraps list", () => {
5663
expect(marshall(["test", 2, null])).toEqual([{ S: "test" }, { N: "2" }, { NULL: true }]);
5764
});

0 commit comments

Comments
 (0)