human-ids 1.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/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # Human IDs
2
+
3
+ A library to generate human-readable IDs.
4
+
5
+ ## Description
6
+
7
+ Human IDs is a JavaScript library that allows you to generate human-readable IDs. The IDs consist of a combination of adjectives, colors, nouns, and numbers, creating unique and memorable identifiers.
8
+
9
+ ## Installation
10
+
11
+ To use Human IDs in your project, you can install it via npm:
12
+
13
+ ```she
14
+ npm install human-ids
15
+ ```
16
+
17
+ ```javascript
18
+ const IdGenerator = require('human-ids');
19
+
20
+ // Initialize the settings object
21
+ const settings = {
22
+ lang: 'es',
23
+ adjective: true,
24
+ noun: true,
25
+ number: {
26
+ min: 0,
27
+ max: 999,
28
+ completeWithZeros: true,
29
+ sets: 3
30
+ }
31
+ };
32
+
33
+ // Create an instance of the IdGenerator class
34
+ const idGenerator = new IdGenerator(settings);
35
+
36
+ // Generate an ID using the class instance
37
+ const id = idGenerator.generateId();
38
+ console.log(id);
39
+ ```
40
+ ## Configuration
41
+
42
+ The settings object allows you to customize the ID generation process. The available options are:
43
+
44
+ lang: The language of the generated words (e.g., 'en' for English, 'es' for Spanish).
45
+ adjective: Set to true to include an adjective in the ID (default: false).
46
+ color: Set to true to include a color in the ID (default: false).
47
+ noun: Set to true to include a noun in the ID (default: false).
48
+ number: An object that configures the number part of the ID:
49
+ min: The minimum value of the number (default: 0).
50
+ max: The maximum value of the number (default: 999).
51
+ completeWithZeros: Set to true to pad the number with leading zeros (default: false).
52
+ sets: The number of sets of random numbers to include, separated by a hyphen (-) (default: 1).
53
+
54
+ ## Test Results
55
+
56
+ While the generated IDs strive for uniqueness, it's important to note that absolute uniqueness cannot be guaranteed, especially with a finite set of words and numbers. During the uniqueness test, the generator produced 999,722 unique IDs out of the expected 1,000,000. This means that a small number of duplicates may occur in practice.
57
+ License
58
+
59
+ This project is licensed under the ISC License.
60
+
61
+ Feel free to modify the `README.md` file to fit your project's specific details and requirements.
@@ -0,0 +1,224 @@
1
+ const words = {
2
+ adjectives: {
3
+ silly: "silly",
4
+ silly: "silly",
5
+ happy: "happy",
6
+ funny: "funny",
7
+ kind: "kind",
8
+ brave: "brave",
9
+ calm: "calm",
10
+ shiny: "shiny",
11
+ witty: "witty",
12
+ sunny: "sunny",
13
+ friendly: "friendly",
14
+ clever: "clever",
15
+ loud: "loud",
16
+ gentle: "gentle",
17
+ honest: "honest",
18
+ polite: "polite",
19
+ caring: "caring",
20
+ playful: "playful",
21
+ cheerful: "cheerful",
22
+ cozy: "cozy",
23
+ daring: "daring",
24
+ patient: "patient",
25
+ eager: "eager",
26
+ creative: "creative",
27
+ quirky: "quirky",
28
+ loyal: "loyal",
29
+ sincere: "sincere",
30
+ thoughtful: "thoughtful",
31
+ wise: "wise",
32
+ sensible: "sensible",
33
+ charming: "charming",
34
+ joyful: "joyful",
35
+ breezy: "breezy",
36
+ vivid: "vivid",
37
+ delightful: "delightful",
38
+ peaceful: "peaceful",
39
+ radiant: "radiant",
40
+ bubbly: "bubbly",
41
+ carefree: "carefree",
42
+ genuine: "genuine",
43
+ lively: "lively",
44
+ mellow: "mellow",
45
+ optimistic: "optimistic",
46
+ relaxed: "relaxed",
47
+ sweet: "sweet",
48
+ tender: "tender",
49
+ vibrant: "vibrant",
50
+ wonderful: "wonderful",
51
+ blissful: "blissful",
52
+ graceful: "graceful",
53
+ gleeful: "gleeful",
54
+ satisfied: "satisfied",
55
+ zesty: "zesty",
56
+ jolly: "jolly",
57
+ merry: "merry",
58
+ festive: "festive",
59
+ amusing: "amusing",
60
+ upbeat: "upbeat",
61
+ content: "content",
62
+ energetic: "energetic",
63
+ bouncy: "bouncy",
64
+ spunky: "spunky",
65
+ harmonious: "harmonious",
66
+ serene: "serene",
67
+ smooth: "smooth",
68
+ comfortable: "comfortable",
69
+ playful: "playful",
70
+ proud: "proud",
71
+ elegant: "elegant",
72
+ dynamic: "dynamic",
73
+ fearless: "fearless",
74
+ brilliant: "brilliant",
75
+ captivating: "captivating",
76
+ exuberant: "exuberant",
77
+ whimsical: "whimsical",
78
+ romantic: "romantic",
79
+ enchanting: "enchanting",
80
+ careful: "careful",
81
+ gallant: "gallant",
82
+ gracious: "gracious",
83
+ spirited: "spirited",
84
+ amiable: "amiable",
85
+ cordial: "cordial",
86
+ rhythmic: "rhythmic",
87
+ gleaming: "gleaming",
88
+ excellent: "excellent",
89
+ adventurous: "adventurous",
90
+ sparkling: "sparkling",
91
+ dreamy: "dreamy",
92
+ spontaneous: "spontaneous",
93
+ inspiring: "inspiring",
94
+ vital: "vital",
95
+ radiant: "radiant",
96
+ refreshing: "refreshing",
97
+ bountiful: "bountiful",
98
+ fabulous: "fabulous",
99
+ playful: "playful",
100
+ zippy: "zippy",
101
+ snazzy: "snazzy",
102
+ pizzazz: "pizzazz"
103
+ },
104
+ colors: {
105
+ red: "red",
106
+ blue: "blue",
107
+ green: "green",
108
+ yellow: "yellow",
109
+ orange: "orange",
110
+ purple: "purple",
111
+ pink: "pink",
112
+ brown: "brown",
113
+ black: "black",
114
+ white: "white",
115
+ gray: "gray",
116
+ silver: "silver",
117
+ gold: "gold",
118
+ beige: "beige",
119
+ turquoise: "turquoise",
120
+ teal: "teal",
121
+ navy: "navy",
122
+ maroon: "maroon",
123
+ olive: "olive",
124
+ indigo: "indigo"
125
+ },
126
+ nouns: {
127
+ cat: "cat",
128
+ dog: "dog",
129
+ bird: "bird",
130
+ rabbit: "rabbit",
131
+ unicorn: "unicorn",
132
+ flower: "flower",
133
+ tree: "tree",
134
+ river: "river",
135
+ ocean: "ocean",
136
+ mountain: "mountain",
137
+ cloud: "cloud",
138
+ sun: "sun",
139
+ moon: "moon",
140
+ star: "star",
141
+ butterfly: "butterfly",
142
+ bee: "bee",
143
+ breeze: "breeze",
144
+ wave: "wave",
145
+ rain: "rain",
146
+ snow: "snow",
147
+ leaf: "leaf",
148
+ stone: "stone",
149
+ sand: "sand",
150
+ boat: "boat",
151
+ bridge: "bridge",
152
+ castle: "castle",
153
+ dream: "dream",
154
+ fire: "fire",
155
+ key: "key",
156
+ lock: "lock",
157
+ music: "music",
158
+ book: "book",
159
+ pen: "pen",
160
+ chair: "chair",
161
+ table: "table",
162
+ window: "window",
163
+ door: "door",
164
+ mirror: "mirror",
165
+ light: "light",
166
+ shadow: "shadow",
167
+ dream: "dream",
168
+ smile: "smile",
169
+ laughter: "laughter",
170
+ friend: "friend",
171
+ love: "love",
172
+ hope: "hope",
173
+ joy: "joy",
174
+ peace: "peace",
175
+ heart: "heart",
176
+ soul: "soul",
177
+ rainbow: "rainbow",
178
+ star: "star",
179
+ planet: "planet",
180
+ galaxy: "galaxy",
181
+ butterfly: "butterfly",
182
+ garden: "garden",
183
+ forest: "forest",
184
+ meadow: "meadow",
185
+ field: "field",
186
+ journey: "journey",
187
+ adventure: "adventure",
188
+ magic: "magic",
189
+ fantasy: "fantasy",
190
+ imagination: "imagination",
191
+ whisper: "whisper",
192
+ giggles: "giggles",
193
+ treasure: "treasure",
194
+ wonder: "wonder",
195
+ serenity: "serenity",
196
+ silence: "silence",
197
+ harmony: "harmony",
198
+ inspiration: "inspiration",
199
+ creativity: "creativity",
200
+ dreamer: "dreamer",
201
+ explorer: "explorer",
202
+ dancer: "dancer",
203
+ artist: "artist",
204
+ story: "story",
205
+ memory: "memory",
206
+ wisdom: "wisdom",
207
+ joy: "joy",
208
+ happiness: "happiness",
209
+ kindness: "kindness",
210
+ gentleness: "gentleness",
211
+ gratitude: "gratitude",
212
+ freedom: "freedom",
213
+ peace: "peace",
214
+ hope: "hope",
215
+ faith: "faith",
216
+ unity: "unity",
217
+ sunset: "sunset",
218
+ sunrise: "sunrise",
219
+ twilight: "twilight",
220
+ midnight: "midnight"
221
+ }
222
+ }
223
+
224
+ module.exports = words;
@@ -0,0 +1,221 @@
1
+ const words = {
2
+ adjectives: {
3
+ alegre: "alegre",
4
+ amable: "amable",
5
+ audaz: "audaz",
6
+ brillante: "brillante",
7
+ calmo: "calmo",
8
+ calido: "calido",
9
+ chistoso: "chistoso",
10
+ contento: "contento",
11
+ creativo: "creativo",
12
+ dulce: "dulce",
13
+ divertido: "divertido",
14
+ encantador: "encantador",
15
+ energetico: "energetico",
16
+ entusiasta: "entusiasta",
17
+ esplendido: "esplendido",
18
+ fresco: "fresco",
19
+ gentil: "gentil",
20
+ gracioso: "gracioso",
21
+ habil: "habil",
22
+ hermoso: "hermoso",
23
+ honrado: "honrado",
24
+ inteligente: "inteligente",
25
+ jovial: "jovial",
26
+ jugueton: "jugueton",
27
+ leal: "leal",
28
+ liviano: "liviano",
29
+ luminoso: "luminoso",
30
+ maravilloso: "maravilloso",
31
+ modesto: "modesto",
32
+ noble: "noble",
33
+ optimista: "optimista",
34
+ paciente: "paciente",
35
+ poderoso: "poderoso",
36
+ radiante: "radiante",
37
+ resplandeciente: "resplandeciente",
38
+ sabio: "sabio",
39
+ sereno: "sereno",
40
+ simpatico: "simpatico",
41
+ soñador: "soñador",
42
+ talentoso: "talentoso",
43
+ tierno: "tierno",
44
+ tranquilo: "tranquilo",
45
+ valiente: "valiente",
46
+ vibrante: "vibrante",
47
+ amigable: "amigable",
48
+ bueno: "bueno",
49
+ celestial: "celestial",
50
+ deseable: "deseable",
51
+ elegante: "elegante",
52
+ especial: "especial",
53
+ excelente: "excelente",
54
+ fascinante: "fascinante",
55
+ feliz: "feliz",
56
+ generoso: "generoso",
57
+ honesto: "honesto",
58
+ iluminado: "iluminado",
59
+ increible: "increible",
60
+ inolvidable: "inolvidable",
61
+ magistral: "magistral",
62
+ pacifico: "pacifico",
63
+ placentero: "placentero",
64
+ positivo: "positivo",
65
+ radioso: "radioso",
66
+ relajado: "relajado",
67
+ satisfecho: "satisfecho",
68
+ sencillo: "sencillo",
69
+ sincero: "sincero",
70
+ solicito: "solicito",
71
+ sorprendente: "sorprendente",
72
+ tenaz: "tenaz",
73
+ triunfante: "triunfante",
74
+ unico: "unico",
75
+ vivaz: "vivaz",
76
+ volador: "volador",
77
+ zumbon: "zumbon",
78
+ armonico: "armonico",
79
+ añorable: "añorable",
80
+ bondadoso: "bondadoso",
81
+ capaz: "capaz",
82
+ cordial: "cordial",
83
+ encantado: "encantado",
84
+ entrañable: "entrañable",
85
+ fascinante: "fascinante",
86
+ fertil: "fertil",
87
+ gozoso: "gozoso",
88
+ habilidoso: "habilidoso",
89
+ honesto: "honesto",
90
+ ideal: "ideal",
91
+ inigualable: "inigualable",
92
+ jugueton: "jugueton",
93
+ luminoso: "luminoso",
94
+ majestuoso: "majestuoso",
95
+ optimista: "optimista",
96
+ radiante: "radiante",
97
+ resplandeciente: "resplandeciente",
98
+ soñador: "soñador",
99
+ talentoso: "talentoso",
100
+ valiente: "valiente",
101
+ vibrante: "vibrante"
102
+ },
103
+ colors: {
104
+ rojo: "rojo",
105
+ azul: "azul",
106
+ verde: "verde",
107
+ amarillo: "amarillo",
108
+ naranja: "naranja",
109
+ morado: "morado",
110
+ rosa: "rosa",
111
+ marron: "marron",
112
+ negro: "negro",
113
+ blanco: "blanco",
114
+ gris: "gris",
115
+ plateado: "plateado",
116
+ dorado: "dorado",
117
+ beige: "beige",
118
+ turquesa: "turquesa",
119
+ celeste: "celeste",
120
+ magenta: "magenta",
121
+ granate: "granate",
122
+ oliva: "oliva",
123
+ añil: "añil"
124
+ },
125
+ nouns: {
126
+ gato: "gato",
127
+ perro: "perro",
128
+ pajaro: "pajaro",
129
+ conejo: "conejo",
130
+ unicornio: "unicornio",
131
+ flor: "flor",
132
+ arbol: "arbol",
133
+ rio: "rio",
134
+ oceano: "oceano",
135
+ montaña: "montana",
136
+ nube: "nube",
137
+ sol: "sol",
138
+ luna: "luna",
139
+ estrella: "estrella",
140
+ mariposa: "mariposa",
141
+ abeja: "abeja",
142
+ brisa: "brisa",
143
+ ola: "ola",
144
+ lluvia: "lluvia",
145
+ nieve: "nieve",
146
+ hoja: "hoja",
147
+ piedra: "piedra",
148
+ arena: "arena",
149
+ barco: "barco",
150
+ puente: "puente",
151
+ castillo: "castillo",
152
+ sueño: "sueno",
153
+ fuego: "fuego",
154
+ llave: "llave",
155
+ libro: "libro",
156
+ pluma: "pluma",
157
+ silla: "silla",
158
+ mesa: "mesa",
159
+ ventana: "ventana",
160
+ puerta: "puerta",
161
+ espejo: "espejo",
162
+ luz: "luz",
163
+ sombra: "sombra",
164
+ sueño: "sueno",
165
+ sonrisa: "sonrisa",
166
+ risa: "risa",
167
+ amigo: "amigo",
168
+ amor: "amor",
169
+ esperanza: "esperanza",
170
+ alegria: "alegria",
171
+ paz: "paz",
172
+ corazon: "corazon",
173
+ alma: "alma",
174
+ arcoiris: "arcoiris",
175
+ estrella: "estrella",
176
+ planeta: "planeta",
177
+ galaxia: "galaxia",
178
+ mariposa: "mariposa",
179
+ jardin: "jardin",
180
+ bosque: "bosque",
181
+ prado: "prado",
182
+ campo: "campo",
183
+ viaje: "viaje",
184
+ aventura: "aventura",
185
+ magia: "magia",
186
+ fantasia: "fantasia",
187
+ imaginacion: "imaginacion",
188
+ susurro: "susurro",
189
+ risitas: "risitas",
190
+ tesoro: "tesoro",
191
+ maravilla: "maravilla",
192
+ serenidad: "serenidad",
193
+ silencio: "silencio",
194
+ armonia: "armonia",
195
+ inspiracion: "inspiracion",
196
+ creatividad: "creatividad",
197
+ soñador: "sonador",
198
+ explorador: "explorador",
199
+ bailarin: "bailarin",
200
+ artista: "artista",
201
+ historia: "historia",
202
+ memoria: "memoria",
203
+ sabiduria: "sabiduria",
204
+ alegria: "alegria",
205
+ felicidad: "felicidad",
206
+ amabilidad: "amabilidad",
207
+ gentileza: "gentileza",
208
+ gratitud: "gratitud",
209
+ libertad: "libertad",
210
+ paz: "paz",
211
+ esperanza: "esperanza",
212
+ fe: "fe",
213
+ unidad: "unidad",
214
+ atardecer: "atardecer",
215
+ amanecer: "amanecer",
216
+ crepusculo: "crepusculo",
217
+ medianoche: "medianoche"
218
+ }
219
+ }
220
+
221
+ module.exports = words;
@@ -0,0 +1,9 @@
1
+ const en = require('./en');
2
+ const es = require('./es');
3
+
4
+ const dictionaries = {
5
+ en,
6
+ es
7
+ };
8
+
9
+ module.exports = dictionaries;
package/index.js ADDED
@@ -0,0 +1,71 @@
1
+ const dictionaries = require('./dictionaries');
2
+
3
+ class IdGenerator {
4
+ constructor(settings = {}) {
5
+ this.lang = dictionaries[settings.lang] ? settings.lang : dictionaries[settings.lang?.split('-')[0]] ? settings.lang?.split('-')[0] : 'en';
6
+ this.useAdjective = settings.adjective || false;
7
+ this.useColor = settings.color || false;
8
+ this.useNoun = settings.noun || false;
9
+ this.numberMin = settings.number && settings.number.min !== undefined ? settings.number.min : 0;
10
+ this.numberMax = settings.number && settings.number.max !== undefined ? settings.number.max : 999;
11
+ this.numberSets = settings.number && settings.number.sets || 1;
12
+ this.completeWithZeros = settings.number && settings.number.completeWithZeros || false;
13
+ }
14
+
15
+ getRandomNumber(min, max) {
16
+ return Math.floor(Math.random() * (max - min + 1)) + min;
17
+ }
18
+
19
+ formatNumber(number) {
20
+ if (this.completeWithZeros) {
21
+ const maxNumberLength = this.numberMax.toString().length;
22
+ return number.toString().padStart(maxNumberLength, '0');
23
+ } else {
24
+ return number.toString();
25
+ }
26
+ }
27
+
28
+ getAdjectives() {
29
+ return dictionaries[this.lang].adjectives;
30
+ }
31
+
32
+ getColors() {
33
+ return dictionaries[this.lang].colors;
34
+ }
35
+
36
+ getNouns() {
37
+ return dictionaries[this.lang].nouns;
38
+ }
39
+
40
+ generateId() {
41
+ const parts = [];
42
+
43
+ if (this.useAdjective) {
44
+ const adjectives = Object.values(this.getAdjectives());
45
+ const adjective = adjectives[Math.floor(Math.random() * adjectives.length)];
46
+ parts.push(adjective);
47
+ }
48
+
49
+ if (this.useColor) {
50
+ const colors = Object.values(this.getColors());
51
+ const color = colors[Math.floor(Math.random() * colors.length)];
52
+ parts.push(color);
53
+ }
54
+
55
+ if (this.useNoun) {
56
+ const nouns = Object.values(this.getNouns());
57
+ const noun = nouns[Math.floor(Math.random() * nouns.length)];
58
+ parts.push(noun);
59
+ }
60
+
61
+ for (let i = 0; i < this.numberSets; i++) {
62
+ const number = this.getRandomNumber(this.numberMin, this.numberMax);
63
+ const formattedNumber = this.formatNumber(number);
64
+ parts.push(formattedNumber);
65
+ }
66
+
67
+ return parts.join('-');
68
+ }
69
+ }
70
+
71
+ module.exports = IdGenerator;
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "human-ids",
3
+ "version": "1.0.0",
4
+ "description": "A library to generate human readable IDs",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "jest --reporters=default --reporters=jest-html-reporter"
8
+ },
9
+ "keywords": [
10
+ "readable",
11
+ "ids",
12
+ "humans",
13
+ "for-humans",
14
+ "human-ids",
15
+ "simple",
16
+ "simple-ids"
17
+ ],
18
+ "author": "JC Mujica",
19
+ "license": "ISC",
20
+ "devDependencies": {
21
+ "jest": "^29.6.1",
22
+ "jest-html-reporter": "^3.10.1"
23
+ }
24
+ }
@@ -0,0 +1,260 @@
1
+ <html><head><meta charset="utf-8"/><title>Test Report</title><style type="text/css">html,
2
+ body {
3
+ font-family: Arial, Helvetica, sans-serif;
4
+ font-size: 1rem;
5
+ margin: 0;
6
+ padding: 0;
7
+ color: #333;
8
+ }
9
+ body {
10
+ padding: 2rem 1rem;
11
+ font-size: 0.85rem;
12
+ }
13
+ .jesthtml-content {
14
+ margin: 0 auto;
15
+ max-width: 70rem;
16
+ }
17
+ header {
18
+ display: flex;
19
+ align-items: center;
20
+ }
21
+ #title {
22
+ margin: 0;
23
+ flex-grow: 1;
24
+ }
25
+ #logo {
26
+ height: 4rem;
27
+ }
28
+ #timestamp {
29
+ color: #777;
30
+ margin-top: 0.5rem;
31
+ }
32
+
33
+ /** SUMMARY */
34
+ #summary {
35
+ color: #333;
36
+ margin: 2rem 0;
37
+ display: flex;
38
+ font-family: monospace;
39
+ font-size: 1rem;
40
+ }
41
+ #summary > div {
42
+ margin-right: 2rem;
43
+ background: #eee;
44
+ padding: 1rem;
45
+ min-width: 15rem;
46
+ }
47
+ #summary > div:last-child {
48
+ margin-right: 0;
49
+ }
50
+ @media only screen and (max-width: 720px) {
51
+ #summary {
52
+ flex-direction: column;
53
+ }
54
+ #summary > div {
55
+ margin-right: 0;
56
+ margin-top: 2rem;
57
+ }
58
+ #summary > div:first-child {
59
+ margin-top: 0;
60
+ }
61
+ }
62
+
63
+ .summary-total {
64
+ font-weight: bold;
65
+ margin-bottom: 0.5rem;
66
+ }
67
+ .summary-passed {
68
+ color: #4f8a10;
69
+ border-left: 0.4rem solid #4f8a10;
70
+ padding-left: 0.5rem;
71
+ }
72
+ .summary-failed,
73
+ .summary-obsolete-snapshots {
74
+ color: #d8000c;
75
+ border-left: 0.4rem solid #d8000c;
76
+ padding-left: 0.5rem;
77
+ }
78
+ .summary-pending {
79
+ color: #9f6000;
80
+ border-left: 0.4rem solid #9f6000;
81
+ padding-left: 0.5rem;
82
+ }
83
+ .summary-empty {
84
+ color: #999;
85
+ border-left: 0.4rem solid #999;
86
+ }
87
+
88
+ .test-result {
89
+ padding: 1rem;
90
+ margin-bottom: 0.25rem;
91
+ }
92
+ .test-result:last-child {
93
+ border: 0;
94
+ }
95
+ .test-result.passed {
96
+ background-color: #dff2bf;
97
+ color: #4f8a10;
98
+ }
99
+ .test-result.failed {
100
+ background-color: #ffbaba;
101
+ color: #d8000c;
102
+ }
103
+ .test-result.pending {
104
+ background-color: #ffdf61;
105
+ color: #9f6000;
106
+ }
107
+
108
+ .test-info {
109
+ display: flex;
110
+ justify-content: space-between;
111
+ }
112
+ .test-suitename {
113
+ width: 20%;
114
+ text-align: left;
115
+ font-weight: bold;
116
+ word-break: break-word;
117
+ }
118
+ .test-title {
119
+ width: 40%;
120
+ text-align: left;
121
+ font-style: italic;
122
+ }
123
+ .test-status {
124
+ width: 20%;
125
+ text-align: right;
126
+ }
127
+ .test-duration {
128
+ width: 10%;
129
+ text-align: right;
130
+ font-size: 0.75rem;
131
+ }
132
+
133
+ .failureMessages {
134
+ padding: 0 1rem;
135
+ margin-top: 1rem;
136
+ border-top: 1px dashed #d8000c;
137
+ }
138
+ .failureMessages.suiteFailure {
139
+ border-top: none;
140
+ }
141
+ .failureMsg {
142
+ white-space: pre-wrap;
143
+ white-space: -moz-pre-wrap;
144
+ white-space: -pre-wrap;
145
+ white-space: -o-pre-wrap;
146
+ word-wrap: break-word;
147
+ }
148
+
149
+ .suite-container {
150
+ margin-bottom: 2rem;
151
+ }
152
+ .suite-container > input[type="checkbox"] {
153
+ position: absolute;
154
+ left: -100vw;
155
+ }
156
+ .suite-container label {
157
+ display: block;
158
+ }
159
+ .suite-container .suite-tests {
160
+ overflow-y: hidden;
161
+ height: 0;
162
+ }
163
+ .suite-container > input[type="checkbox"]:checked ~ .suite-tests {
164
+ height: auto;
165
+ overflow: visible;
166
+ }
167
+ .suite-info {
168
+ padding: 1rem;
169
+ background-color: #eee;
170
+ color: #777;
171
+ display: flex;
172
+ align-items: center;
173
+ margin-bottom: 0.25rem;
174
+ }
175
+ .suite-info:hover {
176
+ background-color: #ddd;
177
+ cursor: pointer;
178
+ }
179
+ .suite-info .suite-path {
180
+ word-break: break-all;
181
+ flex-grow: 1;
182
+ font-family: monospace;
183
+ font-size: 1rem;
184
+ }
185
+ .suite-info .suite-time {
186
+ margin-left: 0.5rem;
187
+ padding: 0.2rem 0.3rem;
188
+ font-size: 0.75rem;
189
+ }
190
+ .suite-info .suite-time.warn {
191
+ background-color: #d8000c;
192
+ color: #fff;
193
+ }
194
+ .suite-info:before {
195
+ content: "\2303";
196
+ display: inline-block;
197
+ margin-right: 0.5rem;
198
+ transform: rotate(0deg);
199
+ }
200
+ .suite-container > input[type="checkbox"]:checked ~ label .suite-info:before {
201
+ transform: rotate(180deg);
202
+ }
203
+
204
+ /* CONSOLE LOGS */
205
+ .suite-consolelog {
206
+ margin-bottom: 0.25rem;
207
+ padding: 1rem;
208
+ background-color: #efefef;
209
+ }
210
+ .suite-consolelog-header {
211
+ font-weight: bold;
212
+ }
213
+ .suite-consolelog-item {
214
+ padding: 0.5rem;
215
+ }
216
+ .suite-consolelog-item pre {
217
+ margin: 0.5rem 0;
218
+ white-space: pre-wrap;
219
+ white-space: -moz-pre-wrap;
220
+ white-space: -pre-wrap;
221
+ white-space: -o-pre-wrap;
222
+ word-wrap: break-word;
223
+ }
224
+ .suite-consolelog-item-origin {
225
+ color: #777;
226
+ font-weight: bold;
227
+ }
228
+ .suite-consolelog-item-message {
229
+ color: #000;
230
+ font-size: 1rem;
231
+ padding: 0 0.5rem;
232
+ }
233
+
234
+ /* OBSOLETE SNAPSHOTS */
235
+ .suite-obsolete-snapshots {
236
+ margin-bottom: 0.25rem;
237
+ padding: 1rem;
238
+ background-color: #ffbaba;
239
+ color: #d8000c;
240
+ }
241
+ .suite-obsolete-snapshots-header {
242
+ font-weight: bold;
243
+ }
244
+ .suite-obsolete-snapshots-item {
245
+ padding: 0.5rem;
246
+ }
247
+ .suite-obsolete-snapshots-item pre {
248
+ margin: 0.5rem 0;
249
+ white-space: pre-wrap;
250
+ white-space: -moz-pre-wrap;
251
+ white-space: -pre-wrap;
252
+ white-space: -o-pre-wrap;
253
+ word-wrap: break-word;
254
+ }
255
+ .suite-obsolete-snapshots-item-message {
256
+ color: #000;
257
+ font-size: 1rem;
258
+ padding: 0 0.5rem;
259
+ }
260
+ </style></head><body><div class="jesthtml-content"><header><h1 id="title">Test Report</h1></header><div id="metadata-container"><div id="timestamp">Started: 2023-07-07 11:15:36</div><div id="summary"><div id="suite-summary"><div class="summary-total">Suites (1)</div><div class="summary-passed summary-empty">0 passed</div><div class="summary-failed ">1 failed</div><div class="summary-pending summary-empty">0 pending</div></div><div id="test-summary"><div class="summary-total">Tests (1)</div><div class="summary-passed summary-empty">0 passed</div><div class="summary-failed ">1 failed</div><div class="summary-pending summary-empty">0 pending</div></div></div></div><div id="suite-1" class="suite-container"><input id="collapsible-0" type="checkbox" class="toggle" checked="checked"/><label for="collapsible-0"><div class="suite-info"><div class="suite-path">/Users/jcmujica/Code/jc/human-ids/tests/index.test.js</div><div class="suite-time warn">247.141s</div></div></label><div class="suite-tests"><div class="test-result failed"><div class="test-info"><div class="test-suitename">IdGenerator</div><div class="test-title">generateId should return a unique ID</div><div class="test-status">failed</div><div class="test-duration">246.948s</div></div></div></div></div></div></body></html>
@@ -0,0 +1,30 @@
1
+ const IdGenerator = require('../index');
2
+
3
+ describe('IdGenerator', () => {
4
+ test('generateId should return a unique ID', () => {
5
+ const testLength = 1000000;
6
+ const settings = {
7
+ lang: 'en',
8
+ adjective: true,
9
+ color: true,
10
+ noun: true,
11
+ number: {
12
+ min: 0,
13
+ max: 9999,
14
+ completeWithZeros: true
15
+ }
16
+ };
17
+
18
+ const idGenerator = new IdGenerator(settings);
19
+ const ids = new Set();
20
+
21
+ // Generate 1000 IDs
22
+ for (let i = 0; i < testLength; i++) {
23
+ const id = idGenerator.generateId();
24
+ ids.add(id);
25
+ }
26
+
27
+ // Assert uniqueness
28
+ expect(ids.size).toBe(testLength);
29
+ });
30
+ });