Permalink
Browse files

Unit testing for receiveOptoutPost

  • Loading branch information...
1 parent 9e64d3c commit 026d4a0fb21305944e5e04badd4153a736b59880 @TauZero TauZero committed Feb 21, 2012
Showing with 53 additions and 0 deletions.
  1. +53 −0 test/test_sailthru.coffee
@@ -0,0 +1,53 @@
+SailthruClient = require('../lib/sailthru').createSailthruClient('abcd12345','1324qwerty')
+{testCase} = require 'nodeunit'
+
+exports.receiveOptoutPost = (test) ->
+ test.expect 6
+
+ # Valid params
+ params1 =
+ action: 'optout'
+ email: 'foo@bar.com'
+ sig: '89b9fce5296ce2920dad46ed3467001d'
+ real1 = SailthruClient.receiveOptoutPost params1
+ test.ok real1
+
+ # Missing sig
+ params2 =
+ action: 'optout'
+ email: 'foo@bar.com'
+ real2 = SailthruClient.receiveOptoutPost params2
+ test.ok not real2
+
+ # Missing email
+ params3 =
+ action: 'optout'
+ sig: '9577f7aae68bc22b4e4d0709b1f2afa8'
+ real3 = SailthruClient.receiveOptoutPost params3
+ test.ok not real3
+
+ # Missing action
+ params4 =
+ email: 'foo@bar.com'
+ sig: '37b11fcea15a1ff5e21b7c8467e93015'
+ real4 = SailthruClient.receiveOptoutPost params4
+ test.ok not real4
+
+ # Non 'optout' action
+ params5 =
+ action: 'baz'
+ email: 'foo@bar.com'
+ sig: '28916f39794b7d8e6c927a1e94d99f93'
+ real5 = SailthruClient.receiveOptoutPost params5
+ test.ok not real5
+
+ # Wrong signature
+ params6 =
+ action: 'optout'
+ email: 'foo@bar.com'
+ sig: '110993c3e8786cb4ebdd509ea6115fea'
+ real6 = SailthruClient.receiveOptoutPost params6
+ test.ok not real5
+
+ test.done()
+

0 comments on commit 026d4a0

Please sign in to comment.