|
| 1 | +require("events").EventEmitter.defaultMaxListeners = 15; |
| 2 | + |
1 | 3 | const tape = require("tape"),
|
2 | 4 | _test = require("tape-promise"),
|
3 | 5 | test = _test(tape), // decorate tape
|
4 | 6 | CodebirdM = require("./codebirdm");
|
5 | 7 |
|
6 | 8 | function getCB() {
|
7 |
| - var cb = new CodebirdM.default; |
| 9 | + var cb = new CodebirdM.default(); |
8 | 10 | cb.setConsumerKey("123", "456");
|
9 | 11 |
|
10 | 12 | return cb;
|
11 | 13 | }
|
12 | 14 |
|
13 |
| -test("Tests oauth_authenticate Promise", function (t) { |
| 15 | +test("Tests oauth_authenticate Promise", function(t) { |
14 | 16 | const cb = getCB();
|
15 | 17 | t.plan(1);
|
16 | 18 |
|
17 | 19 | cb.setToken("123", "456");
|
18 |
| - return cb.oauth_authenticate().then(function (a) { |
19 |
| - t.deepEqual( |
20 |
| - a, |
21 |
| - {reply: "https://api.twitter.com/oauth/authenticate?oauth_token=123"} |
22 |
| - ) |
| 20 | + return cb.oauth_authenticate().then(function(a) { |
| 21 | + t.deepEqual(a, { |
| 22 | + reply: "https://api.twitter.com/oauth/authenticate?oauth_token=123" |
| 23 | + }); |
23 | 24 | });
|
24 | 25 | });
|
25 | 26 |
|
26 |
| -test("Tests oauth_authenticate callback", function (t) { |
| 27 | +test("Tests oauth_authenticate callback", function(t) { |
27 | 28 | const cb = getCB();
|
28 | 29 | t.plan(4);
|
29 | 30 |
|
30 | 31 | cb.setToken("123", "456");
|
31 |
| - cb.oauth_authenticate({}, function (a) { |
32 |
| - t.equal( |
33 |
| - a, "https://api.twitter.com/oauth/authenticate?oauth_token=123" |
34 |
| - ) |
| 32 | + cb.oauth_authenticate({}, function(a) { |
| 33 | + t.equal(a, "https://api.twitter.com/oauth/authenticate?oauth_token=123"); |
35 | 34 | });
|
36 |
| - cb.oauth_authenticate({force_login: true}, function (a) { |
| 35 | + cb.oauth_authenticate({ force_login: true }, function(a) { |
37 | 36 | t.equal(
|
38 |
| - a, "https://api.twitter.com/oauth/authenticate?oauth_token=123&force_login=1" |
39 |
| - ) |
40 |
| - }); |
41 |
| - cb.oauth_authenticate({force_login: true, screen_name: "TwitterAPI"}, function (a) { |
42 |
| - t.equal( |
43 |
| - a, "https://api.twitter.com/oauth/authenticate?oauth_token=123&force_login=1&screen_name=TwitterAPI" |
44 |
| - ) |
| 37 | + a, |
| 38 | + "https://api.twitter.com/oauth/authenticate?oauth_token=123&force_login=1" |
| 39 | + ); |
45 | 40 | });
|
46 |
| - cb.oauth_authenticate({screen_name: "TwitterAPI"}, function (a) { |
| 41 | + cb.oauth_authenticate( |
| 42 | + { force_login: true, screen_name: "TwitterAPI" }, |
| 43 | + function(a) { |
| 44 | + t.equal( |
| 45 | + a, |
| 46 | + "https://api.twitter.com/oauth/authenticate?oauth_token=123&force_login=1&screen_name=TwitterAPI" |
| 47 | + ); |
| 48 | + } |
| 49 | + ); |
| 50 | + cb.oauth_authenticate({ screen_name: "TwitterAPI" }, function(a) { |
47 | 51 | t.equal(
|
48 |
| - a, "https://api.twitter.com/oauth/authenticate?oauth_token=123&screen_name=TwitterAPI" |
49 |
| - ) |
| 52 | + a, |
| 53 | + "https://api.twitter.com/oauth/authenticate?oauth_token=123&screen_name=TwitterAPI" |
| 54 | + ); |
50 | 55 | });
|
51 | 56 | });
|
52 | 57 |
|
53 |
| -test("Tests oauth_authorize callback", function (t) { |
| 58 | +test("Tests oauth_authorize callback", function(t) { |
54 | 59 | const cb = getCB();
|
55 | 60 | t.plan(4);
|
56 | 61 |
|
57 | 62 | cb.setToken("123", "456");
|
58 |
| - cb.oauth_authorize({}, function (a) { |
59 |
| - t.equal( |
60 |
| - a, "https://api.twitter.com/oauth/authorize?oauth_token=123" |
61 |
| - ) |
| 63 | + cb.oauth_authorize({}, function(a) { |
| 64 | + t.equal(a, "https://api.twitter.com/oauth/authorize?oauth_token=123"); |
62 | 65 | <
8000
div class="diff-text-inner"> }); |
63 |
| - cb.oauth_authorize({force_login: true}, function (a) { |
| 66 | + cb.oauth_authorize({ force_login: true }, function(a) { |
64 | 67 | t.equal(
|
65 |
| - a, "https://api.twitter.com/oauth/authorize?oauth_token=123&force_login=1" |
66 |
| - ) |
| 68 | + a, |
| 69 | + "https://api.twitter.com/oauth/authorize?oauth_token=123&force_login=1" |
| 70 | + ); |
67 | 71 | });
|
68 |
| - cb.oauth_authorize({force_login: true, screen_name: "TwitterAPI"}, function (a) { |
| 72 | + cb.oauth_authorize({ force_login: true, screen_name: "TwitterAPI" }, function( |
| 73 | + a |
| 74 | + ) { |
69 | 75 | t.equal(
|
70 |
| - a, "https://api.twitter.com/oauth/authorize?oauth_token=123&force_login=1&screen_name=TwitterAPI" |
71 |
| - ) |
| 76 | + a, |
| 77 | + "https://api.twitter.com/oauth/authorize?oauth_token=123&force_login=1&screen_name=TwitterAPI" |
| 78 | + ); |
72 | 79 | });
|
73 |
| - cb.oauth_authorize({screen_name: "TwitterAPI"}, function (a) { |
| 80 | + cb.oauth_authorize({ screen_name: "TwitterAPI" }, function(a) { |
74 | 81 | t.equal(
|
75 |
| - a, "https://api.twitter.com/oauth/authorize?oauth_token=123&screen_name=TwitterAPI" |
76 |
| - ) |
| 82 | + a, |
| 83 | + "https://api.twitter.com/oauth/authorize?oauth_token=123&screen_name=TwitterAPI" |
| 84 | + ); |
77 | 85 | });
|
78 | 86 | });
|
79 | 87 |
|
80 |
| -test("Tests oauth2_token", function (t) { |
| 88 | +test("Tests oauth2_token", function(t) { |
81 | 89 | const cb = getCB();
|
82 | 90 | t.plan(1);
|
83 | 91 |
|
84 |
| - cb.oauth2_token( |
85 |
| - function (a) { |
86 |
| - t.deepEqual( |
87 |
| - a, { |
88 |
| - token_type: "bearer", |
89 |
| - access_token: "VqiO0n2HrKE", |
90 |
| - httpstatus: 200 |
91 |
| - } |
92 |
| - ); |
| 92 | + cb.oauth2_token(function(a) { |
| 93 | + t.deepEqual(a, { |
| 94 | + token_type: "bearer", |
| 95 | + access_token: "VqiO0n2HrKE", |
| 96 | + httpstatus: 200 |
93 | 97 | });
|
| 98 | + }); |
94 | 99 | });
|
95 | 100 |
|
96 |
| -test("Tests signing of boolean parameters", function (t) { |
| 101 | +test("Tests signing of boolean parameters", function(t) { |
97 | 102 | const cb = getCB();
|
98 | 103 |
|
99 | 104 | t.equal(
|
|
0 commit comments