-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes: Can have blanks in addends #17
- Loading branch information
Showing
11 changed files
with
337 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import AdditionSentence, { BlankPosition } from './AdditionSentence'; | ||
import Addition from './Addition'; | ||
|
||
describe('AdditionSentence', () => { | ||
const element = () => document.querySelector('.addition-sentence-item'); | ||
|
||
describe('default behavior', () => { | ||
beforeEach(() => { | ||
const addition = new Addition(1, 2); | ||
return render( | ||
<AdditionSentence addition={addition} />, | ||
); | ||
}); | ||
|
||
it('renders addition sentence', () => { | ||
expect(element()).toHaveTextContent(/1 \+ 2 = _/); | ||
}); | ||
}); | ||
|
||
describe('when showAnswer is true', () => { | ||
beforeEach(() => render( | ||
<AdditionSentence showAnswer addition={new Addition(3, 4)} />, | ||
)); | ||
|
||
it('renders the answer instead of blank', () => { | ||
expect(element()).toHaveTextContent(/3 \+ 4 = 7/); | ||
}); | ||
}); | ||
|
||
describe('blanks', () => { | ||
const blanks: Record<BlankPosition, RegExp> = { | ||
addendA: /_+ \+ 6 = 11/, | ||
addendB: /5 \+ _+ = 11/, | ||
sum: /5 \+ 6 = _+/, | ||
}; | ||
|
||
Object.entries(blanks).forEach(([blank, content]) => { | ||
describe(`when blank=${blank}`, () => { | ||
beforeEach(() => render( | ||
<AdditionSentence | ||
blank={blank as BlankPosition} | ||
addition={new Addition(5, 6)} | ||
/>, | ||
)); | ||
|
||
it('blanks correct position', () => { | ||
expect(element()).toHaveTextContent(content); | ||
}); | ||
}); | ||
|
||
describe(`when blank=${blank} but showAnswer=true`, () => { | ||
beforeEach(() => render( | ||
<AdditionSentence | ||
showAnswer | ||
blank={blank as BlankPosition} | ||
addition={new Addition(5, 6)} | ||
/>, | ||
)); | ||
|
||
it('displays everything when show answer is enabled', () => { | ||
expect(element()).toHaveTextContent(/5 \+ 6 = 11/); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
export type BlankPositionStrategy = 'sum' | 'addends' | 'random'; | ||
export default interface AftbData { | ||
rangeFrom: number; | ||
rangeTo: number; | ||
problems: number; | ||
blankStrategy: BlankPositionStrategy; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.