Skip to content

Commit

Permalink
Revert "Improved Mineflayer tests timeout handling (#410)"
Browse files Browse the repository at this point in the history
This reverts commit 8a69e72.
  • Loading branch information
vorburger authored and edewit committed Aug 29, 2022
1 parent ff8206b commit fd59089
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions test-mineflayer/storeys.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,46 @@ const createBot = (command) => {
return bot;
}

describe("Storeys plugin test", () => {
let bot;
const handleError = (bot, done) => {
bot.on("error", (e) => {
done(e);
});
}

const handleError = (done) => {
bot.on("error", (e) => {
done(e);
});
}

afterEach(() => bot.quit());
describe("Storeys plugin test", () => {
beforeAll(() => {
// Prevent jest from complaining about an import after the test is done (You are trying to `import` a file after the Jest environment has been torn down.)
jest.useFakeTimers('legacy');
console.log = () => { };
});

test("should connect to minecraft server and execute /make", (done) => {
// given
bot = createBot("/make");
const bot = createBot("/make");

// then
bot.on('messagestr', (msg) => {
if (msg !== "Player joined the game") {
expect(msg).toEqual("Click here to open Scratch and MAKE actions");
done();
bot.quit();
}
});

handleError(done);
handleError(bot, done);
}, TIMEOUT);

test("should execute /new", (done) => {
// given
bot = createBot("/new");
const bot = createBot("/new");

// then
bot.on('title', (msg) => {
expect(msg).toEqual("{\"text\":\"Hello\"}");
done();
bot.quit();
});

handleError(done);
handleError(bot, done);
}, TIMEOUT);
});

0 comments on commit fd59089

Please sign in to comment.