1
+ var isTravis = process . env . TRAVIS || false ;
2
+
3
+ var testLogin = ( isTravis ? {
4
+ "email" : process . env . EMAIL ,
5
+ "password" : process . env . PASSWORD ,
6
+ "room" : process . env . ROOM ,
7
+ "usernameToBuy" : "" ,
8
+ "noParse" : false
9
+ } : require ( "./test.json" ) ) ;
10
+
1
11
var Plugged = require ( "../plugged" ) ;
2
12
var Logger = require ( "../logger" ) ;
3
13
var chai = require ( "chai" ) ;
4
- var testLogin = require ( "./test.json" ) ;
5
14
var expect = chai . expect ;
6
15
var client = new Plugged ( {
7
16
test : testLogin . noParse
@@ -20,6 +29,10 @@ var _media;
20
29
var _user ;
21
30
var _room ;
22
31
32
+ function execTest ( ) {
33
+ return isTravis ? describe . skip : describe ;
34
+ }
35
+
23
36
function testUser ( user ) {
24
37
expect ( user ) . to . contain . all . keys ( [
25
38
"username" ,
@@ -397,7 +410,7 @@ describe("REST", function () {
397
410
it ( "should retrieve the 152 character long authentication token" , function ( done ) {
398
411
client . getAuthToken ( function ( err , token ) {
399
412
expect ( err ) . to . be . a ( "null" ) ;
400
- expect ( token ) . to . be . a ( "string" ) . and . to . have . length ( 152 ) ;
413
+ expect ( token ) . to . be . a ( "string" ) . and . to . have . length ( 172 ) ;
401
414
done ( ) ;
402
415
} ) ;
403
416
} ) ;
@@ -424,7 +437,7 @@ describe("REST", function () {
424
437
} ) ;
425
438
} ) ;
426
439
427
- describe ( "#findRooms" , function ( ) {
440
+ execTest ( ) ( "#findRooms" , function ( ) {
428
441
it ( "should retrieve an array of room objects filtered by a keyword" , function ( done ) {
429
442
client . findRooms ( "kpop" , 0 , 2 , function ( err , rooms ) {
430
443
expect ( err ) . to . be . a ( "null" ) ;
@@ -455,7 +468,7 @@ describe("REST", function () {
455
468
} ) ;
456
469
} ) ;
457
470
458
- describe ( "#getStaff" , function ( ) {
471
+ execTest ( ) ( "#getStaff" , function ( ) {
459
472
it ( "should retrieve all users online or not with a role > 0" , function ( done ) {
460
473
client . getStaff ( function ( err , staff ) {
461
474
expect ( err ) . to . be . a ( "null" ) ;
@@ -470,7 +483,7 @@ describe("REST", function () {
470
483
} ) ;
471
484
} ) ;
472
485
473
- describe ( "#getUser" , function ( ) {
486
+ execTest ( ) ( "#getUser" , function ( ) {
474
487
it ( "should retrieve the user object for a user" , function ( done ) {
475
488
var users = client . getUsers ( ) ;
476
489
@@ -545,7 +558,7 @@ describe("REST", function () {
545
558
} ) ;
546
559
} ) ;
547
560
548
- describe ( "#addToWaitlist" , function ( ) {
561
+ execTest ( ) ( "#addToWaitlist" , function ( ) {
549
562
it ( "should add a user by their ID to the waitlist" , function ( done ) {
550
563
client . addToWaitlist ( _user . id , function ( err ) {
551
564
@@ -559,13 +572,13 @@ describe("REST", function () {
559
572
} ) ;
560
573
} ) ;
561
574
562
- describe ( "#meh" , function ( ) {
575
+ execTest ( ) ( "#meh" , function ( ) {
563
576
it ( "should meh a song" , function ( done ) {
564
577
client . meh ( done ) ;
565
578
} ) ;
566
579
} ) ;
567
580
568
- describe ( "#woot" , function ( ) {
581
+ execTest ( ) ( "#woot" , function ( ) {
569
582
it ( "should woot a song" , function ( done ) {
570
583
client . woot ( done ) ;
571
584
} ) ;
@@ -587,7 +600,7 @@ describe("REST", function () {
587
600
} ) ;
588
601
} ) ;
589
602
590
- describe ( "#grab" , function ( ) {
603
+ execTest ( ) ( "#grab" , function ( ) {
591
604
it ( "should grab a song" , function ( done ) {
592
605
client . grab ( _playlist , done ) ;
593
606
} ) ;
@@ -616,13 +629,13 @@ describe("REST", function () {
616
629
} ) ;
617
630
} ) ;
618
631
619
- describe ( "#skipDJ" , function ( ) {
632
+ execTest ( ) ( "#skipDJ" , function ( ) {
620
633
it ( "should skip the current DJ" , function ( done ) {
621
634
client . skipDJ ( testLogin . noParse ? client . getBooth ( ) . currentDJ : client . getCurrentDJ ( ) . id , done ) ;
622
635
} ) ;
623
636
} ) ;
624
637
625
- describe ( "#moveDJ" , function ( ) {
638
+ execTest ( ) ( "#moveDJ" , function ( ) {
626
639
it ( "should move a DJ to a new position in the waitlist" , function ( done ) {
627
640
var waitlist = client . getWaitlist ( ) ;
628
641
client . moveDJ ( waitlist [ waitlist . length - 1 ] , 0 , done ) ;
@@ -668,7 +681,7 @@ describe("REST", function () {
668
681
} ) ;
669
682
} ) ;
670
683
671
- describe ( "#muteUser" , function ( ) {
684
+ execTest ( ) ( "#muteUser" , function ( ) {
672
685
it ( "should mute a user" , function ( done ) {
673
686
client . muteUser ( _user . id , client . MUTEDURATION . SHORT , client . BANREASON . VIOLATING_COMMUNITY_RULES , function ( err ) {
674
687
@@ -710,13 +723,13 @@ describe("REST", function () {
710
723
} ) ;
711
724
} ) ;
712
725
713
- describe ( "#addStaff" , function ( ) {
726
+ execTest ( ) ( "#addStaff" , function ( ) {
714
727
it ( "should add a user as staff" , function ( done ) {
715
728
client . addStaff ( _user . id , client . USERROLE . BOUNCER , done ) ;
716
729
} ) ;
717
730
} ) ;
718
731
719
- describe ( "#ignoreUser" , function ( ) {
732
+ execTest ( ) ( "#ignoreUser" , function ( ) {
720
733
it ( "should ignore a user" , function ( done ) {
721
734
client . ignoreUser ( _user . id , done ) ;
722
735
} ) ;
@@ -744,7 +757,7 @@ describe("REST", function () {
744
757
} ) ;
745
758
} ) ;
746
759
747
- describe ( "#removeIgnore" , function ( ) {
760
+ execTest ( ) ( "#removeIgnore" , function ( ) {
748
761
it ( "should remove the previously ignored user" , function ( done ) {
749
762
client . removeIgnore ( _user . id , function ( err , ignore ) {
750
763
expect ( err ) . to . be . a ( "null" ) ;
@@ -763,7 +776,7 @@ describe("REST", function () {
763
776
} ) ;
764
777
} ) ;
765
778
766
- describe ( "#removeStaff" , function ( ) {
779
+ execTest ( ) ( "#removeStaff" , function ( ) {
767
780
it ( "should remove the previously added staff member" , function ( done ) {
768
781
client . removeStaff ( _user . id , function ( err ) {
769
782
@@ -777,7 +790,7 @@ describe("REST", function () {
777
790
} ) ;
778
791
} ) ;
779
792
780
- describe ( "#removeDJ" , function ( ) {
793
+ execTest ( ) ( "#removeDJ" , function ( ) {
781
794
it ( "should remove a DJ from the waitlist" , function ( done ) {
782
795
var user = client . getWaitlist ( ) [ 0 ] ;
783
796
client . removeDJ ( user , function ( err ) {
@@ -798,13 +811,13 @@ describe("REST", function () {
798
811
} ) ;
799
812
} ) ;
800
813
801
- describe ( "#unmuteUser" , function ( ) {
814
+ execTest ( ) ( "#unmuteUser" , function ( ) {
802
815
it ( "should unmute the previously muted user" , function ( done ) {
803
816
client . unmuteUser ( _user . id , done ) ;
804
817
} ) ;
805
818
} ) ;
806
819
807
- describe ( "#banUser" , function ( ) {
820
+ execTest ( ) ( "#banUser" , function ( ) {
808
821
it ( "should ban a user" , function ( done ) {
809
822
client . banUser ( _user . id , client . BANDURATION . SHORT , client . BANREASON . VIOLATING_COMMUNITY_RULES , function ( err ) {
810
823
@@ -818,7 +831,7 @@ describe("REST", function () {
818
831
} ) ;
819
832
} ) ;
820
833
821
- describe ( "#unbanUser" , function ( ) {
834
+ execTest ( ) ( "#unbanUser" , function ( ) {
822
835
it ( "should unban the previously banned user" , function ( done ) {
823
836
client . unbanUser ( _user . id , done ) ;
824
837
} ) ;
@@ -1130,7 +1143,7 @@ describe("REST", function () {
1130
1143
} ) ;
1131
1144
} ) ;
1132
1145
1133
- describe ( "#addFriend" , function ( ) {
1146
+ execTest ( ) ( "#addFriend" , function ( ) {
1134
1147
it ( "should add a user as a friend" , function ( done ) {
1135
1148
client . addFriend ( _user . id , done ) ;
1136
1149
} ) ;
@@ -1198,7 +1211,7 @@ describe("REST", function () {
1198
1211
} ) ;
1199
1212
} ) ;
1200
1213
1201
- describe ( "#removeFriend" , function ( ) {
1214
+ execTest ( ) ( "#removeFriend" , function ( ) {
1202
1215
it ( "should remove a user as a friend" , function ( done ) {
1203
1216
client . removeFriend ( _user . id , done ) ;
1204
1217
} ) ;
@@ -1350,7 +1363,7 @@ describe("Local", function () {
1350
1363
} ) ;
1351
1364
} ) ;
1352
1365
1353
- describe ( "#getChatByUser" , function ( ) {
1366
+ execTest ( ) ( "#getChatByUser" , function ( ) {
1354
1367
it ( "should get the messages written by a user" , function ( ) {
1355
1368
_user = client . getUsers ( ) [ 0 ] ;
1356
1369
var messages = client . getChatByUser ( _user . username ) ;
@@ -1382,7 +1395,7 @@ describe("Local", function () {
1382
1395
} ) ;
1383
1396
} ) ;
1384
1397
1385
- describe ( "#removeChatMessage" , function ( ) {
1398
+ execTest ( ) ( "#removeChatMessage" , function ( ) {
1386
1399
it ( "should remove a chat message" , function ( ) {
1387
1400
var chat = client . getChat ( ) ;
1388
1401
var length = chat . length ;
@@ -1394,7 +1407,7 @@ describe("Local", function () {
1394
1407
} ) ;
1395
1408
} ) ;
1396
1409
1397
- describe ( "#removeChatMessagesByUser" , function ( ) {
1410
+ execTest ( ) ( "#removeChatMessagesByUser" , function ( ) {
1398
1411
it ( "should delete all messages of a user" , function ( ) {
1399
1412
client . removeChatMessagesByUser ( _user . username , true ) ;
1400
1413
expect ( client . getChatByUser ( _user . username ) ) . to . be . an ( "array" ) . and . have . length ( 0 ) ;
@@ -1435,7 +1448,7 @@ describe("Local", function () {
1435
1448
} ) ;
1436
1449
} ) ;
1437
1450
1438
- describe ( "#clearUserFromLists" , function ( ) {
1451
+ execTest ( ) ( "#clearUserFromLists" , function ( ) {
1439
1452
it ( "should clear the user from the vote and grab list" , function ( ) {
1440
1453
client . clearUserFromLists ( _user . id ) ;
1441
1454
var done = true ;
@@ -1466,19 +1479,19 @@ describe("Local", function () {
1466
1479
} ) ;
1467
1480
} ) ;
1468
1481
1469
- describe ( "#getUserByName" , function ( ) {
1482
+ execTest ( ) ( "#getUserByName" , function ( ) {
1470
1483
it ( "should get a user by name" , function ( ) {
1471
1484
testUser ( client . getUserByName ( _user . username ) ) ;
1472
1485
} ) ;
1473
1486
} ) ;
1474
1487
1475
- describe ( "#getUserByID" , function ( ) {
1488
+ execTest ( ) ( "#getUserByID" , function ( ) {
1476
1489
it ( "should get a user by their ID" , function ( ) {
1477
1490
testUser ( client . getUserByID ( _user . id ) ) ;
1478
1491
} ) ;
1479
1492
} ) ;
1480
1493
1481
- describe ( "#getUserRole" , function ( ) {
1494
+ execTest ( ) ( "#getUserRole" , function ( ) {
1482
1495
it ( "should get a user's role" , function ( ) {
1483
1496
expect ( client . getUserRole ( _user . id ) ) . to . equal ( _user . role ) ;
1484
1497
} ) ;
@@ -1489,7 +1502,9 @@ describe("Local", function () {
1489
1502
var users = client . getUsers ( ) ;
1490
1503
1491
1504
expect ( users ) . to . be . an ( "array" ) ;
1492
- testUser ( users [ 0 ] ) ;
1505
+
1506
+ if ( users . length > 0 )
1507
+ testUser ( users [ 0 ] ) ;
1493
1508
} ) ;
1494
1509
} ) ;
1495
1510
@@ -1516,13 +1531,13 @@ describe("Local", function () {
1516
1531
} ) ;
1517
1532
} ) ;
1518
1533
1519
- describe ( "#isFriend" , function ( ) {
1534
+ execTest ( ) ( "#isFriend" , function ( ) {
1520
1535
it ( "should indicate whether a user is a friend or not" , function ( ) {
1521
1536
expect ( client . isFriend ( _user . id ) ) . to . be . a ( "boolean" ) ;
1522
1537
} ) ;
1523
1538
} ) ;
1524
1539
1525
- describe ( "#getCurrentDJ" , function ( ) {
1540
+ execTest ( ) ( "#getCurrentDJ" , function ( ) {
1526
1541
it ( "should get the current DJ playing" , function ( ) {
1527
1542
var dj = client . getCurrentDJ ( ) ;
1528
1543
@@ -1531,7 +1546,7 @@ describe("Local", function () {
1531
1546
} ) ;
1532
1547
} ) ;
1533
1548
1534
- describe ( "#getCurrentMedia" , function ( ) {
1549
+ execTest ( ) ( "#getCurrentMedia" , function ( ) {
1535
1550
it ( "should return the current media object" , function ( ) {
1536
1551
testMedia ( client . getCurrentMedia ( ) ) ;
1537
1552
} ) ;
@@ -1618,7 +1633,7 @@ describe("Local", function () {
1618
1633
} ) ;
1619
1634
} ) ;
1620
1635
1621
- describe ( "#checkGlobalRole" , function ( ) {
1636
+ execTest ( ) ( "#checkGlobalRole" , function ( ) {
1622
1637
it ( "should give back the global role of a user" , function ( ) {
1623
1638
expect ( client . checkGlobalRole ( _user . gRole ) ) . to . be . a ( "number" ) ;
1624
1639
} ) ;
@@ -1763,19 +1778,19 @@ describe("Local", function () {
1763
1778
} ) ;
1764
1779
} ) ;
1765
1780
1766
- describe ( "#cacheUser" , function ( ) {
1781
+ execTest ( ) ( "#cacheUser" , function ( ) {
1767
1782
it ( "should cache a user" , function ( ) {
1768
1783
expect ( client . cacheUser ( _user ) ) . to . be . a ( "boolean" ) . and . equal ( true ) ;
1769
1784
} ) ;
1770
1785
} ) ;
1771
1786
1772
- describe ( "#removeCachedUserByID" , function ( ) {
1787
+ execTest ( ) ( "#removeCachedUserByID" , function ( ) {
1773
1788
it ( "should remove a cached user by their ID" , function ( ) {
1774
1789
expect ( client . removeCachedUserByID ( _user . id ) ) . to . be . a ( "boolean" ) . and . equal ( true ) ;
1775
1790
} ) ;
1776
1791
} ) ;
1777
1792
1778
- describe ( "#removeCachedUserByName" , function ( ) {
1793
+ execTest ( ) ( "#removeCachedUserByName" , function ( ) {
1779
1794
it ( "should remove a cached user by their Name" , function ( ) {
1780
1795
client . cacheUser ( _user ) ;
1781
1796
expect ( client . removeCachedUserByName ( _user . username ) ) . to . be . a ( "boolean" ) . and . equal ( true ) ;
0 commit comments