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

Commit

Permalink
#125: added parse method test for names.js and default, minor updates;
Browse files Browse the repository at this point in the history
  • Loading branch information
w20k committed Jan 14, 2017
1 parent 75f1186 commit 5d01b9b
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 7 deletions.
4 changes: 2 additions & 2 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = function ( config ) {
'src/stable.js',

'src/**/*.js',
'tests/**/*Spec.js'
'tests/**/*.spec.js'
],


Expand All @@ -31,7 +31,7 @@ module.exports = function ( config ) {
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'src/**/*.js': ['coverage']
'src/**/*.js': [ 'coverage' ]
},


Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"test": "test"
},
"scripts": {
"test": "./node_modules/karma/bin/karma start karma.conf.js"
"test": "./node_modules/karma/bin/karma start karma.conf.js",
"test-watch": "./node_modules/karma/bin/karma start karma.conf.js --auto-watch"
},
"repository": {
"type": "git",
Expand All @@ -27,11 +28,11 @@
},
"homepage": "https://github.com/Idrinth/IDotD#idotd",
"devDependencies": {
"jasmine": "^2.5.2",
"jasmine": "^2.5.3",
"jasmine-core": "^2.5.2",
"karma": "^1.3.0",
"karma-coverage": "^1.1.1",
"karma-jasmine": "^1.0.2",
"karma-jasmine": "^1.1.0",
"karma-phantomjs-launcher": "^1.0.2",
"karma-spec-reporter": "0.0.26"
}
Expand Down
2 changes: 0 additions & 2 deletions tests/mods/landSpec.js → tests/mods/land.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ describe ( 'Land.js tests', function () {
}
mock[ 'idrinth-land-gold' ] = { value: '' };

console.log ( mock );

spyOn ( document, "getElementById" ).and.callFake ( function ( id ) {
if ( mock.hasOwnProperty ( id ) ) {
return mock[ id ];
Expand Down
47 changes: 47 additions & 0 deletions tests/mods/names.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
describe ( 'Names.js tests', function () {

it ( 'should have a idrinth variable in scope', function () {
expect ( idrinth ).toBeDefined ();
} );


it ( 'should check default data is valid, and empty', function () {
expect ( idrinth.names.users ).toEqual ( {} );
expect ( idrinth.names.classes ).toEqual ( {} );
expect ( idrinth.names.guilds ).toEqual ( {} );
expect ( idrinth.names.counter ).toEqual ( 0 );
} );

describe ( "Names parse method", function () {
//<span class="username chat_message_window_username ign dotdm_1484406507967"
// username="arkamat" dotdxname="arkamat" oncontextmenu="return false;">K2 mat</span>

it ( "Should get attribute with name dotdxname", function () {
var span = document.createElement ( "span" );
span.className = 'username chat_message_window_username ign';
span.setAttribute ( "dotdxname", "testcharacterDTX" );
span.innerHTML = "K2 TestCharacter";

expect ( idrinth.names.parse ( span ) ).toEqual ( "testcharacterDTX" );
} );

it ( "Should get attribute with name username", function () {

var span = document.createElement ( "span" );
span.className = 'username';
span.setAttribute ( "username", "testcharacterUSN" );
span.innerHTML = "K2 TestCharacter";

expect ( idrinth.names.parse ( span ) ).toEqual ( "testcharacterUSN" );
} );

it ( "Should get default attribute", function () {
var span = document.createElement ( "span" );
span.innerHTML = "K2 TestCharacter";

expect ( idrinth.names.parse ( span ) ).toEqual ( "K2 TestCharacter" );
} );

} );

} );

0 comments on commit 5d01b9b

Please sign in to comment.