Skip to content

Commit 2da30c1

Browse files
committed
Additional tests for teamFees / paymentNotes
1 parent 353d40e commit 2da30c1

File tree

3 files changed

+101
-5
lines changed

3 files changed

+101
-5
lines changed

lib/test/js/test.js

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5769,6 +5769,51 @@ describe('Opponents', function() {
57695769

57705770
require.register("test/paymentNotes", function(exports, require, module) {
57715771
describe('Payment Notes', function() {
5772+
var member, memberPayment, paymentNote, teamFee;
5773+
teamFee = null;
5774+
member = null;
5775+
memberPayment = null;
5776+
paymentNote = null;
5777+
before(function(done) {
5778+
teamFee = teamsnap.createTeamFee();
5779+
teamFee.teamId = team.id;
5780+
teamFee.description = 'Test Team Fee';
5781+
teamFee.amount = 1;
5782+
return teamsnap.saveTeamFee(teamFee, function(err, result) {
5783+
expect(err).to.be["null"];
5784+
return done();
5785+
});
5786+
});
5787+
before(function(done) {
5788+
member = teamsnap.createMember();
5789+
member.teamId = team.id;
5790+
member.firstName = 'Test';
5791+
return teamsnap.saveMember(member, function(err, result) {
5792+
expect(err).to.be["null"];
5793+
return done();
5794+
});
5795+
});
5796+
before(function(done) {
5797+
return teamsnap.loadMemberPayments({
5798+
memberId: member.id,
5799+
teamFeeId: teamFee.id
5800+
}).then(function(memberPayments) {
5801+
memberPayment = memberPayments[0];
5802+
return done();
5803+
});
5804+
});
5805+
after(function(done) {
5806+
return teamsnap.deleteMember(member, function(err, result) {
5807+
expect(err).to.be["null"];
5808+
return done();
5809+
});
5810+
});
5811+
after(function(done) {
5812+
return teamsnap.deleteTeamFee(teamFee, function(err, result) {
5813+
expect(err).to.be["null"];
5814+
return done();
5815+
});
5816+
});
57725817
it('should be able to load all payment notes for a team', function(done) {
57735818
return teamsnap.loadPaymentNotes(team.id, function(err, result) {
57745819
expect(err).to.be["null"];
@@ -5777,10 +5822,9 @@ describe('Payment Notes', function() {
57775822
});
57785823
});
57795824
return it('should be able to create a payment note', function(done) {
5780-
var paymentNote;
57815825
paymentNote = teamsnap.createPaymentNote();
57825826
paymentNote.teamId = team.id;
5783-
paymentNote.memberPaymentId = 1;
5827+
paymentNote.memberPaymentId = memberPayment.id;
57845828
paymentNote.note = 'Test payment note.';
57855829
paymentNote.description = 'Payment Note Description';
57865830
return teamsnap.savePaymentNote(paymentNote, function(err, result) {
@@ -5869,15 +5913,16 @@ describe('Sports', function() {
58695913

58705914
require.register("test/teamFees", function(exports, require, module) {
58715915
describe('Team Fees', function() {
5916+
var teamFee;
5917+
teamFee = null;
58725918
it('should be able to load all team fees', function(done) {
58735919
return teamsnap.loadTeamFees(team.id, function(err, result) {
58745920
expect(err).to.be["null"];
58755921
result.should.be.an('array');
58765922
return done();
58775923
});
58785924
});
5879-
return it('should be able to create a team fee', function(done) {
5880-
var teamFee;
5925+
it('should be able to create a team fee', function(done) {
58815926
teamFee = teamsnap.createTeamFee();
58825927
teamFee.teamId = team.id;
58835928
teamFee.description = 'Test Team Fee';
@@ -5888,6 +5933,12 @@ describe('Team Fees', function() {
58885933
return done();
58895934
});
58905935
});
5936+
return it('should be able to delete a team fee', function(done) {
5937+
return teamsnap.deleteTeamFee(teamFee, function(err, result) {
5938+
expect(err).to.be["null"];
5939+
return done();
5940+
});
5941+
});
58915942
});
58925943

58935944
});

test/paymentNotes.coffee

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,43 @@
11
describe 'Payment Notes', ->
22

3+
teamFee = null
4+
member = null
5+
memberPayment = null
6+
paymentNote = null
7+
8+
before (done) ->
9+
teamFee = teamsnap.createTeamFee()
10+
teamFee.teamId = team.id
11+
teamFee.description = 'Test Team Fee'
12+
teamFee.amount = 1
13+
teamsnap.saveTeamFee teamFee, (err, result) ->
14+
expect(err).to.be.null
15+
done()
16+
17+
before (done) ->
18+
member = teamsnap.createMember()
19+
member.teamId = team.id
20+
member.firstName = 'Test'
21+
teamsnap.saveMember member, (err, result) ->
22+
expect(err).to.be.null
23+
done()
24+
25+
before (done) ->
26+
teamsnap.loadMemberPayments(
27+
{memberId: member.id, teamFeeId: teamFee.id}).then (memberPayments) ->
28+
memberPayment = memberPayments[0]
29+
done()
30+
31+
after (done) ->
32+
teamsnap.deleteMember member, (err, result) ->
33+
expect(err).to.be.null
34+
done()
35+
36+
after (done) ->
37+
teamsnap.deleteTeamFee teamFee, (err, result) ->
38+
expect(err).to.be.null
39+
done()
40+
341
it 'should be able to load all payment notes for a team', (done) ->
442
teamsnap.loadPaymentNotes team.id, (err, result) ->
543
expect(err).to.be.null
@@ -9,7 +47,7 @@ describe 'Payment Notes', ->
947
it 'should be able to create a payment note', (done) ->
1048
paymentNote = teamsnap.createPaymentNote()
1149
paymentNote.teamId = team.id
12-
paymentNote.memberPaymentId = 1
50+
paymentNote.memberPaymentId = memberPayment.id
1351
paymentNote.note = 'Test payment note.'
1452
paymentNote.description = 'Payment Note Description'
1553
teamsnap.savePaymentNote paymentNote, (err, result) ->

test/teamFees.coffee

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
describe 'Team Fees', ->
22

3+
teamFee = null
4+
35
it 'should be able to load all team fees', (done) ->
46
teamsnap.loadTeamFees team.id, (err, result) ->
57
expect(err).to.be.null
@@ -14,4 +16,9 @@ describe 'Team Fees', ->
1416
teamsnap.saveTeamFee teamFee, (err, result) ->
1517
expect(err).to.be.null
1618
result.should.have.property('type', 'teamFee')
19+
done()
20+
21+
it 'should be able to delete a team fee', (done) ->
22+
teamsnap.deleteTeamFee teamFee, (err, result) ->
23+
expect(err).to.be.null
1724
done()

0 commit comments

Comments
 (0)