diff --git a/src/requirements/__test__/__snapshots__/exam-data-id.test.ts.snap b/src/requirements/__test__/__snapshots__/exam-data-id.test.ts.snap new file mode 100644 index 000000000..94e170004 --- /dev/null +++ b/src/requirements/__test__/__snapshots__/exam-data-id.test.ts.snap @@ -0,0 +1,37 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ID of the exams are unchanged. 1`] = ` +Array [ + "AP Biology", + "AP Chemistry", + "AP Computer Science A", + "AP English Language and Composition", + "AP English Literature and Composition", + "AP French Language", + "AP French Literature", + "AP Italian Language", + "AP Italian Literature", + "AP Macroeconomics", + "AP Mathematics AB", + "AP Mathematics BC (Engineering)", + "AP Mathematics BC (Non-Engineering)", + "AP Microeconomics", + "AP Physics C-Electricity & Magnetism", + "AP Physics C-Mechanics", + "AP Physics I", + "AP Physics II", + "AP Psychology", + "AP Spanish Language", + "AP Spanish Literature", + "AP Statistics", + "IB Chemical and Physical Systems", + "IB Chemistry", + "IB Computer Science", + "IB Economics", + "IB English Language and Literature", + "IB English Literature A", + "IB Mathematics", + "IB Physical Science", + "IB Physics", +] +`; diff --git a/src/requirements/__test__/exam-data-id.test.ts b/src/requirements/__test__/exam-data-id.test.ts new file mode 100644 index 000000000..90edaf305 --- /dev/null +++ b/src/requirements/__test__/exam-data-id.test.ts @@ -0,0 +1,27 @@ +import { examSubjects } from '../requirement-exam-utils'; + +const examIds = [ + ...examSubjects.AP.map(subject => `AP ${subject}`), + ...examSubjects.IB.map(subject => `IB ${subject}`), +].sort((a, b) => a.localeCompare(b)); + +it('ID of the exams are unchanged.', () => { + /** + * What should you do when this test fails: + * a. Unbreak the test. To update the snapshot, run `npm run test -- -u`. + * b. Write a migration script for any exam unique ids that changed. + */ + + expect(examIds).toMatchSnapshot(); +}); + +it('No duplicate exam unique ID.', () => { + const set = new Set(); + examIds.forEach(id => { + if (set.has(id)) { + fail(`Detected duplicated exam unique ID: ${id}`); + } else { + set.add(id); + } + }); +});