pi-kiosk-shared 1.0.22 → 1.0.23

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.d.ts CHANGED
@@ -5,9 +5,4 @@ export * from './validation';
5
5
  export * from './errors';
6
6
  export * from './utils';
7
7
  export * from './hooks/useErrorHandler';
8
- export * from './hooks/useApi';
9
- export * from './hooks/useAsyncOperation';
10
- export * from './components/LoadingSpinner';
11
- export * from './components/ErrorDisplay';
12
8
  export * from './config/environments';
13
- export * from './config/logger';
package/dist/index.js CHANGED
@@ -7,9 +7,4 @@ export * from './errors';
7
7
  export * from './utils';
8
8
  // Note: ./utils exports getErrorMessage which shadows the one from ./errors
9
9
  export * from './hooks/useErrorHandler';
10
- export * from './hooks/useApi';
11
- export * from './hooks/useAsyncOperation';
12
- export * from './components/LoadingSpinner';
13
- export * from './components/ErrorDisplay';
14
10
  export * from './config/environments';
15
- export * from './config/logger';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-kiosk-shared",
3
- "version": "1.0.22",
3
+ "version": "1.0.23",
4
4
  "private": false,
5
5
  "description": "Shared components and utilities for Pi Kiosk system",
6
6
  "keywords": [
@@ -31,6 +31,9 @@
31
31
  "test": "jest",
32
32
  "test:watch": "jest --watch",
33
33
  "test:coverage": "jest --coverage",
34
+ "test:unit": "jest --testPathPattern=src/__tests__/unit",
35
+ "test:fast": "jest --testPathPattern=src/__tests__/unit --watch",
36
+ "test:debug": "jest --testPathPattern=src/__tests__/unit --verbose",
34
37
  "clean": "rimraf dist",
35
38
  "publish:local": "npm run build && npm pack --pack-destination ../",
36
39
  "prepublishOnly": "npm run build",
@@ -1 +0,0 @@
1
- export {};
@@ -1,49 +0,0 @@
1
- // Tests for environment configuration
2
- import { getCurrentEnvironment, getEnvironmentConfig, isDevelopment, isProduction } from './environments';
3
- describe('Environment Configuration', () => {
4
- const originalEnv = process.env.NODE_ENV;
5
- afterEach(() => {
6
- process.env.NODE_ENV = originalEnv;
7
- });
8
- describe('getCurrentEnvironment', () => {
9
- test('returns development for non-production environments', () => {
10
- process.env.NODE_ENV = 'development';
11
- expect(getCurrentEnvironment()).toBe('development');
12
- process.env.NODE_ENV = 'test';
13
- expect(getCurrentEnvironment()).toBe('development');
14
- delete process.env.NODE_ENV;
15
- expect(getCurrentEnvironment()).toBe('development');
16
- });
17
- test('returns production for production environment', () => {
18
- process.env.NODE_ENV = 'production';
19
- expect(getCurrentEnvironment()).toBe('production');
20
- });
21
- });
22
- describe('getEnvironmentConfig', () => {
23
- test('returns development config by default', () => {
24
- process.env.NODE_ENV = 'development';
25
- const config = getEnvironmentConfig();
26
- expect(config.apiUrl).toBe('http://localhost:3015');
27
- expect(config.enableMockPayments).toBe(true);
28
- expect(config.showDebugInfo).toBe(true);
29
- });
30
- test('returns production config for production', () => {
31
- process.env.NODE_ENV = 'production';
32
- const config = getEnvironmentConfig();
33
- expect(config.enableMockPayments).toBe(false);
34
- expect(config.showDebugInfo).toBe(false);
35
- });
36
- });
37
- describe('environment checks', () => {
38
- test('isDevelopment works correctly', () => {
39
- process.env.NODE_ENV = 'development';
40
- expect(isDevelopment()).toBe(true);
41
- expect(isProduction()).toBe(false);
42
- });
43
- test('isProduction works correctly', () => {
44
- process.env.NODE_ENV = 'production';
45
- expect(isDevelopment()).toBe(false);
46
- expect(isProduction()).toBe(true);
47
- });
48
- });
49
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,45 +0,0 @@
1
- // Tests for shared utilities
2
- import { validateEmail, formatPrice, generatePaymentId, getErrorMessage } from '../utils';
3
- describe('Shared Utilities', () => {
4
- describe('validateEmail', () => {
5
- test('validates correct email addresses', () => {
6
- expect(validateEmail('test@example.com')).toBe(true);
7
- expect(validateEmail('user.name+tag@domain.co.uk')).toBe(true);
8
- });
9
- test('rejects invalid email addresses', () => {
10
- expect(validateEmail('')).toBe(false);
11
- expect(validateEmail('invalid')).toBe(false);
12
- expect(validateEmail('test@')).toBe(false);
13
- expect(validateEmail('@domain.com')).toBe(false);
14
- expect(validateEmail('test..test@domain.com')).toBe(false);
15
- });
16
- });
17
- describe('formatPrice', () => {
18
- test('formats prices correctly', () => {
19
- expect(formatPrice(100)).toBe('100 Kč');
20
- expect(formatPrice(25.5)).toBe('25.5 Kč');
21
- expect(formatPrice(0)).toBe('0 Kč');
22
- });
23
- });
24
- describe('generatePaymentId', () => {
25
- test('generates unique payment IDs', () => {
26
- const id1 = generatePaymentId();
27
- const id2 = generatePaymentId();
28
- expect(id1).toMatch(/^pay-\d+$/);
29
- expect(id2).toMatch(/^pay-\d+$/);
30
- expect(id1).not.toBe(id2);
31
- });
32
- });
33
- describe('getErrorMessage', () => {
34
- test('returns user-friendly error messages', () => {
35
- const fetchError = new Error('Failed to fetch');
36
- expect(getErrorMessage(fetchError)).toBe('Problém s připojením. Zkuste to znovu.');
37
- const authError = new Error('401 Unauthorized');
38
- expect(getErrorMessage(authError)).toBe('Neplatné přihlašovací údaje.');
39
- const genericError = new Error('Something went wrong');
40
- expect(getErrorMessage(genericError)).toBe('Something went wrong');
41
- const emptyError = new Error('');
42
- expect(getErrorMessage(emptyError)).toBe('Něco se pokazilo. Zkuste to znovu.');
43
- });
44
- });
45
- });