Add tests

This commit is contained in:
maxswa
2019-06-10 11:57:06 -04:00
parent 95a679e9a3
commit 3c0e8143c3
3 changed files with 5062 additions and 4 deletions

24
hiscores.test.js Normal file
View File

@@ -0,0 +1,24 @@
const hiscores = require('./hiscores');
test('Get Lynx Titans stats', async done => {
const callback = data => {
expect(data.main.stats.overall.level).toBe('2277');
expect(data.main.stats.overall.rank).toBe('1');
expect(data.main.stats.overall.xp).toBe('4600000000');
done();
};
hiscores.getStats('Lynx Titan', 'main').then(callback);
});
test('Ensure correct lengths', async done => {
const callback = data => {
expect(Object.keys(data.main.stats).length).toBe(24);
expect(Object.keys(data.main.clues).length).toBe(7);
expect(Object.keys(data.main.bh).length).toBe(2);
expect(Object.keys(data.main.lms).length).toBe(2);
done();
};
hiscores.getStats('B0aty', 'main').then(callback);
});

5031
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -4,8 +4,7 @@
"description": "The Oldschool Runescape API wrapper that does more!",
"main": "hiscores.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node hiscores.js"
"test": "jest"
},
"repository": {
"type": "git",
@@ -26,5 +25,11 @@
"bugs": {
"url": "https://github.com/maxswa/osrs-json-hiscores/issues"
},
"homepage": "https://github.com/maxswa/osrs-json-hiscores#readme"
"homepage": "https://github.com/maxswa/osrs-json-hiscores#readme",
"dependencies": {
"axios": "^0.19.0"
},
"devDependencies": {
"jest": "^24.8.0"
}
}