Skip to content

Commit bc1d897

Browse files
authored
test: fix access token payload test for older cdis (#388)
1 parent 8256d4c commit bc1d897

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

test/session/claims/createNewSession.test.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,15 @@ describe(`sessionClaims/createNewSession: ${printPath("[test/session/claims/crea
168168
if (maxVersion(apiVersion, "2.12") === "2.12") {
169169
return;
170170
}
171+
const includesNullInPayload = maxVersion(apiVersion, "2.14") !== "2.14";
171172
const response = mockResponse();
172173
const res = await Session.createNewSession(response, "someId", payloadParam);
173174

174175
// The passed object should be unchanged
175176
assert.strictEqual(Object.keys(payloadParam).length, 1);
176177

177178
const payload = res.getAccessTokenPayload();
178-
assert.strictEqual(Object.keys(payload).length, 5);
179+
assert.strictEqual(Object.keys(payload).length, includesNullInPayload ? 5 : 4);
179180
// We have the prop from the payload param
180181
assert.strictEqual(payload["initial"], true);
181182
// We have the boolean claim
@@ -185,11 +186,18 @@ describe(`sessionClaims/createNewSession: ${printPath("[test/session/claims/crea
185186
// We have the custom claim
186187
// The resulting payload is different from the input: it doesn't container undefined
187188
assert.deepStrictEqual(payload["user-custom"], "asdf");
188-
assert.deepStrictEqual(payload["user-custom2"], {
189-
inner: "asdf",
190-
nullProp: null,
191-
});
192-
assert.deepStrictEqual(payload["user-custom3"], null);
189+
if (includesNullInPayload) {
190+
assert.deepStrictEqual(payload["user-custom2"], {
191+
inner: "asdf",
192+
nullProp: null,
193+
});
194+
assert.deepStrictEqual(payload["user-custom3"], null);
195+
} else {
196+
assert.deepStrictEqual(payload["user-custom2"], {
197+
inner: "asdf",
198+
});
199+
assert.deepStrictEqual(payload["user-custom3"], undefined);
200+
}
193201
});
194202
});
195203
});

0 commit comments

Comments
 (0)