Skip to content

Commit 6f21799

Browse files
committed
added .travis.yml; added badges to README.md; test.js is now ready for use
with TravisCI
1 parent 5851a26 commit 6f21799

File tree

3 files changed

+67
-37
lines changed

3 files changed

+67
-37
lines changed

.travis.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
language: node_js
2+
node_js:
3+
- "0.12"
4+
- "0.11"
5+
- "0.10"
6+
7+
before_script:
8+
- "npm install -g mocha"
9+
- "cd test"
10+
- "npm install chai"
11+
- "cd ../"

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
[![](https://nodei.co/npm/plugged.png?downloadRank=true)](https://npmjs.com/package/plugged)
2+
3+
[![](https://travis-ci.org/SooYou/plugged.svg)](https://travis-ci.org/SooYou/plugged) [![](https://david-dm.org/SooYou/plugged.svg)](https://david-dm.org/SooYou/plugged)
4+
15
plugged
26
==========
37
plugged is a (v|f)ast JavaScript API for the plug.dj service.

test/test.js

+52-37
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
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+
111
var Plugged = require("../plugged");
212
var Logger = require("../logger");
313
var chai = require("chai");
4-
var testLogin = require("./test.json");
514
var expect = chai.expect;
615
var client = new Plugged({
716
test: testLogin.noParse
@@ -20,6 +29,10 @@ var _media;
2029
var _user;
2130
var _room;
2231

32+
function execTest() {
33+
return isTravis ? describe.skip : describe;
34+
}
35+
2336
function testUser(user) {
2437
expect(user).to.contain.all.keys([
2538
"username",
@@ -397,7 +410,7 @@ describe("REST", function () {
397410
it("should retrieve the 152 character long authentication token", function (done) {
398411
client.getAuthToken(function (err, token) {
399412
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);
401414
done();
402415
});
403416
});
@@ -424,7 +437,7 @@ describe("REST", function () {
424437
});
425438
});
426439

427-
describe("#findRooms", function () {
440+
execTest()("#findRooms", function () {
428441
it("should retrieve an array of room objects filtered by a keyword", function (done) {
429442
client.findRooms("kpop", 0, 2, function (err, rooms) {
430443
expect(err).to.be.a("null");
@@ -455,7 +468,7 @@ describe("REST", function () {
455468
});
456469
});
457470

458-
describe("#getStaff", function () {
471+
execTest()("#getStaff", function () {
459472
it("should retrieve all users online or not with a role > 0", function (done) {
460473
client.getStaff(function (err, staff) {
461474
expect(err).to.be.a("null");
@@ -470,7 +483,7 @@ describe("REST", function () {
470483
});
471484
});
472485

473-
describe("#getUser", function () {
486+
execTest()("#getUser", function () {
474487
it("should retrieve the user object for a user", function (done) {
475488
var users = client.getUsers();
476489

@@ -545,7 +558,7 @@ describe("REST", function () {
545558
});
546559
});
547560

548-
describe("#addToWaitlist", function () {
561+
execTest()("#addToWaitlist", function () {
549562
it("should add a user by their ID to the waitlist", function (done) {
550563
client.addToWaitlist(_user.id, function (err) {
551564

@@ -559,13 +572,13 @@ describe("REST", function () {
559572
});
560573
});
561574

562-
describe("#meh", function () {
575+
execTest()("#meh", function () {
563576
it("should meh a song", function (done) {
564577
client.meh(done);
565578
});
566579
});
567580

568-
describe("#woot", function () {
581+
execTest()("#woot", function () {
569582
it("should woot a song", function (done) {
570583
client.woot(done);
571584
});
@@ -587,7 +600,7 @@ describe("REST", function () {
587600
});
588601
});
589602

590-
describe("#grab", function () {
603+
execTest()("#grab", function () {
591604
it("should grab a song", function (done) {
592605
client.grab(_playlist, done);
593606
});
@@ -616,13 +629,13 @@ describe("REST", function () {
616629
});
617630
});
618631

619-
describe("#skipDJ", function () {
632+
execTest()("#skipDJ", function () {
620633
it("should skip the current DJ", function (done) {
621634
client.skipDJ(testLogin.noParse ? client.getBooth().currentDJ : client.getCurrentDJ().id, done);
622635
});
623636
});
624637

625-
describe("#moveDJ", function () {
638+
execTest()("#moveDJ", function () {
626639
it("should move a DJ to a new position in the waitlist", function (done) {
627640
var waitlist = client.getWaitlist();
628641
client.moveDJ(waitlist[waitlist.length - 1], 0, done);
@@ -668,7 +681,7 @@ describe("REST", function () {
668681
});
669682
});
670683

671-
describe("#muteUser", function () {
684+
execTest()("#muteUser", function () {
672685
it("should mute a user", function (done) {
673686
client.muteUser(_user.id, client.MUTEDURATION.SHORT, client.BANREASON.VIOLATING_COMMUNITY_RULES, function (err) {
674687

@@ -710,13 +723,13 @@ describe("REST", function () {
710723
});
711724
});
712725

713-
describe("#addStaff", function () {
726+
execTest()("#addStaff", function () {
714727
it("should add a user as staff", function (done) {
715728
client.addStaff(_user.id, client.USERROLE.BOUNCER, done);
716729
});
717730
});
718731

719-
describe("#ignoreUser", function () {
732+
execTest()("#ignoreUser", function () {
720733
it("should ignore a user", function (done) {
721734
client.ignoreUser(_user.id, done);
722735
});
@@ -744,7 +757,7 @@ describe("REST", function () {
744757
});
745758
});
746759

747-
describe("#removeIgnore", function () {
760+
execTest()("#removeIgnore", function () {
748761
it("should remove the previously ignored user", function (done) {
749762
client.removeIgnore(_user.id, function (err, ignore) {
750763
expect(err).to.be.a("null");
@@ -763,7 +776,7 @@ describe("REST", function () {
763776
});
764777
});
765778

766-
describe("#removeStaff", function () {
779+
execTest()("#removeStaff", function () {
767780
it("should remove the previously added staff member", function (done) {
768781
client.removeStaff(_user.id, function (err) {
769782

@@ -777,7 +790,7 @@ describe("REST", function () {
777790
});
778791
});
779792

780-
describe("#removeDJ", function () {
793+
execTest()("#removeDJ", function () {
781794
it("should remove a DJ from the waitlist", function (done) {
782795
var user = client.getWaitlist()[0];
783796
client.removeDJ(user, function (err) {
@@ -798,13 +811,13 @@ describe("REST", function () {
798811
});
799812
});
800813

801-
describe("#unmuteUser", function () {
814+
execTest()("#unmuteUser", function () {
802815
it("should unmute the previously muted user", function (done) {
803816
client.unmuteUser(_user.id, done);
804817
});
805818
});
806819

807-
describe("#banUser", function () {
820+
execTest()("#banUser", function () {
808821
it("should ban a user", function (done) {
809822
client.banUser(_user.id, client.BANDURATION.SHORT, client.BANREASON.VIOLATING_COMMUNITY_RULES, function (err) {
810823

@@ -818,7 +831,7 @@ describe("REST", function () {
818831
});
819832
});
820833

821-
describe("#unbanUser", function () {
834+
execTest()("#unbanUser", function () {
822835
it("should unban the previously banned user", function (done) {
823836
client.unbanUser(_user.id, done);
824837
});
@@ -1130,7 +1143,7 @@ describe("REST", function () {
11301143
});
11311144
});
11321145

1133-
describe("#addFriend", function () {
1146+
execTest()("#addFriend", function () {
11341147
it("should add a user as a friend", function (done) {
11351148
client.addFriend(_user.id, done);
11361149
});
@@ -1198,7 +1211,7 @@ describe("REST", function () {
11981211
});
11991212
});
12001213

1201-
describe("#removeFriend", function () {
1214+
execTest()("#removeFriend", function () {
12021215
it("should remove a user as a friend", function (done) {
12031216
client.removeFriend(_user.id, done);
12041217
});
@@ -1350,7 +1363,7 @@ describe("Local", function () {
13501363
});
13511364
});
13521365

1353-
describe("#getChatByUser", function () {
1366+
execTest()("#getChatByUser", function () {
13541367
it("should get the messages written by a user", function () {
13551368
_user = client.getUsers()[0];
13561369
var messages = client.getChatByUser(_user.username);
@@ -1382,7 +1395,7 @@ describe("Local", function () {
13821395
});
13831396
});
13841397

1385-
describe("#removeChatMessage", function () {
1398+
execTest()("#removeChatMessage", function () {
13861399
it("should remove a chat message", function () {
13871400
var chat = client.getChat();
13881401
var length = chat.length;
@@ -1394,7 +1407,7 @@ describe("Local", function () {
13941407
});
13951408
});
13961409

1397-
describe("#removeChatMessagesByUser", function () {
1410+
execTest()("#removeChatMessagesByUser", function () {
13981411
it("should delete all messages of a user", function () {
13991412
client.removeChatMessagesByUser(_user.username, true);
14001413
expect(client.getChatByUser(_user.username)).to.be.an("array").and.have.length(0);
@@ -1435,7 +1448,7 @@ describe("Local", function () {
14351448
});
14361449
});
14371450

1438-
describe("#clearUserFromLists", function () {
1451+
execTest()("#clearUserFromLists", function () {
14391452
it("should clear the user from the vote and grab list", function () {
14401453
client.clearUserFromLists(_user.id);
14411454
var done = true;
@@ -1466,19 +1479,19 @@ describe("Local", function () {
14661479
});
14671480
});
14681481

1469-
describe("#getUserByName", function () {
1482+
execTest()("#getUserByName", function () {
14701483
it("should get a user by name", function () {
14711484
testUser(client.getUserByName(_user.username));
14721485
});
14731486
});
14741487

1475-
describe("#getUserByID", function () {
1488+
execTest()("#getUserByID", function () {
14761489
it("should get a user by their ID", function () {
14771490
testUser(client.getUserByID(_user.id));
14781491
});
14791492
});
14801493

1481-
describe("#getUserRole", function () {
1494+
execTest()("#getUserRole", function () {
14821495
it("should get a user's role", function () {
14831496
expect(client.getUserRole(_user.id)).to.equal(_user.role);
14841497
});
@@ -1489,7 +1502,9 @@ describe("Local", function () {
14891502
var users = client.getUsers();
14901503

14911504
expect(users).to.be.an("array");
1492-
testUser(users[0]);
1505+
1506+
if(users.length > 0)
1507+
testUser(users[0]);
14931508
});
14941509
});
14951510

@@ -1516,13 +1531,13 @@ describe("Local", function () {
15161531
});
15171532
});
15181533

1519-
describe("#isFriend", function () {
1534+
execTest()("#isFriend", function () {
15201535
it("should indicate whether a user is a friend or not", function () {
15211536
expect(client.isFriend(_user.id)).to.be.a("boolean");
15221537
});
15231538
});
15241539

1525-
describe("#getCurrentDJ", function () {
1540+
execTest()("#getCurrentDJ", function () {
15261541
it("should get the current DJ playing", function () {
15271542
var dj = client.getCurrentDJ();
15281543

@@ -1531,7 +1546,7 @@ describe("Local", function () {
15311546
});
15321547
});
15331548

1534-
describe("#getCurrentMedia", function () {
1549+
execTest()("#getCurrentMedia", function () {
15351550
it("should return the current media object", function () {
15361551
testMedia(client.getCurrentMedia());
15371552
});
@@ -1618,7 +1633,7 @@ describe("Local", function () {
16181633
});
16191634
});
16201635

1621-
describe("#checkGlobalRole", function () {
1636+
execTest()("#checkGlobalRole", function () {
16221637
it("should give back the global role of a user", function () {
16231638
expect(client.checkGlobalRole(_user.gRole)).to.be.a("number");
16241639
});
@@ -1763,19 +1778,19 @@ describe("Local", function () {
17631778
});
17641779
});
17651780

1766-
describe("#cacheUser", function () {
1781+
execTest()("#cacheUser", function () {
17671782
it("should cache a user", function () {
17681783
expect(client.cacheUser(_user)).to.be.a("boolean").and.equal(true);
17691784
});
17701785
});
17711786

1772-
describe("#removeCachedUserByID", function () {
1787+
execTest()("#removeCachedUserByID", function () {
17731788
it("should remove a cached user by their ID", function () {
17741789
expect(client.removeCachedUserByID(_user.id)).to.be.a("boolean").and.equal(true);
17751790
});
17761791
});
17771792

1778-
describe("#removeCachedUserByName", function () {
1793+
execTest()("#removeCachedUserByName", function () {
17791794
it("should remove a cached user by their Name", function () {
17801795
client.cacheUser(_user);
17811796
expect(client.removeCachedUserByName(_user.username)).to.be.a("boolean").and.equal(true);

0 commit comments

Comments
 (0)