From 9a0715f2835540062b5591a9506fa6f97719ce60 Mon Sep 17 00:00:00 2001 From: ddenisov Date: Sat, 14 Jan 2017 18:50:08 +0200 Subject: [PATCH] Fixes #125: minor updates to names tests, text.js reverted; --- src/mods/text.js | 2 +- tests/mods/names.spec.js | 62 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/src/mods/text.js b/src/mods/text.js index 29e0f5c..419039c 100644 --- a/src/mods/text.js +++ b/src/mods/text.js @@ -44,7 +44,7 @@ idrinth.text = { * See languages/en.json for an example * @type {object} */ - data: {}, + data: JSON.parse ( '###LANG###' ), /** * returns the translation of a provided key or an error-message if no * matching translation is found diff --git a/tests/mods/names.spec.js b/tests/mods/names.spec.js index ebe38e5..21a29a0 100644 --- a/tests/mods/names.spec.js +++ b/tests/mods/names.spec.js @@ -44,4 +44,66 @@ describe ( 'Names.js tests', function () { } ); + describe ( "Names run method", function () { + + beforeAll(function(){ + + var SPANUsername = {}; + document.getElementsByClassName = jasmine.createSpy('HTML Class Elements').andCallFake(function(className) { + if(!SPANUsername[className]) { + SPANUsername[className] = document.createElement('span'); + } + return SPANUsername[className]; + }); + }); + + it ( "Should run for new names and add them", function () { + + var testUser = { + kongregate: { name : 'test'}, + world: { name : 'test'} + }; + + idrinth.names.counter = 300; + idrinth.names.names['testUser'] = testUser; + + idrinth.names.run (); + + expect ( idrinth.names.users ).toEqual ( 2 ); + expect ( idrinth.names.counter ).toEqual ( 121312 ); + } ); + + it ( "Should get attribute with name dotdxname", function () { + + idrinth.names.run (); + + expect ( idrinth.names.users ).toEqual ( 2 ); + expect ( idrinth.names.counter ).toEqual ( 300 ); + } ); + + } ); + + describe ( "Names start method for kongregate", function () { + + it ( "Should start names for kongregate", function () { + // idrinth.ui.tooltip + // idrinth.ui.base + // idrinth.ui.updateClassesList + // idrinth.settings.get + // idrinth.ui.setTooltipTimeout + // idrinth.ui.getElementPositioning + + spyOn(idrinth.core.multibind, 'add'); + spyOn(idrinth.core.timeouts, 'add'); + + idrinth.names.run (); + + expect(idrinth.core.multibind.add).toHaveBeenCalled(); + expect(idrinth.core.multibind.add).toHaveBeenCalledTimes(1); + + expect(idrinth.core.timeouts.add).toHaveBeenCalled(); + expect(idrinth.core.timeouts.add).toHaveBeenCalledTimes(1); + }); + + } ); } ); \ No newline at end of file