-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(adapter): Inherit settings changes after start
- Moved adapters to singleton pattern to accept changes to settings outside adapter - Fixed method and tests for restoring settings after extending
- Loading branch information
1 parent
fba4de6
commit 1464b40
Showing
7 changed files
with
198 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,39 @@ | ||
import 'mocha' | ||
import { expect } from 'chai' | ||
import * as bot from '..' | ||
import * as shell from './shell' | ||
import * as shellAdapter from './shell' | ||
|
||
let initEnv: any | ||
|
||
describe('[adapter-shell]', () => { | ||
before(() => { | ||
initEnv = process.env | ||
process.env.BOT_NAME = 'aston' | ||
process.env.BOT_SHELL_USER = 'carroll' | ||
process.env.BOT_SHELL_ROOM = 'shell' | ||
}) | ||
after(() => process.env = initEnv) | ||
afterEach(() => bot.reset()) | ||
describe('.use', () => { | ||
it('returns adapter instance', () => { | ||
const store = shell.use(bot) | ||
expect(store).to.be.instanceof(bot.Adapter) | ||
const shell = shellAdapter.use(bot) | ||
expect(shell).to.be.instanceof(bot.Adapter) | ||
}) | ||
it('accepts changes in bot settings before startup', async () => { | ||
bot.settings.set('name', 'shelby') | ||
const shell = shellAdapter.use(bot) | ||
shell.debug = true | ||
bot.start() | ||
await new Promise((resolve) => bot.events.on('shell-started', resolve)) | ||
expect(shell.bot.settings.name).to.equal('shelby') | ||
}) | ||
it('accepts changes in bot settings after startup', async () => { | ||
const shell = shellAdapter.use(bot) | ||
shell.debug = true | ||
bot.settings.name = 'not-shelby' | ||
await bot.start().catch((err) => { throw err }) | ||
bot.settings.name = 'shelby' | ||
expect(shell.bot.settings.name).to.equal('shelby') | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.