Skip to content
Snippets Groups Projects
Commit 7e0456c1 authored by emelko's avatar emelko
Browse files

Adding unit tests to all possible mucus feeling/texture combinations

parent 9ab4bd0d
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,7 @@ import { ...@@ -12,6 +12,7 @@ import {
mucusFeeling as feelingLabels, mucusFeeling as feelingLabels,
mucusTexture as textureLabels mucusTexture as textureLabels
} from '../labels/labels' } from '../labels/labels'
import computeSensiplanValue from '../lib/sensiplan-mucus'
export default class Mucus extends Component { export default class Mucus extends Component {
constructor(props) { constructor(props) {
...@@ -137,11 +138,11 @@ export default class Mucus extends Component { ...@@ -137,11 +138,11 @@ export default class Mucus extends Component {
saveMucus(this.cycleDay, { saveMucus(this.cycleDay, {
feeling: this.state.currentFeelingValue, feeling: this.state.currentFeelingValue,
texture: this.state.currentTextureValue, texture: this.state.currentTextureValue,
computedValue: computeSensiplanValue(this.state.currentFeelingValue, this.state.currentTextureValue),
exclude: this.state.exclude exclude: this.state.exclude
}) })
this.showView('dayView') 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 } disabled={ this.state.currentFeelingValue === -1 || this.state.currentTextureValue === -1 }
title="Save"> title="Save">
</Button> </Button>
......
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)
}
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)
})
})
})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment