mirror of
https://github.com/danbulant/flying-squid
synced 2026-06-19 14:31:17 +00:00
add a few tests based on mineflayer
This commit is contained in:
parent
82dbd722fd
commit
44d721d2a5
3 changed files with 77 additions and 4 deletions
|
|
@ -51,14 +51,15 @@
|
|||
"url": "http://github.com/mhsjlw/flying-squid/issues"
|
||||
},
|
||||
"devDependencies": {
|
||||
"doctoc": "^0.15.0",
|
||||
"longjohn": "~0.2.8",
|
||||
"babel": "5.8.23",
|
||||
"chai": "~3.2.0",
|
||||
"doctoc": "^0.15.0",
|
||||
"gulp": "^3.8.11",
|
||||
"gulp-babel": "^5.1.0",
|
||||
"gulp-plumber": "^1.0.1",
|
||||
"gulp-sourcemaps": "^1.3.0",
|
||||
"mocha": "~2.2.5",
|
||||
"chai": "~3.2.0"
|
||||
"longjohn": "~0.2.8",
|
||||
"mineflayer": "^1.5.1",
|
||||
"mocha": "~2.2.5"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
72
test/mineflayer.js
Normal file
72
test/mineflayer.js
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
var net = require('net');
|
||||
var mcServer=require("../");
|
||||
var settings = require('../config/default-settings');
|
||||
var mineflayer = require("mineflayer");
|
||||
|
||||
|
||||
describe("Server with mineflayer connection", function() {
|
||||
var bot;
|
||||
var serv;
|
||||
var player;
|
||||
before(function(done){
|
||||
var options = {
|
||||
'motd': settings.motd,
|
||||
'max-players': settings.maxPlayers,
|
||||
'port': settings.port,
|
||||
'online-mode': false,
|
||||
gameMode:settings.gameMode,
|
||||
logging:settings.logging,
|
||||
generation:settings.generation,
|
||||
'modpe': settings.modpe,
|
||||
kickTimeout: settings.kickTimeout ? settings.kickTimeout : 10*1000,
|
||||
regionFolder: settings.regionFolder,
|
||||
plugins: settings.plugins
|
||||
};
|
||||
|
||||
serv=mcServer.createMCServer(options);
|
||||
|
||||
serv.on("listening",function(){
|
||||
bot = mineflayer.createBot({
|
||||
host: "localhost",
|
||||
port: 25565,
|
||||
username: "echo"
|
||||
});
|
||||
|
||||
serv.once("newPlayer",function(p){
|
||||
player=p;
|
||||
});
|
||||
|
||||
bot.on('spawn', function() {
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe("commands",function(){
|
||||
it("has an help command", function(done) {
|
||||
bot.once("message",function(message){
|
||||
done();
|
||||
});
|
||||
bot.chat("/help");
|
||||
});
|
||||
it("can use /particle",function(done){
|
||||
bot._client.on('world_particles',function(){
|
||||
done();
|
||||
});
|
||||
bot.chat("/particle 5 10 100 100 100");
|
||||
});
|
||||
it("can use /playsound",function(done) {
|
||||
bot.on('soundEffectHeard',function(){
|
||||
done();
|
||||
});
|
||||
bot.chat('/playsound ambient.weather.rain');
|
||||
});
|
||||
it("can use /summon",function(done) {
|
||||
bot.on('entitySpawn',function(entity){
|
||||
if(entity.name=="EnderDragon")
|
||||
done();
|
||||
});
|
||||
bot.chat('/summon EnderDragon');
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue