hubot-diagnostics
Advanced tools
Comparing version 1.2.1 to 2.0.0
{ | ||
"name": "hubot-diagnostics", | ||
"description": "hubot scripts for diagnosing hubot", | ||
"version": "1.2.1", | ||
"version": "2.0.0", | ||
"author": "Josh Nichols <technicalpickles@github.com>", | ||
@@ -19,3 +19,3 @@ "license": "MIT", | ||
"engines": { | ||
"node": "> 4.0.0" | ||
"node": "> 18.x" | ||
}, | ||
@@ -25,13 +25,9 @@ "main": "index.js", | ||
"pretest": "standard", | ||
"test": "mocha --exit" | ||
"test": "node --test" | ||
}, | ||
"dependencies": { | ||
"hubot": "^4.0.0" | ||
"peerDependencies": { | ||
"hubot": ">= 9" | ||
}, | ||
"devDependencies": { | ||
"chai": "^4.3.7", | ||
"mocha": "^10.2.0", | ||
"semantic-release": "^21.0.3", | ||
"sinon": "^15.1.0", | ||
"sinon-chai": "^3.7.0", | ||
"standard": "^17.1.0" | ||
@@ -38,0 +34,0 @@ }, |
'use strict' | ||
/* global describe, beforeEach, it, afterEach, context */ | ||
const { describe, it, beforeEach, afterEach } = require('node:test') | ||
const path = require('path') | ||
const chai = require('chai') | ||
const { hook, reset } = require('./fixtures/RequireMocker.js') | ||
const assert = require('assert') | ||
const Hubot = require('hubot') | ||
const expect = chai.expect | ||
const Robot = Hubot.Robot | ||
const TextMessage = Hubot.TextMessage | ||
chai.use(require('sinon-chai')) | ||
const newTestRobot = function newTestRobot () { | ||
const newTestRobot = async () => { | ||
process.env.PORT = '0' | ||
const robot = new Robot(null, 'mock-adapter', true, 'hubot') | ||
const robot = new Robot('mock-adapter', false, 'hubot') | ||
robot.loadFile(path.resolve('src/'), 'diagnostics.js') | ||
await robot.loadFile(path.resolve('src/'), 'diagnostics.js') | ||
await robot.loadAdapter('./test/fixtures/MockAdapter.js') | ||
@@ -33,67 +28,69 @@ robot.adapter.on('connected', () => robot.brain.userForId('1', { | ||
describe('diagnostics', () => describe('respond to diagnostic commands', () => { | ||
beforeEach(function () { | ||
hook('hubot-mock-adapter', require('./fixtures/MockAdapter.js')) | ||
this.robot = newTestRobot() | ||
this.robot.run() | ||
this.user = this.robot.brain.userForName('john') | ||
let robot = null | ||
beforeEach(async () => { | ||
robot = await newTestRobot() | ||
await robot.run() | ||
}) | ||
afterEach(function () { | ||
this.robot.shutdown() | ||
reset() | ||
afterEach(() => { | ||
robot.shutdown() | ||
}) | ||
context('when sent a ping', () => it('hubot pongs', function (done) { | ||
this.robot.adapter.on('send', function (envelope, strings) { | ||
expect(strings.length).to.eql(1) | ||
expect(strings[0]).to.eql('PONG') | ||
return done() | ||
describe('when sent a ping', () => it('hubot pongs', async () => { | ||
let wasCalled = false | ||
robot.adapter.on('send', (envelope, strings) => { | ||
assert.equal(strings.length, 1) | ||
assert.equal(strings[0], 'PONG') | ||
wasCalled = true | ||
}) | ||
return this.robot.adapter.receive(new TextMessage(this.user, 'hubot ping')) | ||
await robot.receive(new TextMessage(this.user, 'hubot ping')) | ||
assert.deepEqual(wasCalled, true) | ||
})) | ||
context('when asked for adapter', () => it('responds with mock-adapter', function (done) { | ||
this.robot.adapter.on('send', function (envelope, strings) { | ||
expect(strings.length).to.eql(1) | ||
expect(strings[0]).to.eql('mock-adapter') | ||
return done() | ||
describe('when asked for adapter', () => it('responds with mock-adapter', async () => { | ||
let wasCalled = false | ||
robot.adapter.on('send', (envelope, strings) => { | ||
assert.equal(strings.length, 1) | ||
assert.equal(strings[0], 'mock-adapter') | ||
wasCalled = true | ||
}) | ||
return this.robot.adapter.receive(new TextMessage(this.user, 'hubot adapter')) | ||
await robot.receive(new TextMessage(this.user, 'hubot adapter')) | ||
assert.deepEqual(wasCalled, true) | ||
})) | ||
context('when asked to echo a string', () => it('echoes the string', function (done) { | ||
this.robot.adapter.on('send', function (envelope, strings) { | ||
expect(strings.length).to.eql(1) | ||
expect(strings[0]).to.eql('horses are weird') | ||
return done() | ||
describe('when asked to echo a string', () => it('echoes the string', async () => { | ||
let wasCalled = false | ||
robot.adapter.on('send', (envelope, strings) => { | ||
assert.equal(strings.length, 1) | ||
assert.equal(strings[0], 'horses are weird') | ||
wasCalled = true | ||
}) | ||
return this.robot.adapter.receive(new TextMessage(this.user, 'hubot echo horses are weird')) | ||
await robot.receive(new TextMessage(this.user, 'hubot echo horses are weird')) | ||
assert.deepEqual(wasCalled, true) | ||
})) | ||
context('when asked for the server time', () => it('responds with the time', function (done) { | ||
this.robot.adapter.on('send', function (envelope, strings) { | ||
expect(strings.length).to.eql(1) | ||
expect(strings[0]).to.include('Server time is:') | ||
return done() | ||
describe('when asked for the server time', () => it('responds with the time', async () => { | ||
let wasCalled = false | ||
robot.adapter.on('send', (envelope, strings) => { | ||
assert.equal(strings.length, 1) | ||
assert.match(strings[0], /Server time is:/g) | ||
wasCalled = true | ||
}) | ||
return this.robot.adapter.receive(new TextMessage(this.user, 'hubot time')) | ||
await robot.receive(new TextMessage(this.user, 'hubot time')) | ||
assert.deepEqual(wasCalled, true) | ||
})) | ||
context('when asked to echo a multiline string', () => it('echoes the multiline string', function (done) { | ||
this.robot.adapter.on('send', function (envelope, strings) { | ||
expect(strings.length).to.eql(1) | ||
expect(strings[0]).to.eql('horses are weird\nviolets are blue') | ||
return done() | ||
describe('when asked to echo a multiline string', () => it('echoes the multiline string', async () => { | ||
let wasCalled = false | ||
robot.adapter.on('send', (envelope, strings) => { | ||
assert.equal(strings.length, 1) | ||
assert.equal(strings[0], 'horses are weird\nviolets are blue') | ||
wasCalled = true | ||
}) | ||
return this.robot.adapter.receive(new TextMessage(this.user, 'hubot echo horses are weird\nviolets are blue')) | ||
await robot.receive(new TextMessage(this.user, 'hubot echo horses are weird\nviolets are blue')) | ||
assert.deepEqual(wasCalled, true) | ||
})) | ||
})) |
@@ -6,19 +6,19 @@ 'use strict' | ||
class MockAdapter extends Adapter { | ||
send (envelope, ...strings) { | ||
async send (envelope, ...strings) { | ||
this.emit('send', envelope, strings) | ||
} | ||
reply (envelope, ...strings) { | ||
async reply (envelope, ...strings) { | ||
this.emit('reply', envelope, strings) | ||
} | ||
topic (envelope, ...strings) { | ||
async topic (envelope, ...strings) { | ||
this.emit('topic', envelope, strings) | ||
} | ||
play (envelope, ...strings) { | ||
async play (envelope, ...strings) { | ||
this.emit('play', envelope, strings) | ||
} | ||
run () { | ||
async run () { | ||
this.emit('connected') | ||
@@ -25,0 +25,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2
151
8271
+ Addedhubot@11.3.0(transitive)
- Removedhubot@^4.0.0
- Removedasync@3.2.6(transitive)
- Removedcline@0.8.2(transitive)
- Removedcoffeescript@2.7.0(transitive)
- Removedhubot@4.1.0(transitive)
- Removedoptparse@1.0.5(transitive)