Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AP/IB exam id tests #635

Merged
merged 1 commit into from
Jan 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/requirements/__test__/__snapshots__/exam-data-id.test.ts.snap
Original file line number Diff line number Diff line change
@@ -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",
]
`;
27 changes: 27 additions & 0 deletions src/requirements/__test__/exam-data-id.test.ts
Original file line number Diff line number Diff line change
@@ -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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the helpful comment!

* 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<string>();
examIds.forEach(id => {
if (set.has(id)) {
fail(`Detected duplicated exam unique ID: ${id}`);
} else {
set.add(id);
}
});
});