Skip to content
This repository was archived by the owner on Mar 29, 2021. It is now read-only.

Commit

Permalink
#125: first step for mocking in Land.js;
Browse files Browse the repository at this point in the history
  • Loading branch information
w20k committed Oct 4, 2016
1 parent 8896b53 commit cb8cf51
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion tests/mods/landSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
} );

} );

Expand Down

0 comments on commit cb8cf51

Please sign in to comment.