deno.land / x / opine@2.3.4 / test / units / app.locals.test.ts

app.locals.test.ts
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import opine from "../../mod.ts";import { expect } from "../deps.ts";import { describe, it } from "../utils.ts";
const mockUser = Symbol("test-user");const mockAge = Symbol("test-age");const mockSetting = "test-setting";const mockValue = Symbol("test-value");
describe("app", () => { describe(".locals(obj)", () => { it("should merge locals", () => { const app = opine();
expect(Object.keys(app.locals)).toEqual(["settings"]);
app.locals.user = mockUser; app.locals.age = mockAge;
expect(Object.keys(app.locals)).toEqual(["settings", "user", "age"]); expect(app.locals.user).toEqual(mockUser); expect(app.locals.age).toEqual(mockAge); }); });
describe(".locals.settings", () => { it("should expose app settings", () => { const app = opine(); app.set(mockSetting, mockValue);
const obj = app.locals.settings; expect(obj).toHaveProperty(mockSetting); expect(obj[mockSetting]).toEqual(mockValue); }); });});
opine

Version Info

Tagged at
2 years ago