Files
shields/services/reddit/subreddit-subscribers.tester.js
Joe Izzard 36e1d30631 [Reddit] New badge and additional testing (#5166)
* fix: added detection of private subs and aded a test

* test: added test for no subscriber info

* feat: added user-karma badge

* refactor: changed class name for testing

Changed the class name to allow testing the whole service with 'reddit'

* refactor: refactored code for code and output style

* refactor: change how variables are passed to be cleaner

Co-authored-by: Caleb Cartwright <calebcartwright@users.noreply.github.com>
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2020-06-09 02:15:07 +00:00

45 lines
1.1 KiB
JavaScript

'use strict'
const { isMetric } = require('../test-validators')
const t = (module.exports = require('../tester').createServiceTester())
t.create('subreddit-subscribers (valid subreddit)')
.get('/drums.json')
.expectBadge({
label: 'follow r/drums',
message: isMetric,
})
t.create('subreddit-subscribers (invalid subreddit)')
.get('/badfbasdfadfadfadfadfasdf.json')
.expectBadge({
label: 'reddit',
message: 'subreddit not found',
})
t.create('subreddit-subscribers (not existing subreddit)')
.get('/not-a-real-rubreddit.json')
.expectBadge({
label: 'reddit',
message: 'subreddit not found',
})
t.create('subreddit-subscribers (private sub)')
.get('/centuryclub.json')
.expectBadge({
label: 'reddit',
message: 'subreddit is private',
})
t.create('subreddit-subscribers (private sub)')
.get('/centuryclub.json')
.intercept(nock =>
nock('https://www.reddit.com/r')
.get('/centuryclub/about.json')
.reply(200, { kind: 't5', data: {} })
)
.expectBadge({
label: 'reddit',
message: 'subreddit not found',
})