@digitaldefiance/suite-core-lib 3.6.0 → 3.6.5

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/README.md +106 -0
  2. package/package.json +8 -2
package/README.md CHANGED
@@ -424,8 +424,114 @@ MIT © [Digital Defiance](https://github.com/digitaldefiance)
424
424
 
425
425
  **Building user management primitives?** Start with `@digitaldefiance/suite-core-lib` for type-safe, secure, and internationalized user system foundations. For complete frameworks, check out the **node-ecies** and **node-express-suite** projects! 🚀
426
426
 
427
+ ## Testing
428
+
429
+ ### Testing Approach
430
+
431
+ The suite-core-lib package uses comprehensive testing with 409 tests covering all user management primitives, validation logic, and error handling.
432
+
433
+ **Test Framework**: Jest with TypeScript support
434
+ **Property-Based Testing**: fast-check for validation properties
435
+ **Coverage**: 98.47% statements, 94.56% branches, 88.09% functions
436
+
437
+ ### Running Tests
438
+
439
+ ```bash
440
+ # Run all tests
441
+ npm test
442
+
443
+ # Run with coverage
444
+ npm test -- --coverage
445
+
446
+ # Run specific test suite
447
+ npm test -- user-builder.spec.ts
448
+ ```
449
+
450
+ ### Test Patterns
451
+
452
+ #### Testing Builders
453
+
454
+ ```typescript
455
+ import { UserBuilder, RoleBuilder, Role } from '@digitaldefiance/suite-core-lib';
456
+
457
+ describe('User Builder', () => {
458
+ it('should build user with fluent API', () => {
459
+ const user = UserBuilder.create()
460
+ .withUsername('alice')
461
+ .withEmail('alice@example.com')
462
+ .withEmailVerified(true)
463
+ .build();
464
+
465
+ expect(user.username).toBe('alice');
466
+ expect(user.emailVerified).toBe(true);
467
+ });
468
+ });
469
+ ```
470
+
471
+ #### Testing Validators
472
+
473
+ ```typescript
474
+ import { isValidUsername, isValidEmail, isValidPassword } from '@digitaldefiance/suite-core-lib';
475
+
476
+ describe('Validators', () => {
477
+ it('should validate usernames', () => {
478
+ expect(isValidUsername('alice123')).toBe(true);
479
+ expect(isValidUsername('ab')).toBe(false); // too short
480
+ });
481
+
482
+ it('should validate emails', () => {
483
+ expect(isValidEmail('alice@example.com')).toBe(true);
484
+ expect(isValidEmail('invalid')).toBe(false);
485
+ });
486
+ });
487
+ ```
488
+
489
+ #### Testing Error Handling
490
+
491
+ ```typescript
492
+ import { UserNotFoundError, UsernameInUseError, CoreLanguage } from '@digitaldefiance/suite-core-lib';
493
+
494
+ describe('Error Handling', () => {
495
+ it('should throw localized errors', () => {
496
+ const error = new UserNotFoundError(CoreLanguage.French);
497
+ expect(error.message).toContain('utilisateur');
498
+ });
499
+ });
500
+ ```
501
+
502
+ ### Cross-Package Testing
503
+
504
+ Testing with node-express-suite:
505
+
506
+ ```typescript
507
+ import { IBackendUser, AccountStatus } from '@digitaldefiance/suite-core-lib';
508
+ import { UserService } from '@digitaldefiance/node-express-suite';
509
+
510
+ describe('Integration with node-express-suite', () => {
511
+ it('should work with UserService', async () => {
512
+ const user: IBackendUser = {
513
+ username: 'alice',
514
+ email: 'alice@example.com',
515
+ accountStatus: AccountStatus.Active,
516
+ // ... other fields
517
+ };
518
+
519
+ // Use with UserService
520
+ expect(user.accountStatus).toBe(AccountStatus.Active);
521
+ });
522
+ });
523
+ ```
524
+
427
525
  ## ChangeLog
428
526
 
527
+ ## v3.6.5
528
+
529
+ - Update testing
530
+
531
+ ## v3.6.0
532
+
533
+ - Upgrade ecies to 4.4.0
534
+
429
535
  ## v.3.5.8
430
536
 
431
537
  - Upgrade ECIES to 4.3.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitaldefiance/suite-core-lib",
3
- "version": "3.6.0",
3
+ "version": "3.6.5",
4
4
  "description": "Generic user system and document system common core for applications",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -22,7 +22,7 @@
22
22
  "publish:public": "npm publish --access public"
23
23
  },
24
24
  "dependencies": {
25
- "@digitaldefiance/ecies-lib": "4.4.0",
25
+ "@digitaldefiance/ecies-lib": "4.4.1",
26
26
  "@digitaldefiance/i18n-lib": "3.8.0"
27
27
  },
28
28
  "files": [
@@ -36,5 +36,11 @@
36
36
  "author": "Digital Defiance",
37
37
  "license": "MIT",
38
38
  "packageManager": "yarn@4.10.3",
39
+ "devDependencies": {
40
+ "@typescript-eslint/eslint-plugin": "^8.48.0",
41
+ "@typescript-eslint/parser": "^8.48.0",
42
+ "eslint-plugin-import": "^2.32.0",
43
+ "eslint-plugin-prettier": "^5.5.4"
44
+ },
39
45
  "type": "commonjs"
40
46
  }