Skip to content

Commit

Permalink
Write tests for the extract function
Browse files Browse the repository at this point in the history
  • Loading branch information
BitterPanda committed Feb 20, 2024
1 parent 58cff46 commit 09da560
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions library/src/sinks/extractFromContext.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import * as t from "tap";
import {
extractFromContext,
extractFromQuery,
extractFromHeaders,
extractFromCookies,
extractFromBody,
} from "./extractFromContext";
import { extract } from "./extractFromContext";

t.test("Can extract() extract Query objects", async () => {
t.same(extract({ age: { $gt: "21" } }), ["age", "$gt", "21"]);
t.same(extract({ title: { $ne: "null" } }), ["title", "$ne", "null"]);
t.same(extract({ age: "whaat", user_input: ["whaat", "dangerous"]}), ["user_input", "age", "whaat", "dangerous"])

Check failure on line 7 in library/src/sinks/extractFromContext.test.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Replace `}),·["user_input",·"age",·"whaat",·"dangerous"])` with `·}),·[⏎····"user_input",⏎····"age",⏎····"whaat",⏎····"dangerous",⏎··]);`

Check failure on line 7 in library/src/sinks/extractFromContext.test.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Replace `}),·["user_input",·"age",·"whaat",·"dangerous"])` with `·}),·[⏎····"user_input",⏎····"age",⏎····"whaat",⏎····"dangerous",⏎··]);`

Check failure on line 7 in library/src/sinks/extractFromContext.test.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Replace `}),·["user_input",·"age",·"whaat",·"dangerous"])` with `·}),·[⏎····"user_input",⏎····"age",⏎····"whaat",⏎····"dangerous",⏎··]);`
});

t.test("Can extract() extract cookie objects", async () => {
t.same(extract({session: "ABC", session2: "DEF"}), ["session2", "session", "ABC", "DEF"])

Check failure on line 11 in library/src/sinks/extractFromContext.test.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Replace `session:·"ABC",·session2:·"DEF"}),·["session2",·"session",·"ABC",·"DEF"])` with `·session:·"ABC",·session2:·"DEF"·}),·[⏎····"session2",⏎····"session",⏎····"ABC",⏎····"DEF",⏎··]);`

Check failure on line 11 in library/src/sinks/extractFromContext.test.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Replace `session:·"ABC",·session2:·"DEF"}),·["session2",·"session",·"ABC",·"DEF"])` with `·session:·"ABC",·session2:·"DEF"·}),·[⏎····"session2",⏎····"session",⏎····"ABC",⏎····"DEF",⏎··]);`

Check failure on line 11 in library/src/sinks/extractFromContext.test.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Replace `session:·"ABC",·session2:·"DEF"}),·["session2",·"session",·"ABC",·"DEF"])` with `·session:·"ABC",·session2:·"DEF"·}),·[⏎····"session2",⏎····"session",⏎····"ABC",⏎····"DEF",⏎··]);`
})

Check failure on line 12 in library/src/sinks/extractFromContext.test.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Insert `;⏎`

Check failure on line 12 in library/src/sinks/extractFromContext.test.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Insert `;⏎`

Check failure on line 12 in library/src/sinks/extractFromContext.test.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Insert `;⏎`

0 comments on commit 09da560

Please sign in to comment.