@retroachievements/api 2.9.0 → 2.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -114,28 +114,34 @@ describe("Util: serializeProperties", () => {
114
114
  });
115
115
  });
116
116
 
117
- it("can be instructed to map values of certain keys to booleans", () => {
118
- // ARRANGE
119
- const originalObject = {
120
- UserName: "xelnia",
121
- HardcoreMode: "0",
122
- Metadata: {
123
- IsCoolGuy: "1",
124
- },
125
- };
126
-
127
- // ACT
128
- const sanitizedObject = serializeProperties(originalObject, {
129
- shouldMapToBooleans: ["HardcoreMode", "IsCoolGuy"],
130
- });
131
-
132
- // ASSERT
133
- expect(sanitizedObject).toEqual({
134
- userName: "xelnia",
135
- hardcoreMode: false,
136
- metadata: {
137
- isCoolGuy: true,
138
- },
139
- });
140
- });
117
+ it.each([
118
+ { hardcoreMode: "0", isCoolGuy: "1" },
119
+ { hardcoreMode: false, isCoolGuy: true },
120
+ ])(
121
+ "can be instructed to map values of certain keys to booleans such as the value '$hardcoreMode' and '$isCoolGuy'",
122
+ ({ hardcoreMode, isCoolGuy }) => {
123
+ // ARRANGE
124
+ const originalObject = {
125
+ UserName: "xelnia",
126
+ HardcoreMode: hardcoreMode,
127
+ Metadata: {
128
+ IsCoolGuy: isCoolGuy,
129
+ },
130
+ };
131
+
132
+ // ACT
133
+ const sanitizedObject = serializeProperties(originalObject, {
134
+ shouldMapToBooleans: ["HardcoreMode", "IsCoolGuy"],
135
+ });
136
+
137
+ // ASSERT
138
+ expect(sanitizedObject).toEqual({
139
+ userName: "xelnia",
140
+ hardcoreMode: false,
141
+ metadata: {
142
+ isCoolGuy: true,
143
+ },
144
+ });
145
+ }
146
+ );
141
147
  });
@@ -33,7 +33,11 @@ export const serializeProperties = (
33
33
  if (originalValue === null) {
34
34
  sanitizedValue = null;
35
35
  } else {
36
- sanitizedValue = String(originalValue) === "1" ? true : false;
36
+ const originalValueAsString = String(originalValue);
37
+ sanitizedValue =
38
+ originalValueAsString === "1" || originalValueAsString === "true"
39
+ ? true
40
+ : false;
37
41
  }
38
42
  }
39
43