Adding unit tests to all possible mucus feeling/texture combinations
This commit is contained in:
+2
-1
@@ -12,6 +12,7 @@ import {
|
||||
mucusFeeling as feelingLabels,
|
||||
mucusTexture as textureLabels
|
||||
} from '../labels/labels'
|
||||
import computeSensiplanValue from '../lib/sensiplan-mucus'
|
||||
|
||||
export default class Mucus extends Component {
|
||||
constructor(props) {
|
||||
@@ -137,11 +138,11 @@ export default class Mucus extends Component {
|
||||
saveMucus(this.cycleDay, {
|
||||
feeling: this.state.currentFeelingValue,
|
||||
texture: this.state.currentTextureValue,
|
||||
computedValue: computeSensiplanValue(this.state.currentFeelingValue, this.state.currentTextureValue),
|
||||
exclude: this.state.exclude
|
||||
})
|
||||
this.showView('dayView')
|
||||
}}
|
||||
// FIXME: find out how disabled works when 2 values need to be checked
|
||||
disabled={ this.state.currentFeelingValue === -1 || this.state.currentTextureValue === -1 }
|
||||
title="Save">
|
||||
</Button>
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
export default function (feeling, texture) {
|
||||
const feelingMapping = {
|
||||
0: 0,
|
||||
1: 1,
|
||||
2: 2,
|
||||
3: 4
|
||||
}
|
||||
const textureMapping = {
|
||||
0: 0,
|
||||
1: 3,
|
||||
2: 4
|
||||
}
|
||||
const nfpFeelingValue = feelingMapping[feeling]
|
||||
const nfpTextureValue = textureMapping[texture]
|
||||
return Math.max(nfpFeelingValue, nfpTextureValue)
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
import chai from 'chai'
|
||||
import dirtyChai from 'dirty-chai'
|
||||
|
||||
const expect = chai.expect
|
||||
chai.use(dirtyChai)
|
||||
|
||||
import getSensiplanMucus from '../lib/sensiplan-mucus'
|
||||
|
||||
describe.only('getSensiplanMucus', () => {
|
||||
|
||||
describe('results in t for:', () => {
|
||||
it('dry feeling and no texture', function () {
|
||||
const sensiplanValue = getSensiplanMucus(0, 0)
|
||||
expect(sensiplanValue).to.eql(0)
|
||||
})
|
||||
})
|
||||
|
||||
describe('results in Ø for:', () => {
|
||||
it('no feeling and no texture', function () {
|
||||
const sensiplanValue = getSensiplanMucus(1, 0)
|
||||
expect(sensiplanValue).to.eql(1)
|
||||
})
|
||||
})
|
||||
|
||||
describe('results in f for:', () => {
|
||||
it('wet feeling and no texture', function () {
|
||||
const sensiplanValue = getSensiplanMucus(2, 0)
|
||||
expect(sensiplanValue).to.eql(2)
|
||||
})
|
||||
})
|
||||
|
||||
describe('results in S for:', () => {
|
||||
it('dry feeling and creamy texture', function () {
|
||||
const sensiplanValue = getSensiplanMucus(0, 1)
|
||||
expect(sensiplanValue).to.eql(3)
|
||||
})
|
||||
|
||||
it('no feeling and creamy texture', function () {
|
||||
const sensiplanValue = getSensiplanMucus(1, 1)
|
||||
expect(sensiplanValue).to.eql(3)
|
||||
})
|
||||
|
||||
it('wet feeling and creamy texture', function () {
|
||||
const sensiplanValue = getSensiplanMucus(2, 1)
|
||||
expect(sensiplanValue).to.eql(3)
|
||||
})
|
||||
})
|
||||
|
||||
describe('results in +S for:', () => {
|
||||
it('dry feeling and egg white texture', function () {
|
||||
const sensiplanValue = getSensiplanMucus(0, 2)
|
||||
expect(sensiplanValue).to.eql(4)
|
||||
})
|
||||
|
||||
it('no feeling and egg white texture', function () {
|
||||
const sensiplanValue = getSensiplanMucus(1, 2)
|
||||
expect(sensiplanValue).to.eql(4)
|
||||
})
|
||||
|
||||
it('wet feeling and egg white texture', function () {
|
||||
const sensiplanValue = getSensiplanMucus(2, 2)
|
||||
expect(sensiplanValue).to.eql(4)
|
||||
})
|
||||
|
||||
it('slippery feeling and egg white texture', function () {
|
||||
const sensiplanValue = getSensiplanMucus(3, 2)
|
||||
expect(sensiplanValue).to.eql(4)
|
||||
})
|
||||
|
||||
it('slippery feeling and creamy texture', function () {
|
||||
const sensiplanValue = getSensiplanMucus(3, 1)
|
||||
expect(sensiplanValue).to.eql(4)
|
||||
})
|
||||
|
||||
it('slippery feeling and no texture', function () {
|
||||
const sensiplanValue = getSensiplanMucus(3, 0)
|
||||
expect(sensiplanValue).to.eql(4)
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user