clashofclans.js 3.3.3-dev.b711b64 → 3.3.4-dev.7ebadac

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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const Client_1 = require("./client/Client");
4
+ describe('root', () => {
5
+ const client = new Client_1.Client({ baseURL: process.env.BASE_URL });
6
+ it('should return a player', async () => {
7
+ const result = await client.getPlayer('#LUV2PG2Y9');
8
+ console.log({
9
+ name: result.name,
10
+ tag: result.tag,
11
+ troops: result.troops.map((troop) => troop.name),
12
+ spells: result.spells.map((spell) => spell.name),
13
+ heroes: result.heroes.map((hero) => hero.name)
14
+ });
15
+ expect(result).toHaveProperty('tag');
16
+ });
17
+ it('should return a clan', async () => {
18
+ const result = await client.getClan('#8QU8J9LP');
19
+ console.log({
20
+ name: result.name,
21
+ tag: result.tag
22
+ });
23
+ expect(result).toHaveProperty('tag');
24
+ });
25
+ });
@@ -27,12 +27,14 @@ class Unit {
27
27
  this.dps = rawUnit.dps[this.level - 1] ?? 0;
28
28
  this.trainingTime = Number(rawUnit.trainingTime);
29
29
  const origin = data.troops.find((troop) => troop.village === 'home' && troop.name === original.name);
30
- this.level = origin.level;
31
- this.maxLevel = origin.maxLevel;
32
- this.boostable = data.townHallLevel >= 11 && origin.level >= rawSuperUnit.minOriginalLevel;
33
- this.upgradeCost = original.upgrade.cost[origin.level - 1] || 0;
30
+ if (origin) {
31
+ this.level = origin.level;
32
+ this.maxLevel = origin.maxLevel;
33
+ this.boostable = data.townHallLevel >= 11 && origin.level >= rawSuperUnit.minOriginalLevel;
34
+ this.upgradeCost = original.upgrade.cost[origin.level - 1] || 0;
35
+ this.upgradeTime = original.upgrade.time[origin.level - 1] || 0;
36
+ }
34
37
  this.upgradeResource = original.upgrade.resource;
35
- this.upgradeTime = original.upgrade.time[origin.level - 1] || 0;
36
38
  this.hallMaxLevel = original.levels[data.townHallLevel - 1] ?? this.maxLevel;
37
39
  }
38
40
  else if (rawUnit) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clashofclans.js",
3
- "version": "3.3.3-dev.b711b64",
3
+ "version": "3.3.4-dev.7ebadac",
4
4
  "description": "JavaScript library for interacting with the Clash of Clans API",
5
5
  "author": "https://clashofclans.js.org",
6
6
  "license": "MIT",
@@ -20,8 +20,10 @@
20
20
  "scripts": {
21
21
  "build": "tsc && gen-esm-wrapper dist/index.js dist/index.mjs",
22
22
  "prepare": "rimraf dist && npm run build",
23
- "test": "eslint --ext .ts --ignore-path .gitignore .",
24
- "lint": "eslint --fix --ext .ts --ignore-path .gitignore ."
23
+ "lint:test": "eslint --ext .ts --ignore-path .gitignore .",
24
+ "lint:fix": "eslint --fix --ext .ts --ignore-path .gitignore .",
25
+ "test": "jest --setupFiles dotenv/config --config ./jest.config.json",
26
+ "test:watch": "npm run test -- --watch"
25
27
  },
26
28
  "files": [
27
29
  "dist"
@@ -49,9 +51,12 @@
49
51
  }
50
52
  },
51
53
  "dependencies": {
54
+ "jest": "^29.7.0",
52
55
  "undici": "^5.23.0"
53
56
  },
54
57
  "devDependencies": {
58
+ "@jest/globals": "^29.7.0",
59
+ "@types/jest": "^29.5.12",
55
60
  "@types/node": "^18.17.5",
56
61
  "@typescript-eslint/eslint-plugin": "^6.3.0",
57
62
  "@typescript-eslint/parser": "^6.3.0",
@@ -62,6 +67,7 @@
62
67
  "gen-esm-wrapper": "^1.1.3",
63
68
  "prettier": "^3.0.1",
64
69
  "rimraf": "^5.0.1",
70
+ "ts-jest": "^29.1.2",
65
71
  "typescript": "^5.1.6"
66
72
  },
67
73
  "engines": {