@stanlemon/app-template 0.3.82 → 0.3.84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/app.test.js +24 -7
  2. package/package.json +4 -4
package/app.test.js CHANGED
@@ -3,6 +3,17 @@
3
3
  */
4
4
  import request from "supertest";
5
5
  import { app, db } from "./app.js";
6
+ import { test__signupAndLogin } from "@stanlemon/server-with-auth";
7
+
8
+ async function signupAndLogin() {
9
+ const { token } = await test__signupAndLogin(
10
+ app,
11
+ "test" + Math.random(),
12
+ "p@$$w0rd!",
13
+ { name: "Test User", email: "test@test.com" }
14
+ );
15
+ return token;
16
+ }
6
17
 
7
18
  describe("/app", () => {
8
19
  afterEach(() => {
@@ -11,40 +22,46 @@ describe("/app", () => {
11
22
  });
12
23
 
13
24
  it("lists items", async () => {
25
+ const token = await signupAndLogin();
14
26
  const response = await request(app)
15
27
  .get("/api/items")
16
- .set("Accept", "application/json");
28
+ .set("Accept", "application/json")
29
+ .set("Authorization", "Bearer " + token);
17
30
 
18
- expect(response.headers["content-type"]).toMatch(/json/);
19
31
  expect(response.status).toEqual(200);
32
+ expect(response.headers["content-type"]).toMatch(/json/);
20
33
  expect(response.body).toEqual([]);
21
34
  });
22
35
 
23
36
  it("add item", async () => {
37
+ const token = await signupAndLogin();
24
38
  const response = await request(app)
25
39
  .post("/api/items")
26
40
  .set("Accept", "application/json")
27
- .send({ item: "hello world" });
41
+ .send({ item: "hello world" })
42
+ .set("Authorization", "Bearer " + token);
28
43
 
29
- expect(response.headers["content-type"]).toMatch(/json/);
30
44
  expect(response.status).toEqual(200);
45
+ expect(response.headers["content-type"]).toMatch(/json/);
31
46
  expect(response.body).toMatchObject([{ item: "hello world" }]);
32
47
  });
33
48
 
34
49
  it("delete item", async () => {
50
+ const token = await signupAndLogin();
35
51
  const response1 = await request(app)
36
52
  .post("/api/items")
37
53
  .set("Accept", "application/json")
54
+ .set("Authorization", "Bearer " + token)
38
55
  .send({ item: "hello world" });
39
-
40
56
  const items = response1.body;
41
57
 
42
58
  const response2 = await request(app)
43
59
  .delete(`/api/items/${items[0].id}`)
44
- .set("Accept", "application/json");
60
+ .set("Accept", "application/json")
61
+ .set("Authorization", "Bearer " + token);
45
62
 
46
- expect(response2.headers["content-type"]).toMatch(/json/);
47
63
  expect(response2.status).toEqual(200);
64
+ expect(response2.headers["content-type"]).toMatch(/json/);
48
65
  expect(response2.body).toMatchObject([]);
49
66
  });
50
67
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stanlemon/app-template",
3
- "version": "0.3.82",
3
+ "version": "0.3.84",
4
4
  "description": "A template for creating apps using the webdev package.",
5
5
  "author": "Stan Lemon <stanlemon@users.noreply.github.com>",
6
6
  "license": "MIT",
@@ -21,14 +21,14 @@
21
21
  "lint:fix": "eslint --fix ."
22
22
  },
23
23
  "engines": {
24
- "node": ">=22.12.0"
24
+ "node": ">=22.14.0"
25
25
  },
26
26
  "dependencies": {
27
27
  "@stanlemon/server-with-auth": "*",
28
28
  "@stanlemon/webdev": "*",
29
- "react": "^19.0.0",
29
+ "react": "^19.1.0",
30
30
  "react-cookie": "^8.0.1",
31
- "react-dom": "^19.0.0",
31
+ "react-dom": "^19.1.0",
32
32
  "wouter": "^3.6.0"
33
33
  },
34
34
  "devDependencies": {