Skip to content

Commit

Permalink
make e2e test work
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyguerra committed Oct 20, 2023
1 parent 36073f5 commit ee7a6f8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 30 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"pretest": "standard",
"test": "node --test test/redis-brain-test.js",
"test:watch": "node --watch --test",
"e2e": "node --test test/e2e"
"e2e": "node --test test/e2e/*"
},
"peerDependencies": {
"hubot": ">= 9.x.x"
Expand Down
40 changes: 11 additions & 29 deletions test/e2e/connect.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,21 @@
'use strict'

/* global describe, it */
/* eslint-disable no-unused-expressions */
const shell = require('hubot/src/adapters/shell')
const Adapter = require('hubot/src/adapter')

const { describe, it } = require('node:test')
const assert = require('node:assert/strict')
const path = require('path')

const chai = require('chai')
const sinon = require('sinon')
const Hubot = require('hubot')

const expect = chai.expect
const Robot = Hubot.Robot

chai.use(require('sinon-chai'))

const Robot = require('hubot/src/robot.js')
describe('e2e', () => {
it('connects to redis', done => {
shell.use = robot => {
return new Adapter()
}

const robot = new Robot(null, 'shell', false, 'hubot')
sinon.spy(robot.logger, 'debug')
it('connects to redis', async () => {
const robot = new Robot('shell', false, 'hubot')
await robot.loadAdapter()
robot.brain.on('loaded', actual => {
const expected = { users: {}, _private: {} }
expect(actual).to.deep.equal(expected)
assert.deepEqual(actual, expected)
})
robot.brain.on('connected', () => {
expect(robot.logger.debug).to.have.been.calledWith('hubot-redis-brain: Successfully connected to Redis')
robot.shutdown()
done()
assert.ok(true)
})
robot.loadFile(path.resolve('src/'), 'redis-brain.js')
robot.run()
await robot.loadFile(path.resolve('src/'), 'redis-brain.js')
await robot.run()
robot.shutdown()
})
})

0 comments on commit ee7a6f8

Please sign in to comment.