Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Improved timeout handling" #419

Merged
merged 1 commit into from
Aug 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
});