This repository has been archived by the owner on May 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed help texts for !help fun (!animals and !translate) Renamed test - images.js to animals.js
- Loading branch information
Gravestorm
committed
Mar 24, 2016
1 parent
0fabfee
commit 00b7ccc
Showing
4 changed files
with
194 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
import chai from 'chai'; | ||
import nock from 'nock'; | ||
import path from 'path'; | ||
|
||
import images from '../../src/commands/fun/animals'; | ||
|
||
|
||
chai.should(); | ||
const res_fixture_cat = require(path.join(__dirname, '../fixtures/cat.json')); | ||
const res_fixture_pug = require(path.join(__dirname, '../fixtures/pug.json')); | ||
const res_fixture_snake = require(path.join(__dirname, '../fixtures/snake.json')); | ||
const res_fixture_pugbomb = require(path.join(__dirname, '../fixtures/pugbomb.json')); | ||
|
||
describe('images', () => { | ||
describe('cat', () => { | ||
it('should return cat images', done => { | ||
function sendMessage(channel, res) { | ||
channel.should.equal('test'); | ||
res.should.equal('http://random.cat/i/7VnxKqw.jpg'); | ||
done(); | ||
} | ||
|
||
nock.cleanAll(); | ||
nock('http://random.cat') | ||
.get('/meow.php') | ||
.reply(200, res_fixture_cat); | ||
|
||
images.cat({sendMessage}, {channel: 'test'}); | ||
}); | ||
|
||
it('should return 5 cat images', done => { | ||
function sendMessage(channel, res) { | ||
channel.should.equal('test'); | ||
res.should.equal(`http://random.cat/i/7VnxKqw.jpg | ||
http://random.cat/i/7VnxKqw.jpg | ||
http://random.cat/i/7VnxKqw.jpg | ||
http://random.cat/i/7VnxKqw.jpg | ||
http://random.cat/i/7VnxKqw.jpg`); | ||
done(); | ||
} | ||
|
||
nock.cleanAll(); | ||
nock('http://random.cat') | ||
.get('/meow.php') | ||
.times(5) | ||
.reply(200, res_fixture_cat); | ||
|
||
images.cat({sendMessage}, {channel: 'test'}, 'bomb 5'); | ||
}); | ||
}); | ||
|
||
describe('pug', () => { | ||
it('should return pug images', done => { | ||
function sendMessage(channel, res) { | ||
channel.should.equal('test'); | ||
res.should.equal(`http://30.media.tumblr.com/tumblr_lj50gs8rAX1qaa50yo1_500.jpg`); | ||
done(); | ||
} | ||
|
||
nock.cleanAll(); | ||
nock('https://pugme.herokuapp.com') | ||
.get('/bomb?count=1') | ||
.reply(200, res_fixture_pug); | ||
|
||
images.pug({sendMessage}, {channel: 'test'}); | ||
}); | ||
|
||
it('should return 5 pug images', done => { | ||
function sendMessage(channel, res) { | ||
channel.should.equal('test'); | ||
res.should.equal(`http://30.media.tumblr.com/tumblr_lj50gs8rAX1qaa50yo1_500.jpg | ||
http://30.media.tumblr.com/tumblr_lj50gs8rAX1qaa50yo1_500.jpg | ||
http://30.media.tumblr.com/tumblr_lj50gs8rAX1qaa50yo1_500.jpg | ||
http://30.media.tumblr.com/tumblr_lj50gs8rAX1qaa50yo1_500.jpg | ||
http://30.media.tumblr.com/tumblr_lj50gs8rAX1qaa50yo1_500.jpg`); | ||
done(); | ||
} | ||
|
||
nock.cleanAll(); | ||
nock('https://pugme.herokuapp.com') | ||
.get('/bomb?count=5') | ||
.reply(200, res_fixture_pugbomb); | ||
|
||
images.pug({sendMessage}, {channel: 'test'}, 'bomb 5'); | ||
}); | ||
}); | ||
|
||
describe('snake', () => { | ||
it('should return snake images', done => { | ||
function sendMessage(channel, res) { | ||
channel.should.equal('test'); | ||
res.should.equal('http://fur.im/snek/61.png'); | ||
done(); | ||
} | ||
|
||
nock.cleanAll(); | ||
nock('http://fur.im/snek') | ||
.get('/snek.php') | ||
.reply(200, res_fixture_snake); | ||
|
||
images.snake({sendMessage}, {channel: 'test'}); | ||
}); | ||
|
||
it('should return 5 snake images', done => { | ||
function sendMessage(channel, res) { | ||
channel.should.equal('test'); | ||
res.should.equal(`http://fur.im/snek/61.png | ||
http://fur.im/snek/61.png | ||
http://fur.im/snek/61.png | ||
http://fur.im/snek/61.png | ||
http://fur.im/snek/61.png`); | ||
done(); | ||
} | ||
|
||
nock.cleanAll(); | ||
nock('http://fur.im/snek') | ||
.get('/snek.php') | ||
.times(5) | ||
.reply(200, res_fixture_snake); | ||
|
||
images.snake({sendMessage}, {channel: 'test'}, 'bomb 5'); | ||
}); | ||
}); | ||
}); |