v0.1.2: checkout fixes for CMS v0.2.0 (#18)
Co-authored-by: Michael Czechowski <mail@librete.ch>
This commit was merged in pull request #18.
This commit is contained in:
1 parent
60b8f1ab58
commit
fccff147ba
29 files changed
+1108
-71
No files matched your search
@@ -0,0 +1,21 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { isAlreadyCaptured } from "../../utils/captureResponse.ts";
|
||||
|
||||
test("recognises the CMS's answer to a repeated capture", () => {
|
||||
assert.equal(isAlreadyCaptured({ success: true, alreadyCaptured: true }), true);
|
||||
});
|
||||
|
||||
test("takes the paid order of a first capture for no repeated capture", () => {
|
||||
const order = { uuid: "11111111-2222-4333-8444-555555555555", total: 22.85, paymentAuthorised: true, email: "erika@example.org" };
|
||||
|
||||
assert.equal(isAlreadyCaptured(order), false);
|
||||
assert.equal(isAlreadyCaptured({ ...order, alreadyCaptured: false }), false);
|
||||
});
|
||||
|
||||
test("takes nothing but true for both fields as a repeated capture", () => {
|
||||
assert.equal(isAlreadyCaptured({ alreadyCaptured: true }), false);
|
||||
assert.equal(isAlreadyCaptured({ success: true, alreadyCaptured: "true" }), false);
|
||||
assert.equal(isAlreadyCaptured({ success: false, alreadyCaptured: true }), false);
|
||||
for (const response of [undefined, null, "alreadyCaptured", 1, [true]]) assert.equal(isAlreadyCaptured(response), false);
|
||||
});
|
||||
Reference in new issue
Block a user