Skip to content
Open
Show file tree
Hide file tree
Changes from 7 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
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"devDependencies": {
"@types/jest": "^29.5.12",
"@types/mocha": "^10.0.6"
}
}
2 changes: 1 addition & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"icalendar": "0.7.1",
"identity-obj-proxy": "3.0.0",
"jest": "29.6.2",
"jest-environment-jsdom": "^29.5.0",
"jest-environment-jsdom": "^29.7.0",
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 PR! I'll get to reviewing and testing the code by this Wednesday. In the meantime, can I check if bumping the dependencies here (and creating a package.json for the monorepo) is required for the change to work? Otherwise, could you help remove those diffs (package.json, website/package.json, and website/src/utils/yarn.lock from this PR? Thanks!

Copy link
Author

Choose a reason for hiding this comment

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

Alright, done! The dependencies were not required to be updated. I have not worked with yarn before so was a little unfamiliar with the process. Thank you for your help!

"jest-junit": "16.0.0",
"mini-css-extract-plugin": "1.6.2",
"nightwatch": "0.9.21",
Expand Down
2 changes: 2 additions & 0 deletions website/src/utils/ical.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ test('iCalEventForLesson generates correct output', () => {
description: 'Personal Development & Career Management\nSectional Teaching Group A1',
location: 'BIZ1-0303',
repeating: {
interval: 1,
freq: 'WEEKLY',
count: 14,
byDay: ['Mo'],
Expand Down Expand Up @@ -291,6 +292,7 @@ test('work for half hour lesson offsets', () => {
description: 'Personal Development & Career Management\nSectional Teaching Group A1',
location: 'BIZ1-0303',
repeating: {
interval: 1,
freq: 'WEEKLY',
count: 14,
byDay: ['Mo'],
Expand Down
22 changes: 21 additions & 1 deletion website/src/utils/ical.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@ function calculateStartEnd(date: Date, startTime: StartTime, endTime: EndTime) {
return { start, end };
}

function calculateLargestInterval(weeks: NumericWeeks) {
let largestInterval = 1;
for (let i = 0; i < weeks.length - 1; i++) {
const diff = weeks[i + 1] - weeks[i];
if (diff > largestInterval) {
largestInterval = diff;
}
}
return largestInterval - 1;
}

export function calculateNumericWeek(
lesson: RawLesson,
_semester: Semester,
Expand All @@ -91,12 +102,21 @@ export function calculateNumericWeek(
const { start, end } = calculateStartEnd(lessonDay, lesson.startTime, lesson.endTime);
const excludedWeeks = _.difference([RECESS_WEEK, ...ALL_WEEKS], weeks);

// Sets interval to 2 for odd and even weeks. Fix for mobile GCal imports.
const isAlternate =
weeks.every((week) => ODD_WEEKS.includes(week)) ||
weeks.every((week) => EVEN_WEEKS.includes(week));
const interval = isAlternate ? 2 : 1;
const largestInterval = calculateLargestInterval(weeks);
const adjCount = largestInterval === interval ? weeks.length : NUM_WEEKS_IN_A_SEM;

return {
start,
end,
repeating: {
interval,
freq: 'WEEKLY',
count: NUM_WEEKS_IN_A_SEM,
count: adjCount,
byDay: [lesson.day.slice(0, 2)],
exclude: [
...excludedWeeks.map((week) => datesForAcademicWeeks(start, week)),
Expand Down
104 changes: 95 additions & 9 deletions website/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1930,6 +1930,16 @@
"@types/node" "*"
jest-mock "^29.6.2"

"@jest/environment@^29.7.0":
version "29.7.0"
resolved "https://registry.yarnpkg.com/@jest/environment/-/environment-29.7.0.tgz#24d61f54ff1f786f3cd4073b4b94416383baf2a7"
integrity sha512-aQIfHDq33ExsN4jP1NWGXhxgQ/wixs60gDiKO+XVMd8Mn0NWPWgc34ZQDTb2jKaUWQ7MuwoitXAsN2XVXNMpAw==
dependencies:
"@jest/fake-timers" "^29.7.0"
"@jest/types" "^29.6.3"
"@types/node" "*"
jest-mock "^29.7.0"

"@jest/expect-utils@^29.5.0":
version "29.5.0"
resolved "https://registry.yarnpkg.com/@jest/expect-utils/-/expect-utils-29.5.0.tgz#f74fad6b6e20f924582dc8ecbf2cb800fe43a036"
Expand Down Expand Up @@ -1964,6 +1974,18 @@
jest-mock "^29.6.2"
jest-util "^29.6.2"

"@jest/fake-timers@^29.7.0":
version "29.7.0"
resolved "https://registry.yarnpkg.com/@jest/fake-timers/-/fake-timers-29.7.0.tgz#fd91bf1fffb16d7d0d24a426ab1a47a49881a565"
integrity sha512-q4DH1Ha4TTFPdxLsqDXK1d3+ioSL7yL5oCMJZgDYm6i+6CygW5E5xVr/D1HdsGxjt1ZWSfUAs9OxSB/BNelWrQ==
dependencies:
"@jest/types" "^29.6.3"
"@sinonjs/fake-timers" "^10.0.2"
"@types/node" "*"
jest-message-util "^29.7.0"
jest-mock "^29.7.0"
jest-util "^29.7.0"

"@jest/globals@^29.6.2":
version "29.6.2"
resolved "https://registry.yarnpkg.com/@jest/globals/-/globals-29.6.2.tgz#74af81b9249122cc46f1eb25793617eec69bf21a"
Expand Down Expand Up @@ -2018,6 +2040,13 @@
dependencies:
"@sinclair/typebox" "^0.27.8"

"@jest/schemas@^29.6.3":
version "29.6.3"
resolved "https://registry.yarnpkg.com/@jest/schemas/-/schemas-29.6.3.tgz#430b5ce8a4e0044a7e3819663305a7b3091c8e03"
integrity sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==
dependencies:
"@sinclair/typebox" "^0.27.8"

"@jest/source-map@^29.6.0":
version "29.6.0"
resolved "https://registry.yarnpkg.com/@jest/source-map/-/source-map-29.6.0.tgz#bd34a05b5737cb1a99d43e1957020ac8e5b9ddb1"
Expand Down Expand Up @@ -2103,6 +2132,18 @@
"@types/yargs" "^17.0.8"
chalk "^4.0.0"

"@jest/types@^29.6.3":
version "29.6.3"
resolved "https://registry.yarnpkg.com/@jest/types/-/types-29.6.3.tgz#1131f8cf634e7e84c5e77bab12f052af585fba59"
integrity sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==
dependencies:
"@jest/schemas" "^29.6.3"
"@types/istanbul-lib-coverage" "^2.0.0"
"@types/istanbul-reports" "^3.0.0"
"@types/node" "*"
"@types/yargs" "^17.0.8"
chalk "^4.0.0"

"@jridgewell/gen-mapping@^0.3.0", "@jridgewell/gen-mapping@^0.3.2":
version "0.3.3"
resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz#7e02e6eb5df901aaedb08514203b096614024098"
Expand Down Expand Up @@ -8324,18 +8365,18 @@ jest-each@^29.6.2:
jest-util "^29.6.2"
pretty-format "^29.6.2"

jest-environment-jsdom@^29.5.0:
version "29.6.2"
resolved "https://registry.yarnpkg.com/jest-environment-jsdom/-/jest-environment-jsdom-29.6.2.tgz#4fc68836a7774a771819a2f980cb47af3b1629da"
integrity sha512-7oa/+266AAEgkzae8i1awNEfTfjwawWKLpiw2XesZmaoVVj9u9t8JOYx18cG29rbPNtkUlZ8V4b5Jb36y/VxoQ==
jest-environment-jsdom@^29.7.0:
version "29.7.0"
resolved "https://registry.yarnpkg.com/jest-environment-jsdom/-/jest-environment-jsdom-29.7.0.tgz#d206fa3551933c3fd519e5dfdb58a0f5139a837f"
integrity sha512-k9iQbsf9OyOfdzWH8HDmrRT0gSIcX+FLNW7IQq94tFX0gynPwqDTW0Ho6iMVNjGz/nb+l/vW3dWM2bbLLpkbXA==
dependencies:
"@jest/environment" "^29.6.2"
"@jest/fake-timers" "^29.6.2"
"@jest/types" "^29.6.1"
"@jest/environment" "^29.7.0"
"@jest/fake-timers" "^29.7.0"
"@jest/types" "^29.6.3"
"@types/jsdom" "^20.0.0"
"@types/node" "*"
jest-mock "^29.6.2"
jest-util "^29.6.2"
jest-mock "^29.7.0"
jest-util "^29.7.0"
jsdom "^20.0.0"

jest-environment-node@^29.6.2:
Expand Down Expand Up @@ -8447,6 +8488,21 @@ jest-message-util@^29.6.2:
slash "^3.0.0"
stack-utils "^2.0.3"

jest-message-util@^29.7.0:
version "29.7.0"
resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-29.7.0.tgz#8bc392e204e95dfe7564abbe72a404e28e51f7f3"
integrity sha512-GBEV4GRADeP+qtB2+6u61stea8mGcOT4mCtrYISZwfu9/ISHFJ/5zOMXYbpBE9RsS5+Gb63DW4FgmnKJ79Kf6w==
dependencies:
"@babel/code-frame" "^7.12.13"
"@jest/types" "^29.6.3"
"@types/stack-utils" "^2.0.0"
chalk "^4.0.0"
graceful-fs "^4.2.9"
micromatch "^4.0.4"
pretty-format "^29.7.0"
slash "^3.0.0"
stack-utils "^2.0.3"

jest-mock@^29.6.2:
version "29.6.2"
resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-29.6.2.tgz#ef9c9b4d38c34a2ad61010a021866dad41ce5e00"
Expand All @@ -8456,6 +8512,15 @@ jest-mock@^29.6.2:
"@types/node" "*"
jest-util "^29.6.2"

jest-mock@^29.7.0:
version "29.7.0"
resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-29.7.0.tgz#4e836cf60e99c6fcfabe9f99d017f3fdd50a6347"
integrity sha512-ITOMZn+UkYS4ZFh83xYAOzWStloNzJFO2s8DWrE4lhtGD+AorgnbkiKERe4wQVBydIGPx059g6riW5Btp6Llnw==
dependencies:
"@jest/types" "^29.6.3"
"@types/node" "*"
jest-util "^29.7.0"

jest-pnp-resolver@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/jest-pnp-resolver/-/jest-pnp-resolver-1.2.2.tgz#b704ac0ae028a89108a4d040b3f919dfddc8e33c"
Expand Down Expand Up @@ -8594,6 +8659,18 @@ jest-util@^29.6.2:
graceful-fs "^4.2.9"
picomatch "^2.2.3"

jest-util@^29.7.0:
version "29.7.0"
resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-29.7.0.tgz#23c2b62bfb22be82b44de98055802ff3710fc0bc"
integrity sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA==
dependencies:
"@jest/types" "^29.6.3"
"@types/node" "*"
chalk "^4.0.0"
ci-info "^3.2.0"
graceful-fs "^4.2.9"
picomatch "^2.2.3"

jest-validate@^29.6.2:
version "29.6.2"
resolved "https://registry.yarnpkg.com/jest-validate/-/jest-validate-29.6.2.tgz#25d972af35b2415b83b1373baf1a47bb266c1082"
Expand Down Expand Up @@ -10887,6 +10964,15 @@ pretty-format@^29.6.2:
ansi-styles "^5.0.0"
react-is "^18.0.0"

pretty-format@^29.7.0:
version "29.7.0"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-29.7.0.tgz#ca42c758310f365bfa71a0bda0a807160b776812"
integrity sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==
dependencies:
"@jest/schemas" "^29.6.3"
ansi-styles "^5.0.0"
react-is "^18.0.0"

process-nextick-args@~2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"
Expand Down