UNPKG

dadjokes-wrapper

Version:
75 lines (69 loc) 2.66 kB
/* eslint-disable */ const { expect } = require('chai'); const DadJokes = require('../index'); describe('DadJokes API', function () { describe('randomJoke()', function () { it('should give a random joke without any errors', function () { const dadjokes = new DadJokes(); dadjokes.randomJoke().then(res => { expect(res).to.be.an('object') expect(res.id).to.be.a('string') expect(res.joke).to.be.a('string') expect(res.status).to.equal(200) }).catch(e => e); }); }); describe('randomSlackJoke()', function () { it('should give a random joke without any errors', function () { const dadjokes = new DadJokes(); dadjokes.randomSlackJoke().then(res => { expect(res).to.be.an('object') expect(res.attachments).to.be.an('array') expect(res.response_type).to.be.a('string') expect(res.username).to.be.a('string') expect(res.attachments.fallback).to.be.a('string') expect(res.attachments.footer).to.be.a('string') expect(res.attachments.text).to.be.a('string') }).catch(e => e); }); }); describe('jokeById()', function () { it('should give a joke by ID without any errors', function () { const dadjokes = new DadJokes(); dadjokes.jokeById('R7UfaahVfFd').then(res => { expect(res).to.be.an('object') expect(res.id).to.be.a('string') expect(res.joke).to.be.a('string') expect(res.status).to.equal(200) }).catch(e => e); }); }); describe('jokeImgById()', function () { it('should return an image of the joke without any errors', function () { const dadjokes = new DadJokes(); dadjokes.jokeImgById('gNu41gNeqjb').then(res => { expect(res).to.be.a('stream') expect(res.id).to.be.a('string') expect(res.joke).to.be.a('string') expect(res.status).to.equal(200) }).catch(e => e); }); }); describe('searchJoke()', function () { it('should return the result of the search without any errors', function () { const dadjokes = new DadJokes(); dadjokes.searchJoke().then(res => { expect(res).to.be.an('object') expect(res.current_page).to.be.a('number') expect(res.limit).to.be.a('number') expect(res.next_page).to.be.a('number') expect(res.previous_page).to.be.a('number') expect(res.results).to.be.an('array') expect(res.search_term).to.be.a('string') expect(res.status).to.equal(200) expect(res.total_jokes).to.be.a('number') expect(res.total_pages).to.be.a('number') }).catch(e => e); }); }); });