We can test the variables, check their value during the course of the scenario.
@Event('start')
start() {
nb = 18
> Give me a number
Prompt()
nb += :text
}
import assert from 'assert'
import { ConverseTesting } from 'newbot/testing'
import mainSkill from './main'
describe('My own test', () => {
let converse, userConverse
beforeEach(() => {
converse = new ConverseTesting(mainSkill)
userConverse = converse.createUser()
})
test('Test variable', () => {
return userConverse
.start(testing => {
const varNb = testing.variable('nb')
assert.equal(varNb, 18)
})
.prompt('12', testing => {
const varNb = testing.variable('nb')
assert.equal(varNb, 30)
})
.end()
})
})
$nb = 18
@Event('start')
start() {
> Give me a number
Prompt()
$nb += :text
}
import assert from 'assert'
import { ConverseTesting } from 'newbot/testing'
import mainSkill from './main'
describe('My own test', () => {
let converse, userConverse
beforeEach(() => {
converse = new ConverseTesting(mainSkill)
userConverse = converse.createUser()
})
test('Test global variable', () => {
return userConverse
.start(testing => {
const varNb = testing.userVariable('nb')
assert.equal(varNb, 18)
})
.prompt('12', testing => {
const varNb = testing.userVariable('nb')
assert.equal(varNb, 30)
})
.end()
})
})
@Event('start')
start() {
> Your name ?
Prompt()
> Hello { :text }
}
import assert from 'assert'
import { ConverseTesting } from 'newbot/testing'
import mainSkill from './main'
describe('My own test', () => {
let converse, userConverse
beforeEach(() => {
converse = new ConverseTesting(mainSkill)
userConverse = converse.createUser()
})
test('Test magic variable', () => {
return userConverse
.start()
.prompt('Sam', testing => {
const userName = testing.magicVariable('text')
assert.equal(userName, 'Sam')
const output = testing.output(0)
assert.equal(output, 'Hello Sam')
})
.end()
})
})