`,
+ { pagePadding: false }
+ );
+
+ await testDiff(fixtureElement, test.focusGradesButton, test.focusReportsButton);
+ });
+ });
+
+});
diff --git a/test/components/grade-result/d2l-grade-result-student-grade-preview.vdiff.js b/test/components/grade-result/d2l-grade-result-student-grade-preview.vdiff.js
new file mode 100644
index 00000000..4e374c20
--- /dev/null
+++ b/test/components/grade-result/d2l-grade-result-student-grade-preview.vdiff.js
@@ -0,0 +1,268 @@
+import '../../../src/components/grade-result/grade-result-student-grade-preview.js';
+import '../../../src/components/grade-result/grade-result-presentational.js';
+import { expect, fixture, html } from '@brightspace-ui/testing';
+
+describe('student-grade-preview', () => {
+
+ const tests = [
+ {
+ name: 'none',
+ outOf: 10
+ },
+ {
+ name: 'no-display-options',
+ outOf: 10,
+ displayStudentGradePreview: true,
+ studentGradePreview: '{}'
+ },
+ {
+ name: 'select-box-symbol',
+ outOf: 10,
+ displayStudentGradePreview: true,
+ studentGradePreview: '{"score":10, "symbol":"Very Good", "colour":"#00FFFF"}'
+ },
+ {
+ name: 'percentage-symbol',
+ outOf: 10,
+ displayStudentGradePreview: true,
+ studentGradePreview: '{"score":9, "symbol":"90 %", "colour":"#AAAAFF"}'
+ },
+ {
+ name: 'score-and-symbol-only',
+ outOf: 10,
+ displayStudentGradePreview: true,
+ studentGradePreview: '{"score":2, "symbol":"Bad"}'
+ },
+ {
+ name: 'score-and-colour-only',
+ outOf: 10,
+ displayStudentGradePreview: true,
+ studentGradePreview: '{"score":10, "colour":"#11FF11"}'
+ },
+ {
+ name: 'symbol-and-colour-only',
+ outOf: 10,
+ displayStudentGradePreview: true,
+ studentGradePreview: '{"symbol":"11 %", "colour":"#666666"}'
+ },
+ {
+ name: 'score-only',
+ outOf: 10,
+ displayStudentGradePreview: true,
+ studentGradePreview: '{"score":7}'
+ },
+ {
+ name: 'symbol-only',
+ outOf: 10,
+ displayStudentGradePreview: true,
+ studentGradePreview: '{"symbol":"A+"}'
+ },
+ {
+ name: 'colour-only',
+ outOf: 10,
+ displayStudentGradePreview: true,
+ studentGradePreview: '{"colour":"#FFAAAA"}'
+ },
+ {
+ name: 'null-values',
+ outOf: 10,
+ displayStudentGradePreview: true,
+ studentGradePreview: '{"score":null, "symbol":"-%", "colour":""}'
+ },
+ {
+ name: 'hide-label',
+ hideLabel: true,
+ outOf: 10,
+ displayStudentGradePreview: true,
+ studentGradePreview: '{"score":9, "symbol":"90 %", "colour":"#AAAAFF"}'
+ },
+ {
+ name: 'hide-student-grade-preview',
+ hideLabel: false,
+ outOf: 10,
+ displayStudentGradePreview: false,
+ studentGradePreview: '{"score":9, "symbol":"90 %", "colour":"#AAAAFF"}'
+ },
+ ];
+
+ tests.forEach((test) => {
+ it(`${test.name}`, async() => {
+ const el = await fixture(
+ html`
+
+ `
+ );
+
+ await expect(el).to.be.golden();
+ });
+ });
+
+});
+
+describe('presentational-with-grade-preview', () => {
+
+ const tests = [
+ {
+ name: 'write-numeric',
+ gradeType: 'Numeric',
+ labelText: 'Overall Grade',
+ scoreNumerator: '5',
+ scoreDenominator: '20',
+ includeGradeButton: true,
+ includeReportsButton: true,
+ readOnly: false,
+ displayStudentGradePreview: true,
+ studentGradePreview: '{"score":5, "symbol":"Fine", "colour":"#FFCC00"}'
+ },
+ {
+ name: 'write-letter',
+ gradeType: 'LetterGrade',
+ labelText: 'Overall Grade',
+ letterGradeOptions: '{ "0": { "LetterGrade": "None", "PercentStart": null}, "1": { "LetterGrade": "A", "PercentStart": "75"}, "2": { "LetterGrade": "B", "PercentStart": "50"}}',
+ selectedLetterGrade: '2',
+ scoreDenominator: '5',
+ includeGradeButton: true,
+ includeReportsButton: true,
+ readOnly: false,
+ displayStudentGradePreview: true,
+ studentGradePreview: '{"score":5, "symbol":"B", "colour":"#00FF00"}'
+ },
+ {
+ name: 'readonly-numeric',
+ gradeType: 'Numeric',
+ labelText: 'Overall Grade',
+ scoreNumerator: '5',
+ scoreDenominator: '20',
+ includeGradeButton: true,
+ includeReportsButton: true,
+ readOnly: true,
+ displayStudentGradePreview: true,
+ studentGradePreview: '{"score":5, "symbol":"Fine", "colour":"#FFCC00"}'
+ },
+ {
+ name: 'readonly-letter',
+ gradeType: 'LetterGrade',
+ labelText: 'Overall Grade',
+ letterGradeOptions: '{ "0": { "LetterGrade": "None", "PercentStart": null}, "1": { "LetterGrade": "A", "PercentStart": "75"}, "2": { "LetterGrade": "B", "PercentStart": "50"}}',
+ selectedLetterGrade: '2',
+ scoreDenominator: '5',
+ includeGradeButton: true,
+ includeReportsButton: true,
+ readOnly: true,
+ displayStudentGradePreview: true,
+ studentGradePreview: '{"score":5, "symbol":"B", "colour":"#00FF00"}'
+ },
+ {
+ name: 'readonly-letter-long-letter',
+ gradeType: 'LetterGrade',
+ labelText: 'Overall Grade',
+ letterGradeOptions: '{ "0": { "LetterGrade": "None", "PercentStart": null}, "1": { "LetterGrade": "A", "PercentStart": "75"}, "2": { "LetterGrade": "This is a really really really really really long letter grade", "PercentStart": "50"}}',
+ selectedLetterGrade: '2',
+ scoreDenominator: '5',
+ includeGradeButton: true,
+ includeReportsButton: true,
+ readOnly: true,
+ displayStudentGradePreview: true,
+ studentGradePreview: '{"score":5, "symbol":"B", "colour":"#00FF00"}'
+ },
+ {
+ name: 'manual-override',
+ gradeType: 'Numeric',
+ labelText: 'Overall Grade',
+ scoreNumerator: '5',
+ scoreDenominator: '20',
+ isGradeAutoCompleted: true,
+ isManualOverrideActive: true,
+ includeGradeButton: true,
+ includeReportsButton: true,
+ readOnly: false,
+ displayStudentGradePreview: true,
+ studentGradePreview: '{"score":5, "symbol":"Fine", "colour":"#FFCC00"}'
+ },
+ {
+ name: 'grade-calculation',
+ gradeType: 'Numeric',
+ labelText: 'Overall Grade',
+ scoreNumerator: '5',
+ scoreDenominator: '20',
+ isGradeAutoCompleted: false,
+ isManualOverrideActive: false,
+ includeGradeButton: true,
+ includeReportsButton: true,
+ readOnly: true,
+ subtitleText: 'Average post score',
+ displayStudentGradePreview: true,
+ studentGradePreview: '{"score":5, "symbol":"Fine", "colour":"#FFCC00"}'
+ },
+ {
+ name: 'negative-score-hint',
+ gradeType: 'Numeric',
+ labelText: 'Attempt Grade',
+ scoreNumerator: '0',
+ scoreDenominator: '20',
+ showFlooredScoreWarning: true,
+ isGradeAutoCompleted: false,
+ isManualOverrideActive: false,
+ includeGradeButton: true,
+ includeReportsButton: true,
+ readOnly: false,
+ displayStudentGradePreview: true,
+ studentGradePreview: '{"score":5, "symbol":"Fine", "colour":"#FFCC00"}'
+ },
+ {
+ name: 'grade-not-shown-to-learners',
+ gradeType: 'Numeric',
+ labelText: 'Overall Grade',
+ scoreNumerator: '5',
+ scoreDenominator: '20',
+ includeGradeButton: true,
+ includeReportsButton: true,
+ readOnly: false,
+ displayStudentGradePreview: true,
+ studentGradePreview: '{}'
+ },
+ ];
+
+ const screenSizeCategories = [
+ { name: 'desktop', viewport: { height: 800, width: 700 } },
+ { name: 'mobile', viewport: { height: 800, width: 400 } }
+ ];
+
+ screenSizeCategories.forEach((screenSizeCategory) => {
+ describe(screenSizeCategory.name, () => {
+ tests.forEach((test) => {
+ it(`${test.name}`, async() => {
+ const el = await fixture(
+ html`
+
+ `, { viewport: screenSizeCategory.viewport }
+ );
+
+ await expect(el).to.be.golden();
+ });
+ });
+ });
+ });
+
+});
diff --git a/test/components/grade-result/d2l-grade-result-write-enabled.vdiff.js b/test/components/grade-result/d2l-grade-result-write-enabled.vdiff.js
new file mode 100644
index 00000000..25a9f237
--- /dev/null
+++ b/test/components/grade-result/d2l-grade-result-write-enabled.vdiff.js
@@ -0,0 +1,171 @@
+import '../../../src/components/grade-result/grade-result-presentational.js';
+import { fixture, html } from '@brightspace-ui/testing';
+import { testDiff } from './vdiff-utils.js';
+
+describe('write enabled visual diff tests', () => {
+
+ const tests = [
+ {
+ name: 'write-enabled-number-grade-no-icons',
+ gradeType: 'Numeric',
+ labelText: 'Overall Grade',
+ scoreNumerator: 5,
+ scoreDenominator: 20
+ },
+ {
+ name: 'write-enabled-number-decimal-grade-no-icons',
+ gradeType: 'Numeric',
+ labelText: 'Overall Grade',
+ scoreNumerator: 1.55555,
+ scoreDenominator: 20
+ },
+ {
+ name: 'write-enabled-number-grade-icons',
+ gradeType: 'Numeric',
+ labelText: 'Overall Grade',
+ scoreNumerator: 5,
+ scoreDenominator: 20,
+ includeGradeButton: true,
+ includeReportsButton: true
+ },
+ {
+ name: 'write-enabled-number-grade-icons-tooltips-grade',
+ gradeType: 'Numeric',
+ labelText: 'Overall Grade',
+ scoreNumerator: 5,
+ scoreDenominator: 20,
+ gradeButtonTooltip: 'Assignment 1 Grade Item Attached',
+ reportsButtonTooltip: 'Class and user statistics',
+ includeGradeButton: true,
+ includeReportsButton: true,
+ focusGradesButton: true
+ },
+ {
+ name: 'write-enabled-number-grade-icons-tooltips-reports',
+ gradeType: 'Numeric',
+ labelText: 'Overall Grade',
+ scoreNumerator: 5,
+ scoreDenominator: 20,
+ gradeButtonTooltip: 'Assignment 1 Grade Item Attached',
+ reportsButtonTooltip: 'Class and user statistics',
+ includeGradeButton: true,
+ includeReportsButton: true,
+ focusReportsButton: true
+ },
+ {
+ name: 'write-enabled-number-range-validation-error',
+ gradeType: 'Numeric',
+ labelText: 'Overall Grade',
+ scoreNumerator: -2,
+ scoreDenominator: 20
+ },
+ {
+ name: 'write-enabled-number-range-validation-error-tooltip',
+ gradeType: 'Numeric',
+ labelText: 'Overall Grade',
+ scoreNumerator: -2,
+ scoreDenominator: 20,
+ focusInputBox: true
+ },
+ {
+ name: 'write-enabled-number-negative-marking-enabled',
+ gradeType: 'Numeric',
+ labelText: 'Overall Grade',
+ scoreNumerator: -2,
+ scoreDenominator: 20,
+ allowNegativeScore: true
+ },
+ {
+ name: 'write-enabled-negative-grade-warning',
+ gradeType: 'Numeric',
+ labelText: 'Attempt Grade',
+ scoreNumerator: 0,
+ scoreDenominator: 20,
+ showFlooredScoreWarning: true,
+ focusInputBox: true
+ },
+ {
+ name: 'write-enabled-negative-grade-warning-icons',
+ gradeType: 'Numeric',
+ labelText: 'Attempt Grade',
+ scoreNumerator: 0,
+ scoreDenominator: 20,
+ includeGradeButton: true,
+ includeReportsButton: true,
+ showFlooredScoreWarning: true,
+ focusInputBox: true
+ },
+ {
+ name: 'write-enabled-number-dynamic-width',
+ gradeType: 'Numeric',
+ labelText: 'Overall Grade',
+ scoreNumerator: 33333333,
+ scoreDenominator: 33333333
+ },
+ {
+ name: 'write-enabled-letter-grade-no-icons',
+ gradeType: 'LetterGrade',
+ labelText: 'Overall Grade',
+ letterGradeOptions: { '0': { 'LetterGrade': 'None', 'PercentStart': null }, '1': { 'LetterGrade': 'A', 'PercentStart': '75' }, '2': { 'LetterGrade': 'B', 'PercentStart': '50' } },
+ selectedLetterGrade: '2'
+ },
+ {
+ name: 'write-enabled-letter-grade-icons',
+ gradeType: 'LetterGrade',
+ labelText: 'Overall Grade',
+ letterGradeOptions: { '0': { 'LetterGrade': 'None', 'PercentStart': null }, '1': { 'LetterGrade': 'A', 'PercentStart': '75' }, '2': { 'LetterGrade': 'B', 'PercentStart': '50' } },
+ includeGradeButton: true,
+ includeReportsButton: true
+ },
+ {
+ name: 'write-enabled-letter-grade-icons-tooltips-grades',
+ gradeType: 'LetterGrade',
+ labelText: 'Overall Grade',
+ letterGradeOptions: { '0': { 'LetterGrade': 'None', 'PercentStart': null }, '1': { 'LetterGrade': 'A', 'PercentStart': '75' }, '2': { 'LetterGrade': 'B', 'PercentStart': '50' } },
+ gradeButtonTooltip: 'Assignment 1 Grade Item Attached',
+ reportsButtonTooltip: 'Class and user statistics',
+ includeGradeButton: true,
+ includeReportsButton: true,
+ focusGradesButton: true
+ },
+ {
+ name: 'write-enabled-letter-grade-icons-tooltips-reports',
+ gradeType: 'LetterGrade',
+ labelText: 'Overall Grade',
+ letterGradeOptions: { '0': { 'LetterGrade': 'None', 'PercentStart': null }, '1': { 'LetterGrade': 'A', 'PercentStart': '75' }, '2': { 'LetterGrade': 'B', 'PercentStart': '50' } },
+ gradeButtonTooltip: 'Assignment 1 Grade Item Attached',
+ reportsButtonTooltip: 'Class and user statistics',
+ includeGradeButton: true,
+ includeReportsButton: true,
+ focusReportsButton: true
+ }
+ ];
+
+ tests.forEach((test) => {
+ it(`${test.name}`, async() => {
+ const fixtureElement = await fixture(
+ html`
+
+
+
`,
+ { pagePadding: false }
+ );
+
+ await testDiff(fixtureElement, test.focusGradesButton, test.focusReportsButton, test.focusInputBox);
+ });
+ });
+
+});
diff --git a/test/components/grade-result/golden/autograde/chromium/provided-visual-diff-tests-autograde-provided-letter-grade-icons-clear-manual-override-option.png b/test/components/grade-result/golden/autograde/chromium/provided-visual-diff-tests-autograde-provided-letter-grade-icons-clear-manual-override-option.png
new file mode 100644
index 00000000..527a84ca
Binary files /dev/null and b/test/components/grade-result/golden/autograde/chromium/provided-visual-diff-tests-autograde-provided-letter-grade-icons-clear-manual-override-option.png differ
diff --git a/test/components/grade-result/golden/autograde/chromium/provided-visual-diff-tests-autograde-provided-letter-grade-icons-tooltips-clear-manual-override-option-grades.png b/test/components/grade-result/golden/autograde/chromium/provided-visual-diff-tests-autograde-provided-letter-grade-icons-tooltips-clear-manual-override-option-grades.png
new file mode 100644
index 00000000..0428a02f
Binary files /dev/null and b/test/components/grade-result/golden/autograde/chromium/provided-visual-diff-tests-autograde-provided-letter-grade-icons-tooltips-clear-manual-override-option-grades.png differ
diff --git a/test/components/grade-result/golden/autograde/chromium/provided-visual-diff-tests-autograde-provided-letter-grade-icons-tooltips-clear-manual-override-option-reports.png b/test/components/grade-result/golden/autograde/chromium/provided-visual-diff-tests-autograde-provided-letter-grade-icons-tooltips-clear-manual-override-option-reports.png
new file mode 100644
index 00000000..6e43cd04
Binary files /dev/null and b/test/components/grade-result/golden/autograde/chromium/provided-visual-diff-tests-autograde-provided-letter-grade-icons-tooltips-clear-manual-override-option-reports.png differ
diff --git a/test/components/grade-result/golden/autograde/chromium/provided-visual-diff-tests-autograde-provided-letter-grade-no-icons-clear-manual-override-option.png b/test/components/grade-result/golden/autograde/chromium/provided-visual-diff-tests-autograde-provided-letter-grade-no-icons-clear-manual-override-option.png
new file mode 100644
index 00000000..2835cb83
Binary files /dev/null and b/test/components/grade-result/golden/autograde/chromium/provided-visual-diff-tests-autograde-provided-letter-grade-no-icons-clear-manual-override-option.png differ
diff --git a/test/components/grade-result/golden/autograde/chromium/provided-visual-diff-tests-autograde-provided-number-grade-icons-clear-manual-override-option.png b/test/components/grade-result/golden/autograde/chromium/provided-visual-diff-tests-autograde-provided-number-grade-icons-clear-manual-override-option.png
new file mode 100644
index 00000000..84cc074f
Binary files /dev/null and b/test/components/grade-result/golden/autograde/chromium/provided-visual-diff-tests-autograde-provided-number-grade-icons-clear-manual-override-option.png differ
diff --git a/test/components/grade-result/golden/autograde/chromium/provided-visual-diff-tests-autograde-provided-number-grade-icons-tooltips-clear-manual-override-option-grades.png b/test/components/grade-result/golden/autograde/chromium/provided-visual-diff-tests-autograde-provided-number-grade-icons-tooltips-clear-manual-override-option-grades.png
new file mode 100644
index 00000000..540a7600
Binary files /dev/null and b/test/components/grade-result/golden/autograde/chromium/provided-visual-diff-tests-autograde-provided-number-grade-icons-tooltips-clear-manual-override-option-grades.png differ
diff --git a/test/components/grade-result/golden/autograde/chromium/provided-visual-diff-tests-autograde-provided-number-grade-icons-tooltips-clear-manual-override-option-reports.png b/test/components/grade-result/golden/autograde/chromium/provided-visual-diff-tests-autograde-provided-number-grade-icons-tooltips-clear-manual-override-option-reports.png
new file mode 100644
index 00000000..ddc906e6
Binary files /dev/null and b/test/components/grade-result/golden/autograde/chromium/provided-visual-diff-tests-autograde-provided-number-grade-icons-tooltips-clear-manual-override-option-reports.png differ
diff --git a/test/components/grade-result/golden/autograde/chromium/provided-visual-diff-tests-autograde-provided-number-grade-no-icons-clear-manual-override-option.png b/test/components/grade-result/golden/autograde/chromium/provided-visual-diff-tests-autograde-provided-number-grade-no-icons-clear-manual-override-option.png
new file mode 100644
index 00000000..bdccba4b
Binary files /dev/null and b/test/components/grade-result/golden/autograde/chromium/provided-visual-diff-tests-autograde-provided-number-grade-no-icons-clear-manual-override-option.png differ
diff --git a/test/components/grade-result/golden/optional/chromium/override-text-substitution-visual-diff-tests-custom-manual-override-clear-text.png b/test/components/grade-result/golden/optional/chromium/override-text-substitution-visual-diff-tests-custom-manual-override-clear-text.png
new file mode 100644
index 00000000..e0490f24
Binary files /dev/null and b/test/components/grade-result/golden/optional/chromium/override-text-substitution-visual-diff-tests-custom-manual-override-clear-text.png differ
diff --git a/test/components/grade-result/golden/presentational-with-grade-preview/chromium/desktop-grade-calculation.png b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/desktop-grade-calculation.png
new file mode 100644
index 00000000..36c69cba
Binary files /dev/null and b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/desktop-grade-calculation.png differ
diff --git a/test/components/grade-result/golden/presentational-with-grade-preview/chromium/desktop-grade-not-shown-to-learners.png b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/desktop-grade-not-shown-to-learners.png
new file mode 100644
index 00000000..a258ace1
Binary files /dev/null and b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/desktop-grade-not-shown-to-learners.png differ
diff --git a/test/components/grade-result/golden/presentational-with-grade-preview/chromium/desktop-manual-override.png b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/desktop-manual-override.png
new file mode 100644
index 00000000..9f8a1d4f
Binary files /dev/null and b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/desktop-manual-override.png differ
diff --git a/test/components/grade-result/golden/presentational-with-grade-preview/chromium/desktop-negative-score-hint.png b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/desktop-negative-score-hint.png
new file mode 100644
index 00000000..da186aab
Binary files /dev/null and b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/desktop-negative-score-hint.png differ
diff --git a/test/components/grade-result/golden/presentational-with-grade-preview/chromium/desktop-readonly-letter-long-letter.png b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/desktop-readonly-letter-long-letter.png
new file mode 100644
index 00000000..229da2ea
Binary files /dev/null and b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/desktop-readonly-letter-long-letter.png differ
diff --git a/test/components/grade-result/golden/presentational-with-grade-preview/chromium/desktop-readonly-letter.png b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/desktop-readonly-letter.png
new file mode 100644
index 00000000..fce3cd47
Binary files /dev/null and b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/desktop-readonly-letter.png differ
diff --git a/test/components/grade-result/golden/presentational-with-grade-preview/chromium/desktop-readonly-numeric.png b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/desktop-readonly-numeric.png
new file mode 100644
index 00000000..19b21edb
Binary files /dev/null and b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/desktop-readonly-numeric.png differ
diff --git a/test/components/grade-result/golden/presentational-with-grade-preview/chromium/desktop-write-letter.png b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/desktop-write-letter.png
new file mode 100644
index 00000000..b3aa1b29
Binary files /dev/null and b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/desktop-write-letter.png differ
diff --git a/test/components/grade-result/golden/presentational-with-grade-preview/chromium/desktop-write-numeric.png b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/desktop-write-numeric.png
new file mode 100644
index 00000000..38b86638
Binary files /dev/null and b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/desktop-write-numeric.png differ
diff --git a/test/components/grade-result/golden/presentational-with-grade-preview/chromium/mobile-grade-calculation.png b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/mobile-grade-calculation.png
new file mode 100644
index 00000000..68977199
Binary files /dev/null and b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/mobile-grade-calculation.png differ
diff --git a/test/components/grade-result/golden/presentational-with-grade-preview/chromium/mobile-grade-not-shown-to-learners.png b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/mobile-grade-not-shown-to-learners.png
new file mode 100644
index 00000000..de51c2d4
Binary files /dev/null and b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/mobile-grade-not-shown-to-learners.png differ
diff --git a/test/components/grade-result/golden/presentational-with-grade-preview/chromium/mobile-manual-override.png b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/mobile-manual-override.png
new file mode 100644
index 00000000..c4df3da9
Binary files /dev/null and b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/mobile-manual-override.png differ
diff --git a/test/components/grade-result/golden/presentational-with-grade-preview/chromium/mobile-negative-score-hint.png b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/mobile-negative-score-hint.png
new file mode 100644
index 00000000..191f948d
Binary files /dev/null and b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/mobile-negative-score-hint.png differ
diff --git a/test/components/grade-result/golden/presentational-with-grade-preview/chromium/mobile-readonly-letter-long-letter.png b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/mobile-readonly-letter-long-letter.png
new file mode 100644
index 00000000..e4351187
Binary files /dev/null and b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/mobile-readonly-letter-long-letter.png differ
diff --git a/test/components/grade-result/golden/presentational-with-grade-preview/chromium/mobile-readonly-letter.png b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/mobile-readonly-letter.png
new file mode 100644
index 00000000..9454c8a8
Binary files /dev/null and b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/mobile-readonly-letter.png differ
diff --git a/test/components/grade-result/golden/presentational-with-grade-preview/chromium/mobile-readonly-numeric.png b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/mobile-readonly-numeric.png
new file mode 100644
index 00000000..8d6de8a3
Binary files /dev/null and b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/mobile-readonly-numeric.png differ
diff --git a/test/components/grade-result/golden/presentational-with-grade-preview/chromium/mobile-write-letter.png b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/mobile-write-letter.png
new file mode 100644
index 00000000..b30a3a6c
Binary files /dev/null and b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/mobile-write-letter.png differ
diff --git a/test/components/grade-result/golden/presentational-with-grade-preview/chromium/mobile-write-numeric.png b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/mobile-write-numeric.png
new file mode 100644
index 00000000..8e4c67a7
Binary files /dev/null and b/test/components/grade-result/golden/presentational-with-grade-preview/chromium/mobile-write-numeric.png differ
diff --git a/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-d2l-labs-d2l-grade-result-with-subtitle.png b/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-d2l-labs-d2l-grade-result-with-subtitle.png
new file mode 100644
index 00000000..491a363f
Binary files /dev/null and b/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-d2l-labs-d2l-grade-result-with-subtitle.png differ
diff --git a/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-letter-grade-icons-tooltips-grades.png b/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-letter-grade-icons-tooltips-grades.png
new file mode 100644
index 00000000..9c353f81
Binary files /dev/null and b/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-letter-grade-icons-tooltips-grades.png differ
diff --git a/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-letter-grade-icons-tooltips-reports.png b/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-letter-grade-icons-tooltips-reports.png
new file mode 100644
index 00000000..c37fa774
Binary files /dev/null and b/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-letter-grade-icons-tooltips-reports.png differ
diff --git a/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-letter-grade-icons.png b/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-letter-grade-icons.png
new file mode 100644
index 00000000..1ec15fa1
Binary files /dev/null and b/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-letter-grade-icons.png differ
diff --git a/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-letter-grade-no-icons.png b/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-letter-grade-no-icons.png
new file mode 100644
index 00000000..7a3c4f7e
Binary files /dev/null and b/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-letter-grade-no-icons.png differ
diff --git a/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-negative-grade-icons.png b/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-negative-grade-icons.png
new file mode 100644
index 00000000..50770a8b
Binary files /dev/null and b/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-negative-grade-icons.png differ
diff --git a/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-negative-grade-no-icons.png b/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-negative-grade-no-icons.png
new file mode 100644
index 00000000..831c60de
Binary files /dev/null and b/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-negative-grade-no-icons.png differ
diff --git a/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-number-decimal-grade-no-icons.png b/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-number-decimal-grade-no-icons.png
new file mode 100644
index 00000000..846f4a41
Binary files /dev/null and b/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-number-decimal-grade-no-icons.png differ
diff --git a/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-number-grade-empty-numerator.png b/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-number-grade-empty-numerator.png
new file mode 100644
index 00000000..872b0119
Binary files /dev/null and b/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-number-grade-empty-numerator.png differ
diff --git a/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-number-grade-icons-tooltips-grades.png b/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-number-grade-icons-tooltips-grades.png
new file mode 100644
index 00000000..5486ac39
Binary files /dev/null and b/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-number-grade-icons-tooltips-grades.png differ
diff --git a/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-number-grade-icons-tooltips-reports.png b/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-number-grade-icons-tooltips-reports.png
new file mode 100644
index 00000000..b86fe7c8
Binary files /dev/null and b/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-number-grade-icons-tooltips-reports.png differ
diff --git a/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-number-grade-icons.png b/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-number-grade-icons.png
new file mode 100644
index 00000000..2dd88715
Binary files /dev/null and b/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-number-grade-icons.png differ
diff --git a/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-number-grade-no-icons.png b/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-number-grade-no-icons.png
new file mode 100644
index 00000000..15fd3af9
Binary files /dev/null and b/test/components/grade-result/golden/read/chromium/only-visual-diff-tests-read-only-number-grade-no-icons.png differ
diff --git a/test/components/grade-result/golden/student-grade-preview/chromium/colour-only.png b/test/components/grade-result/golden/student-grade-preview/chromium/colour-only.png
new file mode 100644
index 00000000..b079db1c
Binary files /dev/null and b/test/components/grade-result/golden/student-grade-preview/chromium/colour-only.png differ
diff --git a/test/components/grade-result/golden/student-grade-preview/chromium/hide-label.png b/test/components/grade-result/golden/student-grade-preview/chromium/hide-label.png
new file mode 100644
index 00000000..0c13153e
Binary files /dev/null and b/test/components/grade-result/golden/student-grade-preview/chromium/hide-label.png differ
diff --git a/test/components/grade-result/golden/student-grade-preview/chromium/hide-student-grade-preview.png b/test/components/grade-result/golden/student-grade-preview/chromium/hide-student-grade-preview.png
new file mode 100644
index 00000000..78019f8c
Binary files /dev/null and b/test/components/grade-result/golden/student-grade-preview/chromium/hide-student-grade-preview.png differ
diff --git a/test/components/grade-result/golden/student-grade-preview/chromium/no-display-options.png b/test/components/grade-result/golden/student-grade-preview/chromium/no-display-options.png
new file mode 100644
index 00000000..1aff716a
Binary files /dev/null and b/test/components/grade-result/golden/student-grade-preview/chromium/no-display-options.png differ
diff --git a/test/components/grade-result/golden/student-grade-preview/chromium/none.png b/test/components/grade-result/golden/student-grade-preview/chromium/none.png
new file mode 100644
index 00000000..78019f8c
Binary files /dev/null and b/test/components/grade-result/golden/student-grade-preview/chromium/none.png differ
diff --git a/test/components/grade-result/golden/student-grade-preview/chromium/null-values.png b/test/components/grade-result/golden/student-grade-preview/chromium/null-values.png
new file mode 100644
index 00000000..d9fe2531
Binary files /dev/null and b/test/components/grade-result/golden/student-grade-preview/chromium/null-values.png differ
diff --git a/test/components/grade-result/golden/student-grade-preview/chromium/percentage-symbol.png b/test/components/grade-result/golden/student-grade-preview/chromium/percentage-symbol.png
new file mode 100644
index 00000000..7599f395
Binary files /dev/null and b/test/components/grade-result/golden/student-grade-preview/chromium/percentage-symbol.png differ
diff --git a/test/components/grade-result/golden/student-grade-preview/chromium/score-and-colour-only.png b/test/components/grade-result/golden/student-grade-preview/chromium/score-and-colour-only.png
new file mode 100644
index 00000000..6287c528
Binary files /dev/null and b/test/components/grade-result/golden/student-grade-preview/chromium/score-and-colour-only.png differ
diff --git a/test/components/grade-result/golden/student-grade-preview/chromium/score-and-symbol-only.png b/test/components/grade-result/golden/student-grade-preview/chromium/score-and-symbol-only.png
new file mode 100644
index 00000000..17476db9
Binary files /dev/null and b/test/components/grade-result/golden/student-grade-preview/chromium/score-and-symbol-only.png differ
diff --git a/test/components/grade-result/golden/student-grade-preview/chromium/score-only.png b/test/components/grade-result/golden/student-grade-preview/chromium/score-only.png
new file mode 100644
index 00000000..aebef4b3
Binary files /dev/null and b/test/components/grade-result/golden/student-grade-preview/chromium/score-only.png differ
diff --git a/test/components/grade-result/golden/student-grade-preview/chromium/select-box-symbol.png b/test/components/grade-result/golden/student-grade-preview/chromium/select-box-symbol.png
new file mode 100644
index 00000000..c6e8be97
Binary files /dev/null and b/test/components/grade-result/golden/student-grade-preview/chromium/select-box-symbol.png differ
diff --git a/test/components/grade-result/golden/student-grade-preview/chromium/symbol-and-colour-only.png b/test/components/grade-result/golden/student-grade-preview/chromium/symbol-and-colour-only.png
new file mode 100644
index 00000000..2df9bf15
Binary files /dev/null and b/test/components/grade-result/golden/student-grade-preview/chromium/symbol-and-colour-only.png differ
diff --git a/test/components/grade-result/golden/student-grade-preview/chromium/symbol-only.png b/test/components/grade-result/golden/student-grade-preview/chromium/symbol-only.png
new file mode 100644
index 00000000..58f54a29
Binary files /dev/null and b/test/components/grade-result/golden/student-grade-preview/chromium/symbol-only.png differ
diff --git a/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-letter-grade-icons-tooltips-grades.png b/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-letter-grade-icons-tooltips-grades.png
new file mode 100644
index 00000000..66f78327
Binary files /dev/null and b/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-letter-grade-icons-tooltips-grades.png differ
diff --git a/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-letter-grade-icons-tooltips-reports.png b/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-letter-grade-icons-tooltips-reports.png
new file mode 100644
index 00000000..a8fa69c2
Binary files /dev/null and b/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-letter-grade-icons-tooltips-reports.png differ
diff --git a/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-letter-grade-icons.png b/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-letter-grade-icons.png
new file mode 100644
index 00000000..446f8735
Binary files /dev/null and b/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-letter-grade-icons.png differ
diff --git a/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-letter-grade-no-icons.png b/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-letter-grade-no-icons.png
new file mode 100644
index 00000000..dba08f96
Binary files /dev/null and b/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-letter-grade-no-icons.png differ
diff --git a/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-negative-grade-warning-icons.png b/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-negative-grade-warning-icons.png
new file mode 100644
index 00000000..f7aa4a9e
Binary files /dev/null and b/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-negative-grade-warning-icons.png differ
diff --git a/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-negative-grade-warning.png b/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-negative-grade-warning.png
new file mode 100644
index 00000000..8f08a014
Binary files /dev/null and b/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-negative-grade-warning.png differ
diff --git a/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-number-decimal-grade-no-icons.png b/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-number-decimal-grade-no-icons.png
new file mode 100644
index 00000000..1e0f1e01
Binary files /dev/null and b/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-number-decimal-grade-no-icons.png differ
diff --git a/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-number-dynamic-width.png b/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-number-dynamic-width.png
new file mode 100644
index 00000000..c6c08a19
Binary files /dev/null and b/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-number-dynamic-width.png differ
diff --git a/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-number-grade-icons-tooltips-grade.png b/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-number-grade-icons-tooltips-grade.png
new file mode 100644
index 00000000..929375a0
Binary files /dev/null and b/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-number-grade-icons-tooltips-grade.png differ
diff --git a/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-number-grade-icons-tooltips-reports.png b/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-number-grade-icons-tooltips-reports.png
new file mode 100644
index 00000000..70a247fe
Binary files /dev/null and b/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-number-grade-icons-tooltips-reports.png differ
diff --git a/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-number-grade-icons.png b/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-number-grade-icons.png
new file mode 100644
index 00000000..8f10297a
Binary files /dev/null and b/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-number-grade-icons.png differ
diff --git a/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-number-grade-no-icons.png b/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-number-grade-no-icons.png
new file mode 100644
index 00000000..815bcc77
Binary files /dev/null and b/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-number-grade-no-icons.png differ
diff --git a/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-number-negative-marking-enabled.png b/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-number-negative-marking-enabled.png
new file mode 100644
index 00000000..af4e0ee2
Binary files /dev/null and b/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-number-negative-marking-enabled.png differ
diff --git a/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-number-range-validation-error-tooltip.png b/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-number-range-validation-error-tooltip.png
new file mode 100644
index 00000000..fd449807
Binary files /dev/null and b/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-number-range-validation-error-tooltip.png differ
diff --git a/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-number-range-validation-error.png b/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-number-range-validation-error.png
new file mode 100644
index 00000000..acf9463e
Binary files /dev/null and b/test/components/grade-result/golden/write/chromium/enabled-visual-diff-tests-write-enabled-number-range-validation-error.png differ
diff --git a/test/components/grade-result/utils.js b/test/components/grade-result/utils.js
new file mode 100644
index 00000000..a8cb94ef
--- /dev/null
+++ b/test/components/grade-result/utils.js
@@ -0,0 +1,35 @@
+export const getPresentationalComponent = (el) => {
+ return el.shadowRoot.querySelector('d2l-labs-d2l-grade-result-presentational');
+};
+
+export const getGradesButton = (el) => {
+ return el
+ .shadowRoot.querySelector('d2l-grade-result-icon-button')
+ .shadowRoot.querySelector('d2l-button-icon');
+};
+
+export const getReportsButton = (el) => {
+ return el
+ .shadowRoot.querySelectorAll('d2l-grade-result-icon-button')[1]
+ .shadowRoot.querySelector('d2l-button-icon');
+};
+
+export const getManualOverrideButton = (el) => {
+ return el.shadowRoot.querySelector('d2l-button-subtle');
+};
+
+export const getNumericScore = (el) => {
+ return el.shadowRoot.querySelector('d2l-grade-result-numeric-score');
+};
+
+export const getNumericScoreInput = (el) => {
+ return getNumericScore(el).shadowRoot.querySelector('d2l-input-number');
+};
+
+export const getLetterScore = (el) => {
+ return el.shadowRoot.querySelector('d2l-grade-result-letter-score');
+};
+
+export const getLetterScoreSelect = (el) => {
+ return getLetterScore(el).shadowRoot.querySelector('select');
+};
diff --git a/test/components/grade-result/vdiff-utils.js b/test/components/grade-result/vdiff-utils.js
new file mode 100644
index 00000000..947a61d3
--- /dev/null
+++ b/test/components/grade-result/vdiff-utils.js
@@ -0,0 +1,42 @@
+import { expect, focusElem } from '@brightspace-ui/testing';
+
+async function focusGradesButton(fixtureElement) {
+ const gradeButtonElement = fixtureElement
+ .querySelector('d2l-labs-d2l-grade-result-presentational')
+ .shadowRoot.querySelector('d2l-grade-result-icon-button')
+ .shadowRoot.querySelector('d2l-button-icon');
+
+ await focusElem(gradeButtonElement);
+}
+
+async function focusReportsButton(fixtureElement) {
+ const reportsButtonElement = fixtureElement
+ .querySelector('d2l-labs-d2l-grade-result-presentational')
+ .shadowRoot.querySelectorAll('d2l-grade-result-icon-button')[1]
+ .shadowRoot.querySelector('d2l-button-icon');
+
+ await focusElem(reportsButtonElement);
+}
+
+async function focusInputBox(fixtureElement) {
+ const inputBoxElement = fixtureElement
+ .querySelector('d2l-labs-d2l-grade-result-presentational')
+ .shadowRoot.querySelector('d2l-grade-result-numeric-score')
+ .shadowRoot.querySelector('d2l-input-number')
+ .shadowRoot.querySelector('d2l-input-text')
+ .shadowRoot.querySelector('input');
+
+ await focusElem(inputBoxElement);
+}
+
+export async function testDiff(fixtureElement, focusGrades, focusReports, focusInput) {
+ if (focusGrades) {
+ await focusGradesButton(fixtureElement);
+ } else if (focusReports) {
+ await focusReportsButton(fixtureElement);
+ } else if (focusInput) {
+ await focusInputBox(fixtureElement);
+ }
+
+ await expect(fixtureElement).to.be.golden();
+}
diff --git a/test/controllers/grade-result/Grade.test.js b/test/controllers/grade-result/Grade.test.js
new file mode 100644
index 00000000..e4738cd9
--- /dev/null
+++ b/test/controllers/grade-result/Grade.test.js
@@ -0,0 +1,368 @@
+import { Grade, GradeErrors, GradeType } from '../../../src/controllers/grade-result/Grade.js';
+import { assert } from '@brightspace-ui/testing';
+
+const letterGradeOptions = {
+ 0: { 'LetterGrade': 'None', 'PercentStart': null, 'AssignedValue': null },
+ 1: { 'LetterGrade': 'A', 'PercentStart': 80, 'AssignedValue': 80 },
+ 2: { 'LetterGrade': 'B', 'PercentStart': 65, 'AssignedValue': 65 },
+ 3: { 'LetterGrade': 'C', 'PercentStart': 50, 'AssignedValue': 50 },
+};
+
+describe('Grade tests', () => {
+ describe('properly calling constructor', () => {
+ it('initializes properly for a numeric score', () => {
+ const grade = new Grade(GradeType.Number, 10, 50, null, null);
+ assert.equal(grade.isLetterGrade(), false);
+ assert.equal(grade.isNumberGrade(), true);
+ assert.equal(grade.getScoreType(), GradeType.Number);
+ assert.equal(grade.getScore(), 10);
+ assert.equal(grade.getOutOf(), 50);
+ });
+
+ it('initializes properly for a numeric score (not overridden)', () => {
+ const grade = new Grade(GradeType.Number, 10, 50, null, null, null, 10);
+ assert.equal(grade.isLetterGrade(), false);
+ assert.equal(grade.isNumberGrade(), true);
+ assert.equal(grade.getScoreType(), GradeType.Number);
+ assert.equal(grade.getScore(), 10);
+ assert.equal(grade.getOutOf(), 50);
+ assert.equal(grade.getLetterGradeOptions(), undefined);
+ assert.equal(grade.isManuallyOverridden, false);
+ });
+
+ it('initializes properly for a numeric score (overridden)', () => {
+ const grade = new Grade(GradeType.Number, 10, 50, null, null, null, 15);
+ assert.equal(grade.isLetterGrade(), false);
+ assert.equal(grade.isNumberGrade(), true);
+ assert.equal(grade.getScoreType(), GradeType.Number);
+ assert.equal(grade.getScore(), 10);
+ assert.equal(grade.getOutOf(), 50);
+ assert.equal(grade.getLetterGradeOptions(), undefined);
+ assert.equal(grade.isManuallyOverridden, true);
+ });
+
+ it('initializes properly for a letter score', () => {
+ const grade = new Grade(GradeType.Letter, null, null, 'A', letterGradeOptions);
+ assert.equal(grade.isLetterGrade(), true);
+ assert.equal(grade.isNumberGrade(), false);
+ assert.equal(grade.getScoreType(), GradeType.Letter);
+ assert.equal(grade.getScore(), '1');
+ assert.equal(grade.getOutOf(), null);
+ assert.deepEqual(grade.getLetterGradeOptions(), letterGradeOptions);
+ });
+
+ it('initializes properly for a letter score with null grade', () => {
+ const grade = new Grade(GradeType.Letter, null, null, null, letterGradeOptions);
+ assert.equal(grade.isLetterGrade(), true);
+ assert.equal(grade.isNumberGrade(), false);
+ assert.equal(grade.getScoreType(), GradeType.Letter);
+ assert.equal(grade.getScore(), '0');
+ assert.equal(grade.getOutOf(), null);
+ assert.deepEqual(grade.getLetterGradeOptions(), letterGradeOptions);
+ });
+
+ it('initializes properly for a letter score with an out of', () => {
+ const grade = new Grade(GradeType.Letter, null, 50, 'A', letterGradeOptions);
+ assert.equal(grade.isLetterGrade(), true);
+ assert.equal(grade.isNumberGrade(), false);
+ assert.equal(grade.getScoreType(), GradeType.Letter);
+ assert.equal(grade.getScore(), '1');
+ assert.equal(grade.getOutOf(), 50);
+ assert.deepEqual(grade.getLetterGradeOptions(), letterGradeOptions);
+ });
+ });
+
+ describe('throws an error if improper scoreType given in constructor', () => {
+ it('given invalid string', () => {
+ assert.throws(() => {
+ new Grade('not valid', 10, 50, null, null);
+ }, GradeErrors.INVALID_SCORE_TYPE);
+ });
+
+ it('given undefined', () => {
+ assert.throws(() => {
+ new Grade(undefined, 10, 50, null, null);
+ }, GradeErrors.INVALID_SCORE_TYPE);
+ });
+
+ it('given number', () => {
+ assert.throws(() => {
+ new Grade(5, 10, 50, null, null);
+ }, GradeErrors.INVALID_SCORE_TYPE);
+ });
+
+ it('given array', () => {
+ assert.throws(() => {
+ new Grade([], 10, 50, null, null);
+ }, GradeErrors.INVALID_SCORE_TYPE);
+ });
+ });
+
+ describe('ensures that the gradeType is case insensitive and isLetterGrade and isNumberGrade still work', () => {
+ it('can handle numeric', () => {
+ assert.doesNotThrow(() => {
+ const grade = new Grade('numeric', 10, 50, null, null);
+ assert.isFalse(grade.isLetterGrade());
+ assert.isTrue(grade.isNumberGrade());
+ });
+ });
+
+ it('can handle lettergrade', () => {
+ assert.doesNotThrow(() => {
+ const grade = new Grade('lettergrade', null, null, 'A', letterGradeOptions);
+ assert.isTrue(grade.isLetterGrade());
+ assert.isFalse(grade.isNumberGrade());
+ });
+ });
+ });
+
+ describe('throws an error if improper score are provided for numeric scores', () => {
+ it('score as null', () => {
+ assert.doesNotThrow(() => {
+ new Grade(GradeType.Number, null, 10, null, null);
+ });
+ });
+
+ it('score as string', () => {
+ assert.throws(() => {
+ new Grade(GradeType.Number, 'A', 10, null, null);
+ }, GradeErrors.INVALID_SCORE);
+ });
+
+ it('score as array of strings', () => {
+ assert.throws(() => {
+ new Grade(GradeType.Number, ['A'], 10, null, null);
+ }, GradeErrors.INVALID_SCORE);
+ });
+ });
+
+ describe('throws an error if improper score/outOf are provided for letter scores', () => {
+ it('lettergrade as null', () => {
+ assert.doesNotThrow(() => {
+ new Grade(GradeType.Letter, null, null, null, letterGradeOptions);
+ });
+ });
+
+ it('lettergrade as number', () => {
+ assert.throws(() => {
+ new Grade(GradeType.Letter, null, null, 10, letterGradeOptions);
+ }, GradeErrors.INVALID_LETTER_GRADE);
+ });
+
+ it('lettergrade as array of strings', () => {
+ assert.throws(() => {
+ new Grade(GradeType.Letter, null, null, ['A', 'B'], letterGradeOptions);
+ }, GradeErrors.INVALID_LETTER_GRADE);
+ });
+
+ it('lettergradeOptions as null', () => {
+ assert.throws(() => {
+ new Grade(GradeType.Letter, null, null, 'A', null);
+ }, GradeErrors.INVALID_LETTER_GRADE_OPTIONS);
+ });
+
+ it('lettergradeOptions as number', () => {
+ assert.throws(() => {
+ new Grade(GradeType.Letter, null, null, 'A', 50);
+ }, GradeErrors.INVALID_LETTER_GRADE_OPTIONS);
+ });
+
+ it('lettergradeOptions as string', () => {
+ assert.throws(() => {
+ new Grade(GradeType.Letter, null, null, 'A', '50');
+ }, GradeErrors.INVALID_LETTER_GRADE_OPTIONS);
+ });
+
+ it('lettergradeOptions as empty array', () => {
+ assert.throws(() => {
+ new Grade(GradeType.Letter, null, null, 'A', []);
+ }, GradeErrors.INVALID_LETTER_GRADE_OPTIONS);
+ });
+
+ });
+
+ describe('getScore, getOutOf, and getLetterGradeOptions work properly', () => {
+ it('getScore works properly for numeric scores', () => {
+ const grade = new Grade(GradeType.Number, 5, 10, null, null);
+ assert.equal(grade.getScore(), 5);
+ });
+
+ it('getScore works properly for letter scores', () => {
+ const grade = new Grade(GradeType.Letter, null, null, 'A', letterGradeOptions);
+ assert.equal(grade.getScore(), 1);
+ });
+
+ it('getOutOf works properly for numeric scores', () => {
+ const grade = new Grade(GradeType.Number, 5, 10, null, null);
+ assert.equal(grade.getOutOf(), 10);
+ });
+
+ it('getLetterGradeOptions works properly for letter scores', () => {
+ const grade = new Grade(GradeType.Letter, null, null, 'A', letterGradeOptions);
+ assert.deepEqual(grade.getLetterGradeOptions(), letterGradeOptions);
+ });
+ });
+
+ describe('getLetterGrade works properly', () => {
+ it('getLetterGrade throws an error if the grade is numeric', () => {
+ const grade = new Grade(GradeType.Number, 5, 10, null, null);
+ assert.throws(() => {
+ grade.getLetterGrade();
+ }, GradeErrors.GET_LETTER_GRADE_FROM_NUMERIC_SCORE);
+ });
+
+ it('getLetterGrade returns the letter grade properly', () => {
+ const letterGrade = 'A';
+ const grade = new Grade(GradeType.Letter, null, null, letterGrade, letterGradeOptions);
+ assert.equal(grade.getLetterGrade(), letterGrade);
+ });
+ });
+
+ it('ensures that the letterGrade is one of the LetterGradeOptions', () => {
+ assert.throws(() => {
+ new Grade(GradeType.Letter, null, null, 'D', letterGradeOptions);
+ }, GradeErrors.LETTER_GRADE_NOT_IN_OPTIONS);
+ });
+
+ it('allows score and outOf to be 0', () => {
+ assert.doesNotThrow(() => {
+ new Grade(GradeType.Number, 0, 0, null, null);
+ });
+ });
+
+ describe('getLetterGradeAssignedValue works properly', () => {
+ it('getLetterGradeAssignedValue throws an error if the grade is numeric', () => {
+ const grade = new Grade(GradeType.Number, 5, 10, null, null);
+ assert.throws(() => {
+ grade.getLetterGradeAssignedValue();
+ }, GradeErrors.GET_LETTER_GRADE_FROM_NUMERIC_SCORE);
+ });
+
+ it('getLetterGradeAssignedValue throws an error if the letterGradeId has no corresponding assigned value', () => {
+ const letterGrade = 'A';
+ const badLetterGradeOptions = {
+ 0: { 'LetterGrade': 'None', 'PercentStart': null, 'AssignedValue': null },
+ 1: { 'LetterGrade': 'A', 'PercentStart': '80' },
+ 2: { 'LetterGrade': 'B', 'PercentStart': '65', 'AssignedValue': '65' },
+ 3: { 'LetterGrade': 'C', 'PercentStart': '50', 'AssignedValue': '50' },
+ };
+ const grade = new Grade(GradeType.Letter, null, null, letterGrade, badLetterGradeOptions);
+ assert.throws(() => {
+ grade.getLetterGradeAssignedValue();
+ }, GradeErrors.LETTER_GRADE_ID_NO_ASSIGNED_VALUE);
+ });
+
+ it('getLetterGradeAssignedValue throws an error if the letterGradeId has an assigned value that is not a number', () => {
+ const letterGrade = 'A';
+ const badLetterGradeOptions = {
+ 0: { 'LetterGrade': 'None', 'PercentStart': null, 'AssignedValue': null },
+ 1: { 'LetterGrade': 'A', 'PercentStart': '80', 'AssignedValue': 'A' },
+ 2: { 'LetterGrade': 'B', 'PercentStart': '65', 'AssignedValue': '65' },
+ 3: { 'LetterGrade': 'C', 'PercentStart': '50', 'AssignedValue': '50' },
+ };
+ const grade = new Grade(GradeType.Letter, null, null, letterGrade, badLetterGradeOptions);
+ assert.throws(() => {
+ grade.getLetterGradeAssignedValue();
+ }, GradeErrors.LETTER_GRADE_ID_NO_ASSIGNED_VALUE);
+ });
+
+ it('getLetterGradeAssignedValue returns assigned value', () => {
+ const letterGrade = 'A';
+ const grade = new Grade(GradeType.Letter, null, null, letterGrade, letterGradeOptions);
+ assert.equal(grade.getLetterGradeAssignedValue(), 80);
+ });
+ });
+
+ describe('properly updates a score of a number grade', () => {
+ const grade = new Grade(GradeType.Number, 0, 0, null, null);
+
+ it('sets number grade score properly', () => {
+ assert.doesNotThrow(() => {
+ grade.setScore(10);
+ assert.equal(grade.getScore(), 10);
+ });
+ });
+
+ it('returns empty string for undefined score', () => {
+ assert.doesNotThrow(() => {
+ grade.setScore(undefined);
+ assert.equal(grade.getScore(), '');
+ });
+ });
+
+ it('does not throw for null score', () => {
+ assert.doesNotThrow(() => {
+ grade.setScore(null);
+ });
+ });
+
+ it('throws error for string score', () => {
+ assert.throws(() => {
+ grade.setScore('A');
+ }, GradeErrors.INVALID_SCORE);
+ });
+
+ it('throws error for array of strings score', () => {
+ assert.throws(() => {
+ grade.setScore(['A']);
+ }, GradeErrors.INVALID_SCORE);
+ });
+ });
+
+ describe('properly updates a letter grade', () => {
+ const grade = new Grade(GradeType.Letter, null, null, 'A', letterGradeOptions);
+
+ it('sets the letter grade properly', () => {
+ assert.doesNotThrow(() => {
+ const letterGradeId = grade._getLetterGradeIdFromLetterGrade('B', letterGradeOptions);
+ grade.setScore(letterGradeId);
+ assert.equal(grade.getScore(), 2);
+ });
+ });
+
+ it('throws error for null score', () => {
+ assert.throws(() => {
+ grade.setScore(null);
+ }, GradeErrors.INVALID_LETTER_GRADE_ID);
+ });
+
+ it('throws error for undefined score', () => {
+ assert.throws(() => {
+ grade.setScore();
+ }, GradeErrors.INVALID_LETTER_GRADE_ID);
+ });
+
+ it('throws error for new score not in letter grade options', () => {
+ assert.throws(() => {
+ grade._getLetterGradeIdFromLetterGrade('D', letterGradeOptions);
+ }, GradeErrors.LETTER_GRADE_NOT_IN_OPTIONS);
+ });
+
+ });
+
+ it('is able to store and retrieve an entity associated with the grade', () => {
+ const entity = { some: 'entity' };
+ const grade = new Grade(GradeType.Number, 10, 11, null, null, entity);
+ assert.equal(grade.getEntity(), entity);
+ });
+
+ describe('can handle when scores have not yet been set', () => {
+ it('can handle score as null', () => {
+ assert.doesNotThrow(() => {
+ new Grade(GradeType.Number, null, 10, null, null);
+ });
+ });
+
+ it('can handle letterGrade as null', () => {
+ assert.doesNotThrow(() => {
+ new Grade(GradeType.Letter, null, null, null, letterGradeOptions);
+ });
+ });
+ });
+
+ it('getDisplay works properly', () => {
+ const display = { some: 'display property' };
+ const grade = new Grade(GradeType.Number, 10, 11, null, null, null, null, null, display);
+ assert.equal(grade.getDisplay(), display);
+ });
+});