1
+ import { mockStrings } from "../../strings" ;
2
+
1
3
import { generateExamples , shouldShowExamples , unionAnswerForms } from "./utils" ;
2
4
3
- import type { PerseusStrings } from "../../strings" ;
4
5
import type { PerseusNumericInputAnswerForm } from "@khanacademy/perseus-core" ;
5
6
6
7
describe ( "generateExamples" , ( ) => {
@@ -16,23 +17,15 @@ describe("generateExamples", () => {
16
17
simplify : "required" ,
17
18
} ,
18
19
] ;
19
- const fakePerseusStrings : Partial < PerseusStrings > = {
20
- yourAnswer : "Your answer" ,
21
- integerExample : "Integer example" ,
22
- properExample : "Proper example" ,
23
- simplifiedProperExample : "Simplified proper example" ,
24
- } ;
20
+
25
21
const expected = [
26
- "Your answer" ,
27
- "Integer example " ,
28
- "Simplified proper example " ,
22
+ "** Your answer should be** " ,
23
+ "an integer, like $6$ " ,
24
+ "a *simplified proper* fraction, like $3/5$ " ,
29
25
] ;
30
26
31
27
// Act
32
- const result = generateExamples (
33
- answerForms ,
34
- fakePerseusStrings as PerseusStrings ,
35
- ) ;
28
+ const result = generateExamples ( answerForms , mockStrings ) ;
36
29
37
30
// Assert
38
31
expect ( result ) . toEqual ( expected ) ;
@@ -54,23 +47,15 @@ describe("generateExamples", () => {
54
47
simplify : "required" ,
55
48
} ,
56
49
] ;
57
- const fakePerseusStrings : Partial < PerseusStrings > = {
58
- yourAnswer : "Your answer" ,
59
- integerExample : "Integer example" ,
60
- properExample : "Proper example" ,
61
- simplifiedProperExample : "Simplified proper example" ,
62
- } ;
50
+
63
51
const expected = [
64
- "Your answer" ,
65
- "Integer example " ,
66
- "Simplified proper example " ,
52
+ "** Your answer should be** " ,
53
+ "an integer, like $6$ " ,
54
+ "a *simplified proper* fraction, like $3/5$ " ,
67
55
] ;
68
56
69
57
// Act
70
- const result = generateExamples (
71
- answerForms ,
72
- fakePerseusStrings as PerseusStrings ,
73
- ) ;
58
+ const result = generateExamples ( answerForms , mockStrings ) ;
74
59
75
60
// Assert
76
61
expect ( result ) . toEqual ( expected ) ;
@@ -79,19 +64,11 @@ describe("generateExamples", () => {
79
64
it ( "returns an empty array if no answer forms are provided" , ( ) => {
80
65
// Arrange
81
66
const answerForms : readonly PerseusNumericInputAnswerForm [ ] = [ ] ;
82
- const fakePerseusStrings : Partial < PerseusStrings > = {
83
- yourAnswer : "Your answer" ,
84
- integerExample : "Integer example" ,
85
- properExample : "Proper example" ,
86
- simplifiedProperExample : "Simplified proper example" ,
87
- } ;
67
+
88
68
const expected = [ ] ;
89
69
90
70
// Act
91
- const result = generateExamples (
92
- answerForms ,
93
- fakePerseusStrings as PerseusStrings ,
94
- ) ;
71
+ const result = generateExamples ( answerForms , mockStrings ) ;
95
72
96
73
// Assert
97
74
expect ( result ) . toEqual ( expected ) ;
0 commit comments