Skip to content

Commit b9b5b83

Browse files
committed
Allow tests to pass if a callback gets called twice. This is a common occurence.
1 parent 51167ce commit b9b5b83

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,16 @@ describe('CSGO', () => {
107107
});
108108
});
109109

110+
var mmStatsChecked = false;
110111
describe('#mmstats', () => {
111112
before(beConnectedToGC);
112113

113114
it('should request and receive matchmaking stats', (done) => {
114115
CSGOCli.matchmakingStatsRequest();
115116
CSGOCli.on('matchmakingStatsData', (data) => {
117+
if (mmStatsChecked) return;
118+
mmStatsChecked = true;
119+
116120
should.exist(data.global_stats);
117121
done();
118122
});
@@ -122,18 +126,26 @@ describe('CSGO', () => {
122126
describe('#profile', () => {
123127
before(beConnectedToGC);
124128

129+
var profileStatsChecked = false;
125130
it('should request and receive profile stats', (done) => {
126131
CSGOCli.playerProfileRequest(CSGOCli.ToAccountID(steamClient.steamID));
127132
CSGOCli.on('playerProfile', function(profile) {
133+
if (profileStatsChecked) return;
134+
profileStatsChecked = true;
135+
128136
should.exist(profile.account_profiles[0]);
129137
should.equal(profile.account_profiles[0].account_id, CSGOCli.ToAccountID(steamClient.steamID));
130138
done();
131139
});
132140
});
133141

142+
var matchListChecked = false;
134143
it('should request recent games', (done) => {
135144
CSGOCli.requestRecentGames();
136145
CSGOCli.on('matchList', (list) => {
146+
if (matchListChecked) return;
147+
matchListChecked = true;
148+
137149
should.equal(list.accountid, CSGOCli.ToAccountID(steamClient.steamID));
138150
(list.matches).should.be.a.Array();
139151
done();

0 commit comments

Comments
 (0)