forked from hubotio/hubot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgoogle_images_test.coffee
50 lines (43 loc) · 1.23 KB
/
google_images_test.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Tests = require './tests'
assert = require 'assert'
helper = Tests.helper()
Robot = require '../src/robot'
{TextMessage} = require '../src/message'
require('../src/scripts/google-images') helper
# start up a danger room for google images
danger = Tests.danger helper, (req, res, url) ->
res.writeHead 200
res.end JSON.stringify(
responseData:
results: [
unescapedUrl: "(#{url.query.q})"
]
)
# callbacks for when hubot sends messages
mu = "http://mustachify.me/?src="
tests = [
(msg) -> assert.equal "#{mu}(foo)#.png", msg
(msg) -> assert.equal "#{mu}(foo)#.png", msg
(msg) -> assert.equal "#{mu}(foo)#.png", msg
(msg) -> assert.equal "#{mu}(foo)#.png", msg
(msg) -> assert.equal "(foo)#.png", msg
(msg) -> assert.equal "(foo)#.png", msg
(msg) -> assert.equal "(foo)#.png", msg
(msg) -> assert.equal "(animated foo)#.png", msg
]
# run the async tests
messages = [
'helper: stache me foo',
'helper: stache foo',
'helper: mustache me foo',
'helper: mustache foo',
'helper: img foo',
'helper: image me foo',
'helper: image foo',
'helper: animate me foo'
]
user = {}
danger.start tests, ->
for message in messages
helper.receive new TextMessage user, message
helper.stop()