diff --git a/tests/mods/landSpec.js b/tests/mods/landSpec.js index 2be711e..ef193dd 100644 --- a/tests/mods/landSpec.js +++ b/tests/mods/landSpec.js @@ -48,7 +48,38 @@ describe ( 'Land.js tests', function () { expect ( idrinth.land.data ).toEqual ( defData ); } ); - lt ( "", function () { + describe ( "Land calculate method", function () { + + beforeEach ( function () { + var mock = {}, + defaultStructure = '{ "value": "", "parentNode": { "nextSibling": { "innerHTML": "" } } }', + document_getElementById; + document_getElementById = jasmine.createSpyObj ( "input", [ 'value', 'parentNode', 'nextSibling', 'innerHTML' ] ); + + for ( var i in idrinth.land.data ) { + if ( idrinth.land.data.hasOwnProperty ( i ) ) { + mock[ 'idrinth-land-' + i ] = JSON.parse ( defaultStructure ); + } + } + mock[ 'idrinth-land-gold' ] = { value: '' }; + + console.log ( mock ); + + spyOn ( document, "getElementById" ).and.callFake ( function ( id ) { + if ( mock.hasOwnProperty ( id ) ) { + return mock[ id ]; + } + + return document_getElementById ( id ); + } ); + + spyOn(idrinth.core, 'alert'); + } ); + + + it ( "Should properly calculate land values", function () { + idrinth.land.calculate (); + } ); } );