Path: blob/master/test/externalTests/gamemode.js
9427 views
// test to see if bot retains creative gamemode in bot object on death12const assert = require('assert')3const { onceWithCleanup } = require('../../lib/promise_utils')45module.exports = () => {6const tests = []78function addTest (name, f) {9tests[name] = (bot) => f(bot)10}1112addTest('change', async (bot) => {13await bot.test.becomeSurvival()14assert.strictEqual(bot.game.gameMode, 'survival', 'Wrong gamemode after switching gamemode')15await bot.test.becomeCreative()16assert.strictEqual(bot.game.gameMode, 'creative', 'Wrong gamemode after switching gamemode')17})1819addTest('after respawn', async (bot) => {20await bot.test.becomeCreative()21bot.test.selfKill()22await onceWithCleanup(bot, 'respawn', { timeout: 5000 })23// Respawn packets send the gamemode. If the bot is in creative mode, it should respawn in creative mode. Tested <1.2024assert.strictEqual(bot.game.gameMode, 'creative', 'Wrong gamemode after respawn')25})2627return tests28}293031