eureka-init 1.0.5 → 1.0.6

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/.eslintrc.js ADDED
@@ -0,0 +1,19 @@
1
+ module.exports = {
2
+ env: {
3
+ browser: true,
4
+ es2021: true,
5
+ node: true,
6
+ },
7
+ extends: [
8
+ 'eslint:recommended',
9
+ 'plugin:prettier/recommended',
10
+ ],
11
+ parserOptions: {
12
+ ecmaVersion: 'latest',
13
+ sourceType: 'module',
14
+ },
15
+ rules: {
16
+ 'no-console': 'warn',
17
+ 'prettier/prettier': 'error',
18
+ },
19
+ };
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ npx --no -- commitlint --edit $1
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ npm run lint
package/.prettierrc ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "semi": true,
3
+ "trailingComma": "all",
4
+ "singleQuote": true,
5
+ "printWidth": 80,
6
+ "tabWidth": 2,
7
+ "useTabs": false
8
+ }
@@ -0,0 +1,14 @@
1
+ module.exports = {
2
+ extends: ['@commitlint/config-conventional'],
3
+ rules: {
4
+ 'type-enum': [
5
+ 2,
6
+ 'always',
7
+ ['feat', 'fix', 'refactor', 'chore', 'docs', 'test']
8
+ ],
9
+ 'subject-case': [2, 'always', 'lower-case'],
10
+ 'subject-min-length': [2, 'always', 10],
11
+ 'subject-max-length': [2, 'always', 100],
12
+ 'subject-full-stop': [2, 'never', '.']
13
+ }
14
+ };
package/jest.config.js ADDED
@@ -0,0 +1,12 @@
1
+ module.exports = {
2
+ testEnvironment: 'jsdom',
3
+ collectCoverage: true,
4
+ coverageDirectory: 'coverage',
5
+ moduleNameMapper: {
6
+ '\\.(css|less|scss|sass)$': 'identity-obj-proxy',
7
+ },
8
+ setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
9
+ testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
10
+ testPathIgnorePatterns: ['<rootDir>/.next/', '<rootDir>/node_modules/'],
11
+ modulePathIgnorePatterns: ['<rootDir>/.next/'],
12
+ };
package/jest.setup.js ADDED
@@ -0,0 +1,114 @@
1
+ import '@testing-library/jest-dom';
2
+
3
+ /**
4
+ * Mock window.matchMedia (Diperlukan untuk Ant Design dan responsive components)
5
+ */
6
+ Object.defineProperty(window, 'matchMedia', {
7
+ writable: true,
8
+ value: jest.fn().mockImplementation((query) => ({
9
+ matches: false,
10
+ media: query,
11
+ onchange: null,
12
+ addListener: jest.fn(), // deprecated
13
+ removeListener: jest.fn(), // deprecated
14
+ addEventListener: jest.fn(),
15
+ removeEventListener: jest.fn(),
16
+ dispatchEvent: jest.fn(),
17
+ })),
18
+ });
19
+
20
+ /**
21
+ * Mock IntersectionObserver (Biasanya digunakan untuk lazy loading image)
22
+ */
23
+ global.IntersectionObserver = class IntersectionObserver {
24
+ constructor() { }
25
+ observe() { }
26
+ unobserve() { }
27
+ disconnect() { }
28
+ };
29
+
30
+ /**
31
+ * Mock ResizeObserver (Dibutuhkan untuk Framer Motion dan UI responsif)
32
+ */
33
+ global.ResizeObserver = class ResizeObserver {
34
+ constructor() { }
35
+ observe() { }
36
+ unobserve() { }
37
+ disconnect() { }
38
+ };
39
+
40
+ /**
41
+ * Mock window.scrollTo (Penting untuk alur checkout/pembelian)
42
+ */
43
+ Object.defineProperty(window, 'scrollTo', {
44
+ value: () => { },
45
+ writable: true
46
+ });
47
+
48
+ /**
49
+ * Mock Next.js Navigation (useRouter, usePathname, dll)
50
+ */
51
+ jest.mock('next/navigation', () => ({
52
+ useRouter: () => ({
53
+ push: jest.fn(),
54
+ replace: jest.fn(),
55
+ prefetch: jest.fn(),
56
+ back: jest.fn(),
57
+ }),
58
+ usePathname: () => '',
59
+ useSearchParams: () => new URLSearchParams(),
60
+ }));
61
+
62
+ /**
63
+ * Mock SweetAlert2 (Sering digunakan di project Eureka)
64
+ */
65
+ jest.mock('sweetalert2', () => ({
66
+ fire: jest.fn().mockResolvedValue({ isConfirmed: true }),
67
+ }));
68
+
69
+ /**
70
+ * Mock LocalStorage
71
+ */
72
+ const localStorageMock = (function () {
73
+ let store = {};
74
+ return {
75
+ getItem: (key) => store[key] || null,
76
+ setItem: (key, value) => {
77
+ store[key] = value.toString();
78
+ },
79
+ removeItem: (key) => {
80
+ delete store[key];
81
+ },
82
+ clear: () => {
83
+ store = {};
84
+ },
85
+ };
86
+ })();
87
+
88
+ Object.defineProperty(window, 'localStorage', {
89
+ value: localStorageMock,
90
+ });
91
+
92
+ /**
93
+ * Mock Fetch API
94
+ */
95
+ global.fetch = jest.fn(() =>
96
+ Promise.resolve({
97
+ json: () => Promise.resolve({}),
98
+ })
99
+ );
100
+
101
+ /**
102
+ * Mock Axios (Standar alur pembelian di Eureka Group)
103
+ */
104
+ jest.mock('axios', () => ({
105
+ get: jest.fn(() => Promise.resolve({ data: {} })),
106
+ post: jest.fn(() => Promise.resolve({ data: {} })),
107
+ put: jest.fn(() => Promise.resolve({ data: {} })),
108
+ delete: jest.fn(() => Promise.resolve({ data: {} })),
109
+ create: jest.fn(function () { return this; }),
110
+ interceptors: {
111
+ request: { use: jest.fn(), eject: jest.fn() },
112
+ response: { use: jest.fn(), eject: jest.fn() },
113
+ },
114
+ }));
package/package.json CHANGED
@@ -1,13 +1,16 @@
1
1
  {
2
2
  "name": "eureka-init",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Shared configuration for Husky, Commitlint, Prettier, ESLint, and Jest for Eureka Group",
5
5
  "main": "index.js",
6
6
  "bin": {
7
7
  "eureka-init": "bin/eureka-init.js"
8
8
  },
9
9
  "scripts": {
10
- "test": "echo \"Error: no test specified\" && exit 1"
10
+ "test": "echo \"Error: no test specified\" && exit 1",
11
+ "prepare": "husky install",
12
+ "lint": "eslint .",
13
+ "format": "prettier --write ."
11
14
  },
12
15
  "keywords": [
13
16
  "husky",
@@ -32,4 +35,4 @@
32
35
  "identity-obj-proxy": "^3.0.0",
33
36
  "prettier": "^3.2.5"
34
37
  }
35
- }
38
+ }
@@ -0,0 +1,11 @@
1
+ describe('Contoh Unit Test', () => {
2
+ test('Sistem Testing Eureka Init harus berjalan', () => {
3
+ const sum = (a, b) => a + b;
4
+ expect(sum(1, 2)).toBe(3);
5
+ });
6
+
7
+ test('Lingkungan JSDOM harus tersedia', () => {
8
+ const element = document.createElement('div');
9
+ expect(element).not.toBeNull();
10
+ });
11
+ });
@@ -1,4 +1,4 @@
1
- import '@testing-library/jest-dom';
1
+ require('@testing-library/jest-dom');
2
2
 
3
3
  /**
4
4
  * Mock window.matchMedia (Diperlukan untuk Ant Design dan responsive components)