mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2025-05-19 09:40:25 -04: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
test
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) {
|
client.on(0x03, function(packet) {
|
||||||
chatCount += 1;
|
chatCount += 1;
|
||||||
assert.ok(chatCount <= 2);
|
assert.ok(chatCount <= 2);
|
||||||
|
var message = JSON.parse(packet.message);
|
||||||
if (chatCount === 1) {
|
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) {
|
} 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();
|
done();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -328,10 +333,15 @@ describe("client", function() {
|
||||||
client.on(0x03, function(packet) {
|
client.on(0x03, function(packet) {
|
||||||
chatCount += 1;
|
chatCount += 1;
|
||||||
assert.ok(chatCount <= 2);
|
assert.ok(chatCount <= 2);
|
||||||
|
var message = JSON.parse(packet.message);
|
||||||
if (chatCount === 1) {
|
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) {
|
} 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();
|
done();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -364,7 +374,10 @@ describe("client", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
client.on(0x03, function(packet) {
|
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() {
|
setTimeout(function() {
|
||||||
done();
|
done();
|
||||||
}, SURVIVE_TIME);
|
}, SURVIVE_TIME);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue