1 | var mocha = require('mocha');
|
2 | var assert = require('assert');
|
3 | var nconf = require('nconf');
|
4 | var testingKeys = nconf.env().file({
|
5 | file: __dirname + '/testing_keys.json'
|
6 | });
|
7 | var util = require('util');
|
8 | var merge = require('merge');
|
9 |
|
10 | var postmark = require('../lib/postmark/index.js');
|
11 |
|
12 | describe('general client functionality', function() {
|
13 |
|
14 | this.timeout(30000);
|
15 | var _client = null;
|
16 |
|
17 | beforeEach(function() {
|
18 | _client = new postmark.Client(testingKeys.get('WRITE_TEST_SERVER_TOKEN'));
|
19 | });
|
20 |
|
21 | it('properly handles "legacy" options', function() {
|
22 | var client = postmark(testingKeys.get('WRITE_TEST_SERVER_TOKEN'), {
|
23 | testOption: 'asdf',
|
24 | ssl: false
|
25 | });
|
26 |
|
27 | assert.notEqual(client, null);
|
28 | assert.equal(testingKeys.get('WRITE_TEST_SERVER_TOKEN'), client.options.apiKey);
|
29 | assert.equal(client.options.testOption, 'asdf');
|
30 | assert.equal(client.options.ssl, false, "ssl should have been set to 'false'");
|
31 | });
|
32 |
|
33 | it('constructor assigns options.', function() {
|
34 | assert.equal(_client.options.ssl, true, "ssl should default to 'true'");
|
35 | assert.equal(_client.options.apiKey, testingKeys.get('WRITE_TEST_SERVER_TOKEN'));
|
36 | });
|
37 | });
|
38 |
|
39 | describe('integration test assertion', function() {
|
40 | it('should fail if a non-200 response comes back.', function(done) {
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 | var client = postmark(testingKeys.get('READ_SELENIUM_TEST_SERVER_TOKEN'))
|
56 |
|
57 | client.getBounces({
|
58 | count: "invalid count"
|
59 | }, function(err, result) {
|
60 |
|
61 | assert.equal(null, result);
|
62 | assert.equal(err.status, 422);
|
63 | assert.equal(err.message, 'Parameter \'count\' should be integer value');
|
64 | done();
|
65 | });
|
66 | });
|
67 | }); |
\ | No newline at end of file |