CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PrismarineJS

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: PrismarineJS/mineflayer
Path: blob/master/test/externalTests/exampleDigger.js
Views: 789
1
const assert = require('assert')
2
3
module.exports = () => async (bot) => {
4
await bot.test.runExample('examples/digger.js', async (name) => {
5
assert.strictEqual(name, 'digger')
6
bot.chat('/op digger') // to counteract spawn protection
7
bot.chat('/give digger dirt 64')
8
await bot.test.wait(2000)
9
await bot.test.tellAndListen(name, 'dig', (message) => {
10
if (message.startsWith('starting')) {
11
return false // continue to listen
12
} else if (message.startsWith('finished')) {
13
return true // stop listening
14
}
15
assert.fail(`Unexpected message: ${message}`) // error
16
})
17
await bot.test.tellAndListen(name, 'equip dirt', (message) => {
18
if (!message.startsWith('equipped dirt')) {
19
assert.fail(`Unexpected message: ${message}`) // error
20
}
21
return true // stop listening
22
})
23
await bot.test.tellAndListen(name, 'build', (message) => {
24
if (message !== 'Placing a block was successful') {
25
assert.fail(`Unexpected message: ${message}`) // error
26
}
27
return true // stop listening
28
})
29
})
30
}
31
32