mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-11-14 19:04:59 -05:00
tests fixed: parse properly the new JSON chat messages
This commit is contained in:
parent
767f64153b
commit
cd6b27aeac
3 changed files with 18 additions and 32 deletions
BIN
test/.test.js.swp
Normal file
BIN
test/.test.js.swp
Normal file
Binary file not shown.
|
@ -1,27 +0,0 @@
|
|||
generator-settings=
|
||||
allow-nether=true
|
||||
level-name=world
|
||||
enable-query=false
|
||||
allow-flight=false
|
||||
server-port=25565
|
||||
level-type=DEFAULT
|
||||
enable-rcon=false
|
||||
level-seed=
|
||||
server-ip=
|
||||
max-build-height=256
|
||||
spawn-npcs=true
|
||||
white-list=false
|
||||
spawn-animals=true
|
||||
snooper-enabled=true
|
||||
hardcore=false
|
||||
texture-pack=
|
||||
online-mode=true
|
||||
pvp=true
|
||||
difficulty=1
|
||||
gamemode=0
|
||||
max-players=120
|
||||
spawn-monsters=true
|
||||
generate-structures=true
|
||||
view-distance=10
|
||||
spawn-protection=16
|
||||
motd=test1234
|
23
test/test.js
23
test/test.js
|
@ -294,10 +294,15 @@ describe("client", function() {
|
|||
client.on(0x03, function(packet) {
|
||||
chatCount += 1;
|
||||
assert.ok(chatCount <= 2);
|
||||
var message = JSON.parse(packet.message);
|
||||
if (chatCount === 1) {
|
||||
assert.strictEqual(packet.message, "<" + client.session.username + ">" + " hello everyone; I have logged in.");
|
||||
assert.strictEqual(message.translate, "chat.type.text");
|
||||
assert.strictEqual(message.using[0], client.session.username);
|
||||
assert.strictEqual(message.using[1], "hello everyone; I have logged in.");
|
||||
} else if (chatCount === 2) {
|
||||
assert.strictEqual(packet.message, "[Server] hello");
|
||||
assert.strictEqual(message.translate, "chat.type.announcement");
|
||||
assert.strictEqual(message.using[0], "Server");
|
||||
assert.strictEqual(message.using[1], "hello");
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
@ -328,10 +333,15 @@ describe("client", function() {
|
|||
client.on(0x03, function(packet) {
|
||||
chatCount += 1;
|
||||
assert.ok(chatCount <= 2);
|
||||
var message = JSON.parse(packet.message);
|
||||
if (chatCount === 1) {
|
||||
assert.strictEqual(packet.message, "<Player>" + " hello everyone; I have logged in.");
|
||||
assert.strictEqual(message.translate, "chat.type.text");
|
||||
assert.strictEqual(message.using[0], "Player");
|
||||
assert.strictEqual(message.using[1], "hello everyone; I have logged in.");
|
||||
} else if (chatCount === 2) {
|
||||
assert.strictEqual(packet.message, "[Server] hello");
|
||||
assert.strictEqual(message.translate, "chat.type.announcement");
|
||||
assert.strictEqual(message.using[0], "Server");
|
||||
assert.strictEqual(message.using[1], "hello");
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
@ -364,7 +374,10 @@ describe("client", function() {
|
|||
});
|
||||
});
|
||||
client.on(0x03, function(packet) {
|
||||
assert.strictEqual(packet.message, "<Player>" + " hello everyone; I have logged in.");
|
||||
var message = JSON.parse(packet.message);
|
||||
assert.strictEqual(message.translate, "chat.type.text");
|
||||
assert.strictEqual(message.using[0], "Player");
|
||||
assert.strictEqual(message.using[1], "hello everyone; I have logged in.");
|
||||
setTimeout(function() {
|
||||
done();
|
||||
}, SURVIVE_TIME);
|
||||
|
|
Loading…
Reference in a new issue