@amandevelops/whoami 1.0.1 → 2.0.0

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.
package/dist/index.cjs CHANGED
@@ -26,7 +26,13 @@ module.exports = __toCommonJS(index_exports);
26
26
 
27
27
  // src/functions.ts
28
28
  function checkAge({ age }) {
29
- return age > 18;
29
+ if (age < 0) {
30
+ throw new Error("Age not Valid");
31
+ } else if (age > 18) {
32
+ return true;
33
+ } else {
34
+ return false;
35
+ }
30
36
  }
31
37
  // Annotate the CommonJS export names for ESM import in node:
32
38
  0 && (module.exports = {
package/dist/index.js CHANGED
@@ -1,6 +1,12 @@
1
1
  // src/functions.ts
2
2
  function checkAge({ age }) {
3
- return age > 18;
3
+ if (age < 0) {
4
+ throw new Error("Age not Valid");
5
+ } else if (age > 18) {
6
+ return true;
7
+ } else {
8
+ return false;
9
+ }
4
10
  }
5
11
  export {
6
12
  checkAge
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amandevelops/whoami",
3
- "version": "1.0.1",
3
+ "version": "2.0.0",
4
4
  "description": "My first NPM package",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -20,13 +20,15 @@
20
20
  "access": "public"
21
21
  },
22
22
  "scripts": {
23
- "build": "tsup"
23
+ "build": "tsup",
24
+ "test": "vitest"
24
25
  },
25
26
  "keywords": [],
26
27
  "author": "amandevelops",
27
28
  "license": "MIT",
28
29
  "devDependencies": {
29
30
  "tsup": "^8.5.1",
30
- "typescript": "^6.0.2"
31
+ "typescript": "^6.0.2",
32
+ "vitest": "^4.1.2"
31
33
  }
32
34
  }
@@ -0,0 +1,16 @@
1
+ import { expect, test } from "vitest";
2
+ import { checkAge } from "../src/functions";
3
+
4
+ test("check age > 18", () => {
5
+ expect(checkAge({ age: 19 })).toBe(true);
6
+ expect(checkAge({ age: 125 })).toBe(true);
7
+ });
8
+
9
+ test("check age <= 18", () => {
10
+ expect(checkAge({ age: 18 })).toBe(false);
11
+ expect(checkAge({ age: 0 })).toBe(false);
12
+ });
13
+
14
+ test("check age < 0", () => {
15
+ expect(() => checkAge({ age: -1 })).toThrow("Age not Valid");
16
+ });