mirror of
https://github.com/danbulant/flying-squid
synced 2026-06-18 22:11:07 +00:00
add a digging and placing test
the placing test is currently skipped because it doesn't always work (might be better to restart the server and bots at each test)
This commit is contained in:
parent
526a9f1132
commit
974fcafba7
2 changed files with 49 additions and 10 deletions
|
|
@ -61,7 +61,7 @@
|
|||
"gulp-plumber": "^1.0.1",
|
||||
"gulp-sourcemaps": "^1.3.0",
|
||||
"longjohn": "~0.2.8",
|
||||
"mineflayer": "^1.5.1",
|
||||
"mineflayer": "^1.5.2",
|
||||
"mocha": "~2.3.4"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,20 @@ describe("Server with mineflayer connection", () => {
|
|||
var bot;
|
||||
var bot2;
|
||||
var serv;
|
||||
|
||||
async function onGround()
|
||||
{
|
||||
await new Promise((cb) => {
|
||||
var l=() => {
|
||||
if(bot.entity.onGround) {
|
||||
bot.removeListener("move",l);
|
||||
cb();
|
||||
}
|
||||
};
|
||||
bot.on("move",l);
|
||||
});
|
||||
}
|
||||
|
||||
before(async function () {
|
||||
this.timeout(10 * 60 * 1000);
|
||||
var options = settings;
|
||||
|
|
@ -34,15 +48,7 @@ describe("Server with mineflayer connection", () => {
|
|||
username: "bot2"
|
||||
});
|
||||
|
||||
await new Promise((cb) => {
|
||||
var l=() => {
|
||||
if(bot.entity.onGround) {
|
||||
bot.removeListener("move",l);
|
||||
cb();
|
||||
}
|
||||
};
|
||||
bot.on("move",l);
|
||||
});
|
||||
await onGround();
|
||||
});
|
||||
|
||||
after(() => {
|
||||
|
|
@ -50,6 +56,39 @@ describe("Server with mineflayer connection", () => {
|
|||
return once(serv._server,"close");
|
||||
});
|
||||
|
||||
|
||||
|
||||
describe("actions",() => {
|
||||
it("can dig",async function () {
|
||||
this.timeout(10 * 60 * 1000);
|
||||
var pos=bot.entity.position.offset(0,-1,0);
|
||||
bot.dig(bot.blockAt(pos));
|
||||
let [oldBlock,newBlock]=await once(bot,'blockUpdate:'+pos,{array:true});
|
||||
assert.equal(newBlock.type,0);
|
||||
await onGround();
|
||||
});
|
||||
it.skip("can place a block",async function () {
|
||||
|
||||
this.timeout(10 * 60 * 1000);
|
||||
var pos=bot.entity.position.offset(0,-2,0);
|
||||
bot.dig(bot.blockAt(pos));
|
||||
|
||||
let [oldBlock,newBlock]=await once(bot2,'blockUpdate:'+pos,{array:true});
|
||||
assert.equal(newBlock.type,0);
|
||||
bot.creative.setInventorySlot(36,new mineflayer.Item(1,1));
|
||||
await new Promise((cb) => {
|
||||
bot.inventory.on("windowUpdate",(slot,oldItem,newItem) => {
|
||||
if(slot==36 && newItem && newItem.type==1)
|
||||
cb();
|
||||
});
|
||||
});
|
||||
|
||||
bot.placeBlock(bot.blockAt(pos.offset(0,-2,0)),new Vec3(0,1,0));
|
||||
[oldBlock,newBlock]=await once(bot2,'blockUpdate:'+pos.offset(0,-1,0),{array:true});
|
||||
assert.equal(newBlock.type,1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("commands",() => {
|
||||
it("has an help command", async () => {
|
||||
bot.chat("/help");
|
||||
|
|
|
|||
Loading…
Reference in a new issue