Permalink
Browse files

Expand test coverage.

  • Loading branch information...
1 parent 443f5e6 commit 9f9254c6d7d77df4b846ca5ad95a96fcaf5ee25b @jaredhanson committed Jan 29, 2016
Showing with 149 additions and 2 deletions.
  1. +128 −0 test/fixtures/users/rsarver-without-id_str.json
  2. +19 −0 test/profile.test.js
  3. +2 −2 test/strategy.test.js
@@ -0,0 +1,128 @@
+{
+ "profile_sidebar_fill_color": "F8FCF2",
+ "profile_sidebar_border_color": "547980",
+ "profile_background_tile": true,
+ "name": "Ryan Sarver",
+ "profile_image_url": "http://a0.twimg.com/profile_images/1777569006/image1327396628_normal.png",
+ "created_at": "Mon Feb 26 18:05:55 +0000 2007",
+ "location": "San Francisco, CA",
+ "follow_request_sent": false,
+ "profile_link_color": "547980",
+ "is_translator": false,
+ "default_profile": false,
+ "contributors_enabled": true,
+ "favourites_count": 3162,
+ "url": null,
+ "profile_image_url_https": "https://si0.twimg.com/profile_images/1777569006/image1327396628_normal.png",
+ "utc_offset": -28800,
+ "id": 795649,
+ "profile_use_background_image": true,
+ "listed_count": 1586,
+ "profile_text_color": "594F4F",
+ "lang": "en",
+ "followers_count": 276334,
+ "protected": false,
+ "notifications": true,
+ "profile_background_image_url_https": "https://si0.twimg.com/profile_background_images/113854313/xa60e82408188860c483d73444d53e21.png",
+ "profile_background_color": "45ADA8",
+ "verified": false,
+ "geo_enabled": true,
+ "time_zone": "Pacific Time (US & Canada)",
+ "description": "Director, Platform at Twitter. Detroit and Boston export. Foodie and over-the-hill hockey player. @devon's lesser half",
+ "default_profile_image": false,
+ "profile_background_image_url": "http://a0.twimg.com/profile_background_images/113854313/xa60e82408188860c483d73444d53e21.png",
+ "status": {
+ "coordinates": null,
+ "favorited": false,
+ "truncated": false,
+ "created_at": "Sat Aug 25 19:33:11 +0000 2012",
+ "retweeted_status": {
+ "coordinates": null,
+ "favorited": false,
+ "truncated": false,
+ "created_at": "Sat Aug 25 19:20:36 +0000 2012",
+ "id_str": "239442171466493953",
+ "entities": {
+ "urls": [
+ {
+ "expanded_url": "http://nbcnews.to/NtkRTJ",
+ "url": "http://t.co/f8ivBrVd",
+ "indices": [
+ 102,
+ 122
+ ],
+ "display_url": "nbcnews.to/NtkRTJ"
+ }
+ ],
+ "hashtags": [
+
+ ],
+ "user_mentions": [
+
+ ]
+ },
+ "in_reply_to_user_id_str": null,
+ "contributors": null,
+ "text": "Neil Armstrong has died at the age of 82 from complications from heart operations he had 3 weeks ago. http://t.co/f8ivBrVd",
+ "retweet_count": 112,
+ "in_reply_to_status_id_str": null,
+ "id": 239442171466493953,
+ "geo": null,
+ "retweeted": false,
+ "possibly_sensitive": false,
+ "in_reply_to_user_id": null,
+ "place": null,
+ "in_reply_to_screen_name": null,
+ "source": "web",
+ "in_reply_to_status_id": null
+ },
+ "id_str": "239445335481647105",
+ "entities": {
+ "urls": [
+ {
+ "expanded_url": "http://nbcnews.to/NtkRTJ",
+ "url": "http://t.co/f8ivBrVd",
+ "indices": [
+ 115,
+ 135
+ ],
+ "display_url": "nbcnews.to/NtkRTJ"
+ }
+ ],
+ "hashtags": [
+
+ ],
+ "user_mentions": [
+ {
+ "name": "NBC News",
+ "id_str": "14173315",
+ "id": 14173315,
+ "indices": [
+ 3,
+ 11
+ ],
+ "screen_name": "NBCNews"
+ }
+ ]
+ },
+ "in_reply_to_user_id_str": null,
+ "contributors": null,
+ "text": "RT @NBCNews: Neil Armstrong has died at the age of 82 from complications from heart operations he had 3 weeks ago. http://t.co/f8ivBrVd",
+ "retweet_count": 112,
+ "in_reply_to_status_id_str": null,
+ "id": 239445335481647105,
+ "geo": null,
+ "retweeted": false,
+ "possibly_sensitive": false,
+ "in_reply_to_user_id": null,
+ "place": null,
+ "in_reply_to_screen_name": null,
+ "source": "<a href=\"http://twitter.com\" rel=\"nofollow\">Twitter for iPhone</a>",
+ "in_reply_to_status_id": null
+ },
+ "statuses_count": 13728,
+ "friends_count": 1780,
+ "following": true,
+ "show_all_inline_media": true,
+ "screen_name": "rsarver"
+}
View
@@ -64,4 +64,23 @@ describe('Profile.parse', function() {
});
});
+ describe('profile obtained from unknown source on unknown date, without id_str attribute', function() {
+ var profile;
+
+ before(function(done) {
+ fs.readFile('test/fixtures/users/rsarver-without-id_str.json', 'utf8', function(err, data) {
+ if (err) { return done(err); }
+ profile = Profile.parse(data);
+ done();
+ });
+ });
+
+ it('should parse profile', function() {
+ expect(profile.id).to.equal('795649');
+ expect(profile.username).to.equal('rsarver');
+ expect(profile.displayName).to.equal('Ryan Sarver');
+ expect(profile.photos[0].value).to.equal('https://si0.twimg.com/profile_images/1777569006/image1327396628_normal.png');
+ });
+ });
+
});
@@ -15,10 +15,10 @@ describe('Strategy', function() {
});
})
- describe('constructed without required options', function() {
+ describe('constructed with undefined options', function() {
it('should throw', function() {
expect(function() {
- var strategy = new TwitterStrategy(function(){});
+ var strategy = new TwitterStrategy(undefined, function(){});
}).to.throw(Error);
});
})

0 comments on commit 9f9254c

Please sign in to comment.