fix /setblock test, fix #344

This commit is contained in:
Romain Beaumont 2018-05-27 21:24:43 +02:00
parent 60318c74e1
commit 3e172af693
No known key found for this signature in database
GPG key ID: DB60E388B3BCF286

View file

@ -112,22 +112,22 @@ squid.supportedVersions.forEach((supportedVersion, i) => {
await serv.quit() await serv.quit()
}) })
describe('actions', () => { function waitSpawnZone (bot, view) {
function waitSpawnZone (bot, view) { const nbChunksExpected = (view * 2) * (view * 2)
const nbChunksExpected = (view * 2) * (view * 2) let c = 0
let c = 0 return new Promise(resolve => {
return new Promise(resolve => { const listener = () => {
const listener = () => { c++
c++ if (c === nbChunksExpected) {
if (c === nbChunksExpected) { bot.removeListener('chunkColumnLoad', listener)
bot.removeListener('chunkColumnLoad', listener) resolve()
resolve()
}
} }
bot.on('chunkColumnLoad', listener) }
}) bot.on('chunkColumnLoad', listener)
} })
}
describe('actions', () => {
test('can dig', async () => { test('can dig', async () => {
await Promise.all([waitSpawnZone(bot, 2), waitSpawnZone(bot2, 2), onGround(bot), onGround(bot2)]) await Promise.all([waitSpawnZone(bot, 2), waitSpawnZone(bot2, 2), onGround(bot), onGround(bot2)])
@ -244,7 +244,7 @@ squid.supportedVersions.forEach((supportedVersion, i) => {
serv.getPlayer('bot').op = true serv.getPlayer('bot').op = true
}) })
test('can use /setblock', async () => { test('can use /setblock', async () => {
await once(bot, 'chunkColumnLoad') await Promise.all([waitSpawnZone(bot, 2), onGround(bot)])
bot.chat('/setblock 1 2 3 95 0') bot.chat('/setblock 1 2 3 95 0')
let [, newBlock] = await once(bot, 'blockUpdate:' + new Vec3(1, 2, 3), {array: true}) let [, newBlock] = await once(bot, 'blockUpdate:' + new Vec3(1, 2, 3), {array: true})
expect(newBlock.type).toEqual(95) expect(newBlock.type).toEqual(95)