(dev) remove rewire, add babel-plugin-rewire. (#44)

* removed rewire. now using babel-rewire instead

* implemented more tests

* changed some eslint params

* linting

* linting

* coverage on getChant

Co-authored-by: Marcus Netz <marcus.netz@godyo.com>
This commit is contained in:
2021-05-06 12:52:33 +02:00
committed by GitHub
parent 4fa2dc7ab7
commit 79c95cea97
14 changed files with 807 additions and 311 deletions

View File

@ -1,5 +1,5 @@
const Capitalize = (Word = 'none') => {
return Word[0].toUpperCase() + Word.substring(1);
return Word[0].toUpperCase() + Word.substring(1);
};
module.exports = { Capitalize };

View File

@ -1,5 +1,5 @@
const CountOccurences = (arr, value) => {
return arr.filter((v) => (v === value)).length;
return arr.filter(v => v === value).length;
};
module.exports = { CountOccurences };
module.exports = { CountOccurences };

View File

@ -1,22 +1,18 @@
require('module-alias/register');
const { getAttributeLevels } = require('@dsabot/getAttributeLevels');
const Chants = require('@Lib/Chants.json');
const { isEmpty } = require('@dsabot/isEmpty');
const getChant = ({ Character: Character = [], chant_name: chantName = '' } = {}) => {
//if (!Character.hasOwnProperty('chants')) return;
if (!Character.hasOwnProperty('chants')) return null;
const chantEntry =
Chants.find(chant => chant.id.toLowerCase() === chantName.toLowerCase()) ||
Chants.find(chant => chant.name.toLowerCase() === chantName.toLowerCase());
if (!chantEntry) {
console.log(`getChant() Did not find entry for ${chantName}`);
return null;
}
let Level = 0; // This is the minimum attributes value.
const Chant = Character.chants.find(chant => chant.id === chantEntry.id) || null;
if (Chant && Chant.hasOwnProperty('level')) {
Level = Chant.level || 0;
}
// let us filter out blessings.
if (isEmpty(chantEntry)) return null;
const Chant = Character.chants.find(chant => chant.id === chantEntry.id); // || null;
const Level = Chant.hasOwnProperty('level') ? Chant.level : 0;
const Attributes = getAttributeLevels(chantEntry.attributes, Character);
return { Name: chantEntry.name, Level: Level, Attributes: Attributes };