This repository has been archived by the owner on Mar 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conflicts: src/mods/text.js tests/landbuy.js
- Loading branch information
Showing
8 changed files
with
376 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Coverage directory used by tools like istanbul | ||
coverage | ||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
# Dependency directories | ||
node_modules | ||
.npm | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Karma configuration | ||
|
||
module.exports = function ( config ) { | ||
config.set ( { | ||
|
||
// base path that will be used to resolve all patterns (eg. files, exclude) | ||
basePath: '', | ||
|
||
|
||
// frameworks to use | ||
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter | ||
frameworks: [ 'jasmine' ], | ||
|
||
|
||
// list of files / patterns to load in the browser | ||
files: [ | ||
//Starting point | ||
'src/stable.js', | ||
|
||
'src/**/*.js', | ||
'tests/**/*.spec.js' | ||
], | ||
|
||
|
||
// list of files to exclude | ||
exclude: [ | ||
'src/libs/*.js' | ||
], | ||
|
||
|
||
// preprocess matching files before serving them to the browser | ||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor | ||
preprocessors: { | ||
'src/**/*.js': [ 'coverage' ] | ||
}, | ||
|
||
|
||
// test results reporter to use | ||
// possible values: 'dots', 'progress' | ||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter | ||
reporters: [ 'spec', 'coverage' ], | ||
|
||
|
||
// web server port | ||
port: 9876, | ||
|
||
|
||
// enable / disable colors in the output (reporters and logs) | ||
colors: true, | ||
|
||
|
||
// level of logging | ||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG | ||
logLevel: config.LOG_INFO, | ||
|
||
|
||
// enable / disable watching file and executing tests whenever any file changes | ||
autoWatch: false, | ||
|
||
|
||
// start these browsers | ||
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher | ||
browsers: [ 'PhantomJS' ], | ||
|
||
|
||
// Continuous Integration mode | ||
// if true, Karma captures browsers, runs the tests and exits | ||
singleRun: true, | ||
|
||
// Concurrency level | ||
// how many browser should be started simultaneous | ||
concurrency: Infinity | ||
} ) | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"name": "idotd", | ||
"version": "10.0.0", | ||
"description": "A script for dawn of the dragons, that works based on data provided to https://dotd.idrinth.de via UgUp", | ||
"main": "src/stable.js", | ||
"directories": { | ||
"test": "test" | ||
}, | ||
"scripts": { | ||
"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", | ||
"url": "git+https://github.com/Idrinth/IDotD.git" | ||
}, | ||
"keywords": [ | ||
"dotd", | ||
"idrinth", | ||
"script", | ||
"userscript", | ||
"dotd" | ||
], | ||
"author": "Björn Büttner", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/Idrinth/IDotD/issues" | ||
}, | ||
"homepage": "https://github.com/Idrinth/IDotD#idotd", | ||
"devDependencies": { | ||
"jasmine": "^2.5.3", | ||
"jasmine-core": "^2.5.2", | ||
"karma": "^1.3.0", | ||
"karma-coverage": "^1.1.1", | ||
"karma-jasmine": "^1.1.0", | ||
"karma-phantomjs-launcher": "^1.0.2", | ||
"karma-spec-reporter": "0.0.26" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
describe ( 'Land.js tests', function () { | ||
|
||
it ( 'should have a idrinth variable in scope', function () { | ||
expect ( idrinth ).toBeDefined (); | ||
} ); | ||
|
||
|
||
it ( 'should check default data is valid', function () { | ||
var defData = { | ||
cornfield: { | ||
perHour: 100, | ||
base: 4000 | ||
}, | ||
stable: { | ||
perHour: 300, | ||
base: 15000 | ||
}, | ||
barn: { | ||
perHour: 400, | ||
base: 25000 | ||
}, | ||
store: { | ||
perHour: 700, | ||
base: 50000 | ||
}, | ||
pub: { | ||
perHour: 900, | ||
base: 75000 | ||
}, | ||
inn: { | ||
perHour: 1200, | ||
base: 110000 | ||
}, | ||
tower: { | ||
perHour: 2700, | ||
base: 300000 | ||
}, | ||
fort: { | ||
perHour: 4500, | ||
base: 600000 | ||
}, | ||
castle: { | ||
perHour: 8000, | ||
base: 1200000 | ||
} | ||
}; | ||
|
||
expect ( idrinth.land.data ).toEqual ( defData ); | ||
} ); | ||
|
||
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: '' }; | ||
|
||
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 (); | ||
} ); | ||
|
||
} ); | ||
|
||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
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" ); | ||
} ); | ||
|
||
} ); | ||
|
||
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); | ||
}); | ||
|
||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
describe ( 'Settings.js tests', function () { | ||
|
||
it ( 'should have a idrinth variable in scope', function () { | ||
expect ( idrinth ).toBeDefined (); | ||
} ); | ||
|
||
it ( 'should have default values defined', function () { | ||
var defaults = { | ||
raids: false, | ||
favs: '', | ||
factor: true, | ||
moveLeft: false, | ||
minimalist: false, | ||
chatHiddenOnStart: true, | ||
names: true, | ||
timeout: 5000, | ||
loadtime: 5000, | ||
windows: 3, | ||
warBottom: false, | ||
landMax: true, | ||
chatting: true, | ||
chatuser: '', | ||
newgroundLoad: 30, | ||
chatpass: '', | ||
isWorldServer: false, | ||
alarmTime: '8:0', | ||
alarmActive: false, | ||
bannedRaids: {}, | ||
language: 'en', | ||
notification: { | ||
mention: true, | ||
message: true, | ||
raid: true | ||
}, | ||
land: { | ||
cornfield: 0, | ||
stable: 0, | ||
barn: 0, | ||
store: 0, | ||
pub: 0, | ||
inn: 0, | ||
tower: 0, | ||
fort: 0, | ||
castle: 0, | ||
gold: 0 | ||
} | ||
}; | ||
|
||
var copySettings = JSON.parse ( JSON.stringify ( idrinth.settings ) ); | ||
|
||
//CleanUP functions -> not part of the test | ||
for ( var i in copySettings ) { | ||
if ( copySettings.hasOwnProperty ( i ) && typeof copySettings[ i ] === 'function' ) { | ||
delete copySettings[ i ]; | ||
} | ||
} | ||
|
||
expect ( copySettings ).toEqual ( defaults ); | ||
} ); | ||
|
||
} ); |