Skip to content

Commit

Permalink
chore(test): Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
lgaticaq committed Jun 17, 2016
1 parent 375c4b1 commit fe595a1
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
19 changes: 19 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
"version": "1.1.5",
"description": "A Hubot script to close time entries for new payment",
"main": "src",
"scripts": {
"pretest": "coffeelint src test",
"test": "mocha --compilers coffee:coffee-script/register --require coffee-coverage/register-istanbul",
"posttest": "istanbul report text-summary lcov",
"coveralls": "coveralls < coverage/lcov.info",
"codeclimate": "codeclimate-test-reporter < coverage/lcov.info"
},
"engines": {
"node": ">=4"
},
Expand All @@ -27,5 +34,17 @@
"request-promise": "^3.0.0",
"simple-encryptor": "^1.1.0",
"toggl-api": "^1.0.0"
},
"devDependencies": {
"chai": "^3.5.0",
"codeclimate-test-reporter": "^0.3.3",
"coffee-coverage": "^1.0.1",
"coffee-script": "^1.10.0",
"coffeelint": "^1.15.7",
"coveralls": "^2.11.9",
"hubot-test-helper": "^1.4.4",
"istanbul": "^0.4.3",
"mocha": "^2.5.3",
"proxyquire": "^1.7.9"
}
}
60 changes: 60 additions & 0 deletions test/test.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
Helper = require("hubot-test-helper")
expect = require("chai").expect
proxyquire = require("proxyquire")

apiToken = "DK89YJJRktQ2X0B3i1o7N96Z75pWL2MR"
password = "19QBn1kzsKyuC9IKHz9byjCL8222wuop"

togglStub = () ->
getUserDataAsync: () ->
return new Promise (resolve) ->
resolve({
api_token: apiToken,
fullname: "Testing User"
})
getTimeEntriesAsync: () ->
return new Promise (resolve) ->
resolve([
{
id: 1,
duration: 100,
description: "Testing"
},
{
id: 2,
duration: 100,
description: "Testing"
},
{
id: 3,
tags: "Pagado",
duration: 100,
description: "Testing"
},
])
updateTimeEntriesTagsAsync: () ->
return new Promise (resolve) ->
resolve()
proxyquire("./../src/script.coffee", {"toggl-api": togglStub})

helper = new Helper("./../src/index.coffee")

describe "hubot-toggl-payment", ->
room = null

beforeEach ->
room = helper.createRoom({name: "user"})

afterEach ->
room.destroy()

context "get w3w from address", ->
beforeEach (done) ->
room.user.say("user", "hubot toggl login #{apiToken} #{password}")
setTimeout(done, 100)

it "should get a w3w", ->
expect(room.messages).to.eql([
["user", "hubot toggl login #{apiToken} #{password}"]
["hubot", "Login success as Testing User"]
])

0 comments on commit fe595a1

Please sign in to comment.