UNPKG

overwatch-api-server

Version:
89 lines (81 loc) 3.62 kB
"use strict"; var _ava = _interopRequireDefault(require("ava")); var _parser = require("../../src/parser"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } var platform = 'pc'; var region = 'us'; var tag = 'xQc-11273'; var result; _ava["default"].before.cb(function (t) { (0, _parser.getStats)(platform, region, tag, function (err, json) { if (err) t.fail(); result = json; t.end(); }); }); (0, _ava["default"])('get base information of user profile', function (t) { t.deepEqual(_typeof(result.username), 'string'); t.deepEqual(_typeof(result.level), 'number'); t.deepEqual(result.portrait.startsWith('http'), true); }); (0, _ava["default"])('get user top heroes information', function (t) { var topHeroCategories = { quickplay: { 'played': '0x0860000000000021', 'games_won': '0x0860000000000039', 'weapon_accuracy': '0x086000000000002F', 'eliminations_per_life': '0x08600000000003D2', 'multikill_best': '0x0860000000000346', 'objective_kills_average': '0x086000000000039C' }, competitive: { 'played': '0x0860000000000021', 'games_won': '0x0860000000000039', 'win_rate': '0x08600000000003D1', 'weapon_accuracy': '0x086000000000002F', 'eliminations_per_life': '0x08600000000003D2', 'multikill_best': '0x0860000000000346', 'objective_kills_average': '0x086000000000039C' } }; Object.keys(topHeroCategories.quickplay).forEach(function (k) { result['stats']['top_heroes']['quickplay'][k].map(function (hero) { t.deepEqual(_typeof(hero['hero']), 'string'); t.deepEqual(_typeof(hero[k]), 'string'); t.deepEqual(hero.img.startsWith('http'), true); }); }); Object.keys(topHeroCategories.competitive).forEach(function (k) { result['stats']['top_heroes']['competitive'][k].map(function (hero) { t.deepEqual(_typeof(hero['hero']), 'string'); t.deepEqual(_typeof(hero[k]), 'string'); t.deepEqual(hero.img.startsWith('http'), true); }); }); }); (0, _ava["default"])('get combat stats', function (t) { t.is(result['stats']['combat']['quickplay'].length > 0, true); result['stats']['combat']['quickplay'].map(function (stat) { t.deepEqual(_typeof(stat.title), 'string'); t.deepEqual(_typeof(stat.value), 'string'); }); t.is(result['stats']['combat']['competitive'].length > 0, true); result['stats']['combat']['competitive'].map(function (stat) { t.deepEqual(_typeof(stat.title), 'string'); t.deepEqual(_typeof(stat.value), 'string'); }); }); _ava["default"].skip('get death stats', function (t) { t.is(result['stats']['deaths']['quickplay'].length > 0, true); result['stats']['deaths']['quickplay'].map(function (stat) { t.deepEqual(_typeof(stat.title), 'string'); t.deepEqual(_typeof(stat.value), 'string'); }); t.is(result['stats']['deaths']['competitive'].length > 0, true); result['stats']['deaths']['competitive'].map(function (stat) { t.deepEqual(_typeof(stat.title), 'string'); t.deepEqual(_typeof(stat.value), 'string'); }); }); //# sourceMappingURL=C:\Users\Alf\Source\overwatch-api\api\node_modules\.cache\ava\04bb7dfc868f7c4034c8f6ccf8ef92aa.js.map