Skip to content
This repository was archived by the owner on Aug 12, 2022. It is now read-only.

Commit

Permalink
Add tests for gene quality
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaneMaglangit committed Jul 30, 2021
1 parent 37a9b9a commit 63f99e4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/axie-gene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ export class AxieGene {

/**
* Calculates the purity or gene quality of the Axie's gene.
* @returns an integer that represents the quality of the gene in percentage.
* @returns a number that represents the quality of the gene in percentage.
*/
getGeneQuality(): number {
let geneQuality = 0;
Expand All @@ -562,7 +562,7 @@ export class AxieGene {
geneQuality += this.getPartQuality(this._genes.horn);
geneQuality += this.getPartQuality(this._genes.back);
geneQuality += this.getPartQuality(this._genes.tail);
return geneQuality;
return parseFloat(geneQuality.toFixed(2));
}

/**
Expand Down
13 changes: 12 additions & 1 deletion test/axie-gene.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,15 @@ describe('AxieGene_Origin_512bit', () => {
it('parse tag', () => {
expect(axieGene.tag).toBe(Tag.Origin);
});
});
});

describe('AxieGene_Quality', () => {
const axieGeneP6 = new AxieGene('0x50000000021053031443110414a5280814250802146508c414451108146230c2');
it('gene quality pure 6', () => {
expect(axieGeneP6.getGeneQuality()).toBe(88);
});
const axieGeneP2 = new AxieGene('0x300000000b881322104308c20c2110c40c201908108208ca148120cc10430806');
it('gene quality pure 2', () => {
expect(axieGeneP2.getGeneQuality()).toBe(35.33);
});
})

0 comments on commit 63f99e4

Please sign in to comment.