Skip to content
This repository has been archived by the owner on Jul 16, 2020. It is now read-only.

Commit

Permalink
rename cap and rem; bump versions
Browse files Browse the repository at this point in the history
  • Loading branch information
ricokahler committed Feb 10, 2018
1 parent 4ee3e5e commit 818ca3c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unofficial-umdearborn-catalog-api",
"version": "0.2.0",
"version": "0.3.0",
"description": "Unofficial course catalog APIs for the University of Michigan-Dearborn",
"main": "./dist/src/library.js",
"typings": "./src/library.ts",
Expand Down
20 changes: 10 additions & 10 deletions src/parsers/schedule-detail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { range } from 'lodash';
import { decode } from 'he';

export function parseCapacityAndRemaining(seatsTbody: HTMLTableSectionElement) {
const empty = { cap: NaN, rem: NaN };
const empty = { capacity: NaN, remaining: NaN };
const rows = (Array
.from(seatsTbody.children)
.filter(elem => elem.tagName.toLowerCase().trim() === 'tr')
Expand Down Expand Up @@ -50,13 +50,13 @@ export function parseCapacityAndRemaining(seatsTbody: HTMLTableSectionElement) {
);

if (result.crosslistseats) {
const cap = result.crosslistseats && result.crosslistseats.capacity || NaN;
const rem = result.crosslistseats && result.crosslistseats.remaining || NaN;
return { cap, rem };
const capacity = result.crosslistseats && result.crosslistseats.capacity || NaN;
const remaining = result.crosslistseats && result.crosslistseats.remaining || NaN;
return { capacity, remaining };
} else if (result.seats) {
const cap = result.seats && result.seats.capacity || NaN;
const rem = result.seats && result.seats.remaining || NaN;
return { cap, rem };
const capacity = result.seats && result.seats.capacity || NaN;
const remaining = result.seats && result.seats.remaining || NaN;
return { capacity, remaining };
}

return empty;
Expand Down Expand Up @@ -114,15 +114,15 @@ export function parseCrossListedCourses(infoCell: Element) {
}

type ScheduleDetailResult = {
cap: number,
rem: number,
capacity: number,
remaining: number,
credits: number,
creditsMin: number | undefined,
crossList: [string, string][],
};

/**
* captures the `cap` and `rem` of a section detail HTML
* captures the `capacity` and `remaining` of a section detail HTML
*/
export function parseScheduleDetail(html: string) {
const document = new JSDOM(html).window.document;
Expand Down
2 changes: 1 addition & 1 deletion swagger.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
openapi: 3.0.0
info:
title: Unofficial UMDearborn Catalog API
version: 0.2.0
version: 0.3.0
components:
schemas:
term:
Expand Down
10 changes: 5 additions & 5 deletions test/parsers/schedule-detail.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ describe(`schedule detail parser`, function () {
it(`parsers 'schedule-detail.html'`, function () {
const result = parseScheduleDetail(scheduleDetailHtml);
expect(result).to.be.deep.equal({
cap: 35,
rem: 1,
capacity: 35,
remaining: 1,
credits: 4,
creditsMin: undefined,
crossList: [['ECE', '478']]
Expand All @@ -27,9 +27,9 @@ describe(`schedule detail parser`, function () {
'.datadisplaytable tbody .datadisplaytable tbody'
) as HTMLTableSectionElement | null;

const { cap, rem } = parseCapacityAndRemaining(seatsTbody || document.createElement('tbody'));
expect(cap).to.be.equal(35);
expect(rem).to.be.equal(1);
const { capacity, remaining } = parseCapacityAndRemaining(seatsTbody || document.createElement('tbody'));
expect(capacity).to.be.equal(35);
expect(remaining).to.be.equal(1);
});
it(`parses the credits or credit range`, function () {
const infoCell = document.querySelector(
Expand Down

0 comments on commit 818ca3c

Please sign in to comment.