From e293bb2000277ef006bbabea18d18727a98ceb4e Mon Sep 17 00:00:00 2001 From: Enrico Fasoli Date: Sat, 26 Sep 2015 18:16:17 +0200 Subject: [PATCH] dimenticato un file --- test/memes-test.coffee | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 test/memes-test.coffee diff --git a/test/memes-test.coffee b/test/memes-test.coffee new file mode 100644 index 0000000..29e924d --- /dev/null +++ b/test/memes-test.coffee @@ -0,0 +1,38 @@ +nock = require 'nock' +expect = require("chai").should() + +Asjon = require '../asjon-testing.coffee' +asjon = undefined + +describe 'modulo memes', -> + before (done) -> + # Inizializzo robot + Asjon (assa) -> + asjon = assa + after asjon.after + afterEach asjon.clear + require('../scripts/memes.coffee')(asjon.robot) + done() + + it "dovrebbe generare correttamente l'url dell'immagine", (done) -> + questions = [ + "asjon meme fry, not sure if this works, or not" + ] + acc = 0 + asjon.receive (e,l) -> + l.join().should.equal 'http://memegen.link/fry/not_sure_if_this_works/or_not.jpg' + acc++ + if acc is questions.length then done() + questions.map (q) -> asjon.send q + + it 'dovrebbe rispondere correttamente quando la domanda รจ malformata', (done) -> + questions = [ + "asjon meme a, b, c, d,e" + "asjon meme ciao" + ] + acc = 0 + asjon.receive (e,l) -> + l.join().should.match /^richiesta malformata/g + acc++ + if acc is questions.length then done() + questions.map (q) -> asjon.send q