-
-
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.
Separate test files, pass internal names
- Loading branch information
1 parent
213f50f
commit 712b185
Showing
5 changed files
with
82 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -281,4 +281,4 @@ class Metabot { | |
} | ||
} | ||
|
||
module.exports = { Chat, Metabot }; | ||
module.exports = { MENU, Chat, Metabot }; |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict'; | ||
|
||
const test = require('node:test'); | ||
const assert = require('node:assert'); | ||
const path = require('node:path'); | ||
const fsp = require('node:fs/promises'); | ||
const EventEmitter = require('node:events'); | ||
const { parseMarkdown } = require('../lib/markdown.js'); | ||
|
||
const PATH = 'test/Example'; | ||
|
||
test('Parse markdown to Scenario', async () => { | ||
const scenarioFile = path.join(PATH, 'scenario.md'); | ||
const data = await fsp.readFile(scenarioFile, 'utf8'); | ||
const scenario = parseMarkdown(data); | ||
assert.ok(scenario instanceof EventEmitter); | ||
assert.ok(scenario.steps instanceof Map); | ||
assert.strictEqual(scenario.steps.size, 3); | ||
assert.ok(scenario.menu instanceof Array); | ||
assert.strictEqual(scenario.menu.length, 3); | ||
assert.ok(Object.getPrototypeOf(scenario.entry).constructor.name, 'Step'); | ||
assert.strictEqual(scenario.steps.get('1'), scenario.entry); | ||
assert.strictEqual(typeof scenario.name, 'string'); | ||
assert.strictEqual(typeof scenario.description, 'string'); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict'; | ||
|
||
const test = require('node:test'); | ||
const assert = require('node:assert'); | ||
const { Stopwatch } = require('../lib/stopwatch.js'); | ||
|
||
test('Stopwatch initial start', async () => { | ||
const options = { timeout: 1000 }; | ||
const timer = new Stopwatch(() => {}, options); | ||
assert.strictEqual(timer.state.timeout, 1000); | ||
assert.strictEqual(typeof timer.state.start, 'number'); | ||
assert.strictEqual(timer.state.done, false); | ||
}); | ||
|
||
test('Stopwatch initial start', async () => { | ||
const options = { timeout: 1000 }; | ||
const timer = new Stopwatch(() => {}, options); | ||
assert.strictEqual(typeof timer.start, 'number'); | ||
assert.strictEqual(typeof timer.callback, 'function'); | ||
assert.strictEqual(timer.state.timeout, 1000); | ||
assert.strictEqual(typeof timer.state.start, 'number'); | ||
assert.strictEqual(timer.state.done, false); | ||
assert.ok(Object.getPrototypeOf(timer.timer).constructor.name, 'Timer'); | ||
timer.stop(); | ||
}); | ||
|
||
test('Stopwatch restore', async () => { | ||
const options = { start: 1725824170365, timeout: 1000, done: false }; | ||
const timer = new Stopwatch(() => {}, options); | ||
assert.strictEqual(timer.state.timeout, 1000); | ||
assert.strictEqual(timer.state.start, 1725824170365); | ||
assert.strictEqual(timer.state.done, false); | ||
assert.strictEqual(timer.remaining, 0); | ||
timer.stop(); | ||
}); |