homey-lib 2.45.0 → 2.45.2

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.
@@ -1,685 +0,0 @@
1
- /* eslint-disable node/no-unpublished-require */
2
-
3
- 'use strict';
4
-
5
- const {
6
- baseAppManifest,
7
- mockApp,
8
- clearMockApp,
9
- assertValidates,
10
- } = require('./fixtures/mock-app');
11
-
12
- describe('HomeyLib.App#validate() base manifest', function() {
13
- this.slow(500);
14
-
15
- afterEach(function() {
16
- clearMockApp();
17
- });
18
-
19
- /*
20
- * App ID
21
- */
22
-
23
- it('`id` needs to be defined', async function() {
24
- const app = mockApp({
25
- ...baseAppManifest,
26
- id: undefined,
27
- });
28
-
29
- await assertValidates(app, {
30
- debug: /should have required property 'id'/i,
31
- publish: /should have required property 'id'/i,
32
- verified: /should have required property 'id'/i,
33
- });
34
- });
35
-
36
- it('`id` needs to be a reverse DNS', async function() {
37
- const app = mockApp({
38
- ...baseAppManifest,
39
- id: 'test',
40
- });
41
-
42
- await assertValidates(app, {
43
- debug: /invalid id/i,
44
- publish: /invalid id/i,
45
- verified: /invalid id/i,
46
- });
47
- });
48
-
49
- /*
50
- * App Name
51
- */
52
-
53
- it('`name` needs to be defined', async function() {
54
- const app = mockApp({
55
- ...baseAppManifest,
56
- name: undefined,
57
- });
58
-
59
- await assertValidates(app, {
60
- debug: /should have required property 'name'/i,
61
- publish: /should have required property 'name'/i,
62
- verified: /should have required property 'name'/i,
63
- });
64
- });
65
-
66
- /*
67
- * App Brand Color
68
- */
69
-
70
- it('`brandColor` needs to be defined', async function() {
71
- const app = mockApp({
72
- ...baseAppManifest,
73
- brandColor: undefined,
74
- });
75
-
76
- await assertValidates(app, {
77
- debug: true, // brandColor is optional for debug
78
- publish: /property `brandColor` is required/i,
79
- verified: /property `brandColor` is required/i,
80
- });
81
- });
82
-
83
- it('`brandColor` needs to be a hex color', async function() {
84
- const app = mockApp({
85
- ...baseAppManifest,
86
- brandColor: 'fuchsia',
87
- });
88
-
89
- await assertValidates(app, {
90
- debug: /brandColor should match pattern/i,
91
- publish: /brandColor should match pattern/i,
92
- verified: /brandColor should match pattern/i,
93
- });
94
- });
95
-
96
- it('`brandColor` is not allowed to be too bright', async function() {
97
- const app = mockApp({
98
- ...baseAppManifest,
99
- brandColor: '#FFFFFF',
100
- });
101
-
102
- await assertValidates(app, {
103
- debug: /`brandColor` is too bright/i,
104
- publish: /`brandColor` is too bright/i,
105
- verified: /`brandColor` is too bright/i,
106
- });
107
- });
108
-
109
- /*
110
- * App Version
111
- */
112
-
113
- it('`version` needs to be defined', async function() {
114
- const app = mockApp({
115
- ...baseAppManifest,
116
- version: undefined,
117
- });
118
-
119
- await assertValidates(app, {
120
- debug: /should have required property 'version'/i,
121
- publish: /should have required property 'version'/i,
122
- verified: /should have required property 'version'/i,
123
- });
124
- });
125
-
126
- it('`version` needs to be a valid semver string', async function() {
127
- const app = mockApp({
128
- ...baseAppManifest,
129
- version: '1',
130
- });
131
-
132
- await assertValidates(app, {
133
- debug: /invalid version/i,
134
- publish: /invalid version/i,
135
- verified: /invalid version/i,
136
- });
137
- });
138
-
139
- /*
140
- * App SDK version
141
- */
142
-
143
- it('`sdk` can be undefined', async function() {
144
- const app = mockApp({
145
- ...baseAppManifest,
146
- sdk: undefined,
147
- });
148
-
149
- await assertValidates(app, {
150
- debug: true,
151
- publish: true,
152
- verified: true,
153
- });
154
- });
155
-
156
- it('`sdk` needs to be valid', async function() {
157
- const app = mockApp({
158
- ...baseAppManifest,
159
- sdk: 0,
160
- });
161
-
162
- await assertValidates(app, {
163
- debug: /sdk should be >= 1/i,
164
- publish: /sdk should be >= 1/i,
165
- verified: /sdk should be >= 1/i,
166
- });
167
- });
168
-
169
- it('`sdk: 3` needs at least `compatibility: ">=5.0.0"`', async function() {
170
- const app = mockApp({
171
- ...baseAppManifest,
172
- sdk: 3,
173
- compatibility: '>=4.2.0',
174
- });
175
-
176
- await assertValidates(app, {
177
- debug: /sdk version 3 apps must have a compatibility of at least >=5.0.0/i,
178
- publish: /sdk version 3 apps must have a compatibility of at least >=5.0.0/i,
179
- verified: /sdk version 3 apps must have a compatibility of at least >=5.0.0/i,
180
- });
181
- });
182
-
183
- /*
184
- * App Compatibility
185
- */
186
-
187
- it('`compatibility` needs to be defined', async function() {
188
- const app = mockApp({
189
- ...baseAppManifest,
190
- compatibility: undefined,
191
- });
192
-
193
- await assertValidates(app, {
194
- debug: /should have required property 'compatibility'/i,
195
- publish: /should have required property 'compatibility'/i,
196
- verified: /should have required property 'compatibility'/i,
197
- });
198
- });
199
-
200
- it('`compatibility` needs to be a valid semver string', async function() {
201
- const app = mockApp({
202
- ...baseAppManifest,
203
- compatibility: '1',
204
- });
205
-
206
- await assertValidates(app, {
207
- debug: /invalid compatibility/i,
208
- publish: /invalid compatibility/i,
209
- verified: /invalid compatibility/i,
210
- });
211
- });
212
-
213
- /*
214
- * App Platforms
215
- */
216
-
217
- it('`platforms` needs to be defined', async function() {
218
- const app = mockApp({
219
- ...baseAppManifest,
220
- platforms: undefined,
221
- });
222
-
223
- await assertValidates(app, {
224
- debug: true, // platforms is optional for debug
225
- publish: true, // platforms is optional for publish
226
- verified: /property `platforms` is required/i,
227
- });
228
- });
229
-
230
- it('`platforms` needs to be valid', async function() {
231
- const app = mockApp({
232
- ...baseAppManifest,
233
- platforms: ['none'],
234
- });
235
-
236
- await assertValidates(app, {
237
- debug: /platforms\[0\] should be equal to one of the allowed values/i,
238
- publish: /platforms\[0\] should be equal to one of the allowed values/i,
239
- verified: /platforms\[0\] should be equal to one of the allowed values/i,
240
- });
241
- });
242
-
243
- /*
244
- * App Category
245
- */
246
-
247
- it('`category` needs to be defined', async function() {
248
- const app = mockApp({
249
- ...baseAppManifest,
250
- category: undefined,
251
- });
252
-
253
- await assertValidates(app, {
254
- debug: true, // category is optional for debug
255
- publish: /property `category` is required/i,
256
- verified: /property `category` is required/i,
257
- });
258
- });
259
-
260
- it('`category` needs to be valid', async function() {
261
- const app = mockApp({
262
- ...baseAppManifest,
263
- category: ['none'],
264
- });
265
-
266
- await assertValidates(app, {
267
- debug: /invalid category/i,
268
- publish: /invalid category/i,
269
- verified: /invalid category/i,
270
- });
271
- });
272
-
273
- /*
274
- * App Tags
275
- */
276
-
277
- it('`tags` can be validated', async function() {
278
- const app = mockApp({
279
- ...baseAppManifest,
280
- tags: { en: ['test'] },
281
- });
282
-
283
- await assertValidates(app, {
284
- debug: true,
285
- publish: true,
286
- verified: true,
287
- });
288
- });
289
-
290
- it('`tags` needs to be valid', async function() {
291
- const app = mockApp({
292
- ...baseAppManifest,
293
- tags: 'test',
294
- });
295
-
296
- await assertValidates(app, {
297
- debug: /tags should be object/i,
298
- publish: /tags should be object/i,
299
- verified: /tags should be object/i,
300
- });
301
- });
302
-
303
- /*
304
- * App Images
305
- */
306
-
307
- it('`images` needs to be defined', async function() {
308
- const app = mockApp({
309
- ...baseAppManifest,
310
- images: undefined,
311
- });
312
-
313
- await assertValidates(app, {
314
- debug: true, // debug does not validate images
315
- publish: /property `images` is required/i,
316
- verified: /property `images` is required/i,
317
- });
318
- });
319
-
320
- it('`images` need to be a known format', async function() {
321
- const app = mockApp({
322
- ...baseAppManifest,
323
- images: {
324
- small: '/assets/images/small.webp',
325
- large: '/assets/images/large.webp',
326
- xlarge: '/assets/images/xlarge.webp',
327
- },
328
- });
329
-
330
- await assertValidates(app, {
331
- debug: true, // debug does not validate images
332
- publish: /invalid image extension/i,
333
- verified: /invalid image extension/i,
334
- });
335
- });
336
-
337
- /*
338
- * App Author
339
- */
340
-
341
- it('`author` needs to be defined', async function() {
342
- const app = mockApp({
343
- ...baseAppManifest,
344
- author: undefined,
345
- });
346
-
347
- await assertValidates(app, {
348
- debug: /should have required property 'author'/i,
349
- publish: /should have required property 'author'/i,
350
- verified: /should have required property 'author'/i,
351
- });
352
- });
353
-
354
- it('`author.name` should be defined', async function() {
355
- const app = mockApp({
356
- ...baseAppManifest,
357
- author: {
358
- name: undefined,
359
- },
360
- });
361
-
362
- await assertValidates(app, {
363
- debug: /author should have required property 'name'/i,
364
- publish: /author should have required property 'name'/i,
365
- verified: /author should have required property 'name'/i,
366
- });
367
- });
368
-
369
- it('`author.email` should be valid', async function() {
370
- const app = mockApp({
371
- ...baseAppManifest,
372
- author: {
373
- name: 'Athom B.V.',
374
- email: 10,
375
- },
376
- });
377
-
378
- await assertValidates(app, {
379
- debug: /author\.email should be string/i,
380
- publish: /author\.email should be string/i,
381
- verified: /author\.email should be string/i,
382
- });
383
- });
384
-
385
- it('`author.website` should be valid', async function() {
386
- const app = mockApp({
387
- ...baseAppManifest,
388
- author: {
389
- name: 'Athom B.V.',
390
- website: 10,
391
- },
392
- });
393
-
394
- await assertValidates(app, {
395
- debug: /author\.website should be string/i,
396
- publish: /author\.website should be string/i,
397
- verified: /author\.website should be string/i,
398
- });
399
- });
400
-
401
- /*
402
- * App Support
403
- */
404
-
405
- it('`support` needs to be defined', async function() {
406
- const app = mockApp({
407
- ...baseAppManifest,
408
- support: undefined,
409
- });
410
-
411
- await assertValidates(app, {
412
- debug: true, // support is optional for debug
413
- publish: true, // support is optional for publish
414
- verified: /property `support` is required/i,
415
- });
416
- });
417
-
418
- it('`support` needs to be a valid link', async function() {
419
- const app = mockApp({
420
- ...baseAppManifest,
421
- support: 'test',
422
- });
423
-
424
- await assertValidates(app, {
425
- debug: /support should match pattern/i,
426
- publish: /support should match pattern/i,
427
- verified: /support should match pattern/i,
428
- });
429
- });
430
-
431
- /*
432
- * App Permissions
433
- */
434
-
435
- it('`permissions` can be validated', async function() {
436
- const app = mockApp({
437
- ...baseAppManifest,
438
- permissions: ['homey:wireless:ble', 'homey:app:com.athom.example'],
439
- });
440
-
441
- await assertValidates(app, {
442
- debug: true,
443
- publish: true,
444
- verified: true,
445
- });
446
- });
447
-
448
- it('`permissions` needs to be valid', async function() {
449
- const app = mockApp({
450
- ...baseAppManifest,
451
- permissions: ['none'],
452
- });
453
-
454
- await assertValidates(app, {
455
- debug: /invalid permission/i,
456
- publish: /invalid permission/i,
457
- verified: /invalid permission/i,
458
- });
459
- });
460
-
461
- /*
462
- * App Source
463
- */
464
-
465
- it('`source` can be validated', async function() {
466
- const app = mockApp({
467
- ...baseAppManifest,
468
- source: 'https://github.com/athombv/com.athom.myapp',
469
- });
470
-
471
- await assertValidates(app, {
472
- debug: true,
473
- publish: true,
474
- verified: true,
475
- });
476
- });
477
-
478
- it('`source` needs to be valid', async function() {
479
- const app = mockApp({
480
- ...baseAppManifest,
481
- source: 'test',
482
- });
483
-
484
- await assertValidates(app, {
485
- debug: /source should match pattern/i,
486
- publish: /source should match pattern/i,
487
- verified: /source should match pattern/i,
488
- });
489
- });
490
-
491
- /*
492
- * App Home Page
493
- */
494
-
495
- it('`homepage` can be validated', async function() {
496
- const app = mockApp({
497
- ...baseAppManifest,
498
- homepage: 'https://homey.app/',
499
- });
500
-
501
- await assertValidates(app, {
502
- debug: true,
503
- publish: true,
504
- verified: true,
505
- });
506
- });
507
-
508
- it('`homepage` needs to be valid', async function() {
509
- const app = mockApp({
510
- ...baseAppManifest,
511
- homepage: 'test',
512
- });
513
-
514
- await assertValidates(app, {
515
- debug: /homepage should match pattern/i,
516
- publish: /homepage should match pattern/i,
517
- verified: /homepage should match pattern/i,
518
- });
519
- });
520
-
521
- /*
522
- * App Bugs
523
- */
524
-
525
- it('`bugs` can be validated', async function() {
526
- const app = mockApp({
527
- ...baseAppManifest,
528
- bugs: {
529
- url: 'https://github.com/athombv/homey-apps-sdk-issues/issues',
530
- },
531
- });
532
-
533
- await assertValidates(app, {
534
- debug: true,
535
- publish: true,
536
- verified: true,
537
- });
538
- });
539
-
540
- it('`bugs` needs to be valid', async function() {
541
- const app = mockApp({
542
- ...baseAppManifest,
543
- bugs: 'test',
544
- });
545
-
546
- await assertValidates(app, {
547
- debug: /bugs should be object/i,
548
- publish: /bugs should be object/i,
549
- verified: /bugs should be object/i,
550
- });
551
- });
552
-
553
- /*
554
- * App Athom Forum Discussion ID
555
- */
556
-
557
- it('`athomForumDiscussionId` can be validated', async function() {
558
- const app = mockApp({
559
- ...baseAppManifest,
560
- athomForumDiscussionId: 1234,
561
- });
562
-
563
- await assertValidates(app, {
564
- debug: true,
565
- publish: true,
566
- verified: true,
567
- });
568
- });
569
-
570
- it('`athomForumDiscussionId` needs to be valid', async function() {
571
- const app = mockApp({
572
- ...baseAppManifest,
573
- athomForumDiscussionId: 'test',
574
- });
575
-
576
- await assertValidates(app, {
577
- debug: /athomForumDiscussionId should be number/i,
578
- publish: /athomForumDiscussionId should be number/i,
579
- verified: /athomForumDiscussionId should be number/i,
580
- });
581
- });
582
-
583
- /*
584
- * App Homey Community Topic ID
585
- */
586
-
587
- it('`homeyCommunityTopicId` can be validated', async function() {
588
- const app = mockApp({
589
- ...baseAppManifest,
590
- homeyCommunityTopicId: 1234,
591
- });
592
-
593
- await assertValidates(app, {
594
- debug: true,
595
- publish: true,
596
- verified: true,
597
- });
598
- });
599
-
600
- it('`homeyCommunityTopicId` needs to be valid', async function() {
601
- const app = mockApp({
602
- ...baseAppManifest,
603
- homeyCommunityTopicId: 'test',
604
- });
605
-
606
- await assertValidates(app, {
607
- debug: /homeyCommunityTopicId should be number/i,
608
- publish: /homeyCommunityTopicId should be number/i,
609
- verified: /homeyCommunityTopicId should be number/i,
610
- });
611
- });
612
-
613
- /*
614
- * App Homey Community Topic ID
615
- */
616
-
617
- it('`contributers` can be validated', async function() {
618
- const app = mockApp({
619
- ...baseAppManifest,
620
- contributors: {
621
- developers: [{
622
- name: 'Athom B.V.',
623
- email: 'info@athom.com',
624
- website: 'https://athom.nl',
625
- }],
626
- translators: [{
627
- name: 'Athom B.V.',
628
- email: 'info@athom.com',
629
- website: 'https://athom.nl',
630
- }],
631
- },
632
- });
633
-
634
- await assertValidates(app, {
635
- debug: true,
636
- publish: true,
637
- verified: true,
638
- });
639
- });
640
-
641
- it('`contributers` cannot contain additional properties', async function() {
642
- const app = mockApp({
643
- ...baseAppManifest,
644
- contributors: {
645
- test: {},
646
- },
647
- });
648
-
649
- await assertValidates(app, {
650
- debug: /contributors should not have additional properties/i,
651
- publish: /contributors should not have additional properties/i,
652
- verified: /contributors should not have additional properties/i,
653
- });
654
- });
655
-
656
- it('`contributers.developers` needs to be valid', async function() {
657
- const app = mockApp({
658
- ...baseAppManifest,
659
- contributors: {
660
- developers: {},
661
- },
662
- });
663
-
664
- await assertValidates(app, {
665
- debug: /contributors\['developers'\] should be array/i,
666
- publish: /contributors\['developers'\] should be array/i,
667
- verified: /contributors\['developers'\] should be array/i,
668
- });
669
- });
670
-
671
- it('`contributers.translators` needs to be valid', async function() {
672
- const app = mockApp({
673
- ...baseAppManifest,
674
- contributors: {
675
- translators: {},
676
- },
677
- });
678
-
679
- await assertValidates(app, {
680
- debug: /contributors\['translators'\] should be array/i,
681
- publish: /contributors\['translators'\] should be array/i,
682
- verified: /contributors\['translators'\] should be array/i,
683
- });
684
- });
685
- });