-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* v0.2.0 * updated GitHub action configs * updated GitHub action job name
- Loading branch information
Showing
9 changed files
with
175 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Pull Request | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
integrity-checks: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: read | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup Deno | ||
uses: denoland/setup-deno@v1 | ||
with: | ||
deno-version: v1.x | ||
|
||
- name: Verify formatting | ||
run: deno fmt --check | ||
|
||
- name: Run linter | ||
run: deno lint --ignore=\*\*\/\*_test.ts | ||
|
||
- name: Run tests | ||
run: deno test -A |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export { assert, assertEquals } from "jsr:@std/assert@^0.218.2"; | ||
|
||
export { | ||
assertSpyCall, | ||
assertSpyCalls, | ||
spy, | ||
stub, | ||
} from "jsr:@std/testing@^0.218.2/mock"; | ||
|
||
export { | ||
afterEach, | ||
beforeEach, | ||
describe, | ||
it, | ||
} from "jsr:@std/testing@^0.218.2/bdd"; | ||
|
||
export type { Spy, Stub } from "jsr:@std/testing@^0.218.2/mock"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
{ | ||
"name": "@dklab/oak-routing-ctrl", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"exports": { | ||
".": "./mod.ts" | ||
} | ||
}, | ||
"exclude": ["**/*_test.ts", "dev_deps.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { | ||
assertEquals, | ||
assertSpyCall, | ||
assertSpyCalls, | ||
spy, | ||
stub, | ||
} from "../dev_deps.ts"; | ||
import { debug } from "./utils/logger.ts"; | ||
import { register, store } from "./Store.ts"; | ||
import { Put } from "./Put.ts"; | ||
|
||
Deno.test("@Put decorator", () => { | ||
// @TODO check why spies don't work | ||
// const spyStoreRegister = spy(register); | ||
// const spyLoggerDebug = spy(debug); | ||
|
||
class _ { | ||
@Put("/bar") | ||
doSomething() {} | ||
} | ||
|
||
// assertSpyCalls(spyLoggerDebug, 1); | ||
// assertSpyCalls(spyStoreRegister, 1); | ||
// assertSpyCall(spyStoreRegister, 0, { | ||
// args: ["put", "/bar", "doSomething"], | ||
// returned: undefined, | ||
// }); | ||
|
||
assertEquals(store.get("doSomething")?.get("put"), "/bar"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { debug } from "./logger.ts"; | ||
import { | ||
afterEach, | ||
assertSpyCall, | ||
assertSpyCalls, | ||
beforeEach, | ||
stub, | ||
} from "../../dev_deps.ts"; | ||
import type { Stub } from "../../dev_deps.ts"; | ||
import { describe, it } from "../../dev_deps.ts"; | ||
|
||
let stubConsoleDebug: Stub; | ||
|
||
beforeEach(() => { | ||
stubConsoleDebug = stub(console, "debug", () => {}); | ||
}); | ||
|
||
afterEach(() => { | ||
stubConsoleDebug.restore(); | ||
}); | ||
|
||
describe("debug logger", () => { | ||
it("behaves without DEBUG env var", () => { | ||
const stubbedGetDebugEnv = stubGetEnv("DEBUG", undefined); | ||
try { | ||
debug("foo"); | ||
assertSpyCalls(stubConsoleDebug, 0); | ||
} finally { | ||
stubbedGetDebugEnv.restore(); | ||
} | ||
}); | ||
|
||
it("behaves with DEBUG env var", () => { | ||
const stubbedGetDebugEnv = stubGetEnv("DEBUG", "true"); | ||
try { | ||
debug("bar"); | ||
assertSpyCall(stubConsoleDebug, 0, { args: ["bar"] }); | ||
} finally { | ||
stubbedGetDebugEnv.restore(); | ||
} | ||
}); | ||
}); | ||
|
||
function stubGetEnv(envName: string, stubValue: string | undefined): Stub { | ||
return stub( | ||
Deno.env, | ||
"get", | ||
(key) => key === envName ? stubValue : Deno.env.get(key), | ||
); | ||
} |