This repository was archived by the owner on Jan 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
742 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"presets": ["es2015"], | ||
"env": { | ||
"commonjs": { | ||
"plugins": [ | ||
["transform-es2015-modules-commonjs", { "loose": true }] | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
module.exports = { | ||
parser: 'babel-eslint', | ||
root: true, | ||
extends: [ | ||
'airbnb-base', | ||
'plugin:flowtype/recommended', | ||
], | ||
env: { | ||
browser: true, | ||
node: true, | ||
}, | ||
globals: { | ||
expect: true, | ||
it: true, | ||
}, | ||
plugins: [ | ||
'flowtype', | ||
'import', | ||
], | ||
settings: { | ||
'import/resolver': { | ||
webpack: { | ||
config: 'webpack.config.js', | ||
}, | ||
}, | ||
}, | ||
rules: { | ||
'arrow-body-style': 'off', | ||
'arrow-parens': ['error', 'as-needed', { requireForBlockBody: true }], | ||
'max-len': ['error', 120], | ||
'import/extensions': ['error', 'always', | ||
{ | ||
js: 'never', | ||
} | ||
], | ||
'linebreak-style': 'off', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,8 @@ node_modules | |
|
||
# Users Environment Variables | ||
.lock-wscript | ||
|
||
# Build | ||
es | ||
dist | ||
lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"coverageDirectory": "coverage", | ||
"moduleDirectories": ["node_modules"], | ||
"moduleNameMapper": { | ||
"^.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|bmp|ico|yml)$": "<rootDir>/__mocks__/fileMock.js", | ||
"^.+\\.(css|scss)$": "<rootDir>/__mocks__/styleMock.js" | ||
}, | ||
"modulePaths": [ | ||
"src" | ||
], | ||
"collectCoverageFrom": [ | ||
"src/**/*.js" | ||
], | ||
"testRegex": "(/__tests__/.*\\.test.js)$" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
6.6.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
language: node_js | ||
node_js: | ||
- '6' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = "test-file-stub"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
env: { | ||
jest: true, | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
/* eslint-disable no-console */ | ||
import { | ||
acadYearStartDates, | ||
getAcadYear, | ||
getAcadSem, | ||
getAcadWeekName, | ||
getAcadWeekInfo, | ||
} from '../src/academicCalendar'; | ||
|
||
console.warn = jest.genMockFn(); | ||
|
||
describe('acadYearStartDates', () => { | ||
it('has the start dates of 6 academic years', () => { | ||
expect(Object.keys(acadYearStartDates).length).toBe(6); | ||
}); | ||
}); | ||
|
||
describe('getAcadYear', () => { | ||
it('determines the correct start date for supported dates', () => { | ||
expect(getAcadYear(new Date('July 31, 2016')).year).toBe('15/16'); | ||
expect(getAcadYear(new Date('August 1, 2016')).year).toBe('16/17'); | ||
expect(getAcadYear(new Date('October 17, 2016')).year).toBe('16/17'); | ||
expect(getAcadYear(new Date('October 17, 2017')).year).toBe('17/18'); | ||
}); | ||
|
||
it('gives defaults for unsupported dates', () => { | ||
// Earlier than supported year range. | ||
expect(getAcadYear(new Date('October 17, 2006'))).toBe(null); | ||
// Later than supported year range. | ||
expect(getAcadYear(new Date('October 17, 2106')).year).toBe('19/20'); | ||
}); | ||
}); | ||
|
||
describe('getAcadSem', () => { | ||
it('determines the correct semester for supported weeks', () => { | ||
expect(getAcadSem(1)).toBe('Semester 1'); | ||
expect(getAcadSem(15)).toBe('Semester 1'); | ||
expect(getAcadSem(23)).toBe('Semester 1'); | ||
expect(getAcadSem(24)).toBe('Semester 2'); | ||
expect(getAcadSem(32)).toBe('Semester 2'); | ||
expect(getAcadSem(40)).toBe('Semester 2'); | ||
expect(getAcadSem(41)).toBe('Special Term I'); | ||
expect(getAcadSem(43)).toBe('Special Term I'); | ||
expect(getAcadSem(46)).toBe('Special Term I'); | ||
expect(getAcadSem(47)).toBe('Special Term II'); | ||
expect(getAcadSem(50)).toBe('Special Term II'); | ||
expect(getAcadSem(52)).toBe('Special Term II'); | ||
}); | ||
|
||
it('gives null for unsupported weeks', () => { | ||
expect(getAcadSem(-1)).toBe(null); | ||
expect(getAcadSem(0)).toBe(null); | ||
expect(getAcadSem(54)).toBe(null); | ||
expect(getAcadSem(1000)).toBe(null); | ||
expect(console.warn).toBeCalled(); | ||
}); | ||
}); | ||
|
||
describe('getAcadWeekName', () => { | ||
it('determines the correct semester for supported weeks', () => { | ||
expect(getAcadWeekName(1)).toEqual({ weekType: 'Instructional', weekNumber: 1 }); | ||
expect(getAcadWeekName(3)).toEqual({ weekType: 'Instructional', weekNumber: 3 }); | ||
expect(getAcadWeekName(7)).toEqual({ weekType: 'Recess', weekNumber: null }); | ||
expect(getAcadWeekName(8)).toEqual({ weekType: 'Instructional', weekNumber: 7 }); | ||
expect(getAcadWeekName(11)).toEqual({ weekType: 'Instructional', weekNumber: 10 }); | ||
expect(getAcadWeekName(15)).toEqual({ weekType: 'Reading', weekNumber: null }); | ||
expect(getAcadWeekName(16)).toEqual({ weekType: 'Examination', weekNumber: 1 }); | ||
expect(getAcadWeekName(17)).toEqual({ weekType: 'Examination', weekNumber: 2 }); | ||
}); | ||
|
||
it('gives null for unsupported weeks', () => { | ||
expect(getAcadWeekName(-1)).toBe(null); | ||
expect(getAcadWeekName(0)).toBe(null); | ||
expect(getAcadWeekName(18)).toBe(null); | ||
expect(getAcadWeekName(1000)).toBe(null); | ||
expect(console.warn).toBeCalled(); | ||
}); | ||
}); | ||
|
||
describe('getAcadWeekInfo', () => { | ||
it('determines the correct week info for supported weeks', () => { | ||
expect(getAcadWeekInfo(new Date('August 1, 2016'))).toEqual({ | ||
year: '16/17', sem: 'Semester 1', type: 'Orientation', num: null, | ||
}); | ||
expect(getAcadWeekInfo(new Date('August 8, 2016'))).toEqual({ | ||
year: '16/17', sem: 'Semester 1', type: 'Instructional', num: 1, | ||
}); | ||
expect(getAcadWeekInfo(new Date('August 14, 2016'))).toEqual({ | ||
year: '16/17', sem: 'Semester 1', type: 'Instructional', num: 1, | ||
}); | ||
expect(getAcadWeekInfo(new Date('September 12, 2016'))).toEqual({ | ||
year: '16/17', sem: 'Semester 1', type: 'Instructional', num: 6, | ||
}); | ||
expect(getAcadWeekInfo(new Date('September 19, 2016'))).toEqual({ | ||
year: '16/17', sem: 'Semester 1', type: 'Recess', num: null, | ||
}); | ||
expect(getAcadWeekInfo(new Date('September 27, 2016'))).toEqual({ | ||
year: '16/17', sem: 'Semester 1', type: 'Instructional', num: 7, | ||
}); | ||
expect(getAcadWeekInfo(new Date('November 11, 2016'))).toEqual({ | ||
year: '16/17', sem: 'Semester 1', type: 'Instructional', num: 13, | ||
}); | ||
expect(getAcadWeekInfo(new Date('November 14, 2016'))).toEqual({ | ||
year: '16/17', sem: 'Semester 1', type: 'Reading', num: null, | ||
}); | ||
expect(getAcadWeekInfo(new Date('November 21, 2016'))).toEqual({ | ||
year: '16/17', sem: 'Semester 1', type: 'Examination', num: 1, | ||
}); | ||
expect(getAcadWeekInfo(new Date('December 2, 2016'))).toEqual({ | ||
year: '16/17', sem: 'Semester 1', type: 'Examination', num: 2, | ||
}); | ||
expect(getAcadWeekInfo(new Date('December 7, 2016'))).toEqual({ | ||
year: '16/17', sem: 'Semester 1', type: 'Vacation', num: 1, | ||
}); | ||
expect(getAcadWeekInfo(new Date('December 28, 2016'))).toEqual({ | ||
year: '16/17', sem: 'Semester 1', type: 'Vacation', num: 4, | ||
}); | ||
expect(getAcadWeekInfo(new Date('January 4, 2017'))).toEqual({ | ||
year: '16/17', sem: 'Semester 1', type: 'Vacation', num: 5, | ||
}); | ||
expect(getAcadWeekInfo(new Date('January 9, 2017'))).toEqual({ | ||
year: '16/17', sem: 'Semester 2', type: 'Instructional', num: 1, | ||
}); | ||
expect(getAcadWeekInfo(new Date('February 14, 2017'))).toEqual({ | ||
year: '16/17', sem: 'Semester 2', type: 'Instructional', num: 6, | ||
}); | ||
expect(getAcadWeekInfo(new Date('February 21, 2017'))).toEqual({ | ||
year: '16/17', sem: 'Semester 2', type: 'Recess', num: null, | ||
}); | ||
expect(getAcadWeekInfo(new Date('February 28, 2017'))).toEqual({ | ||
year: '16/17', sem: 'Semester 2', type: 'Instructional', num: 7, | ||
}); | ||
expect(getAcadWeekInfo(new Date('April 11, 2017'))).toEqual({ | ||
year: '16/17', sem: 'Semester 2', type: 'Instructional', num: 13, | ||
}); | ||
expect(getAcadWeekInfo(new Date('April 18, 2017'))).toEqual({ | ||
year: '16/17', sem: 'Semester 2', type: 'Reading', num: null, | ||
}); | ||
expect(getAcadWeekInfo(new Date('April 25, 2017'))).toEqual({ | ||
year: '16/17', sem: 'Semester 2', type: 'Examination', num: 1, | ||
}); | ||
expect(getAcadWeekInfo(new Date('May 2, 2017'))).toEqual({ | ||
year: '16/17', sem: 'Semester 2', type: 'Examination', num: 2, | ||
}); | ||
expect(getAcadWeekInfo(new Date('May 9, 2017'))).toEqual({ | ||
year: '16/17', sem: 'Special Term I', type: 'Instructional', num: 1, | ||
}); | ||
expect(getAcadWeekInfo(new Date('June 6, 2017'))).toEqual({ | ||
year: '16/17', sem: 'Special Term I', type: 'Instructional', num: 5, | ||
}); | ||
expect(getAcadWeekInfo(new Date('June 13, 2017'))).toEqual({ | ||
year: '16/17', sem: 'Special Term I', type: 'Instructional', num: 6, | ||
}); | ||
expect(getAcadWeekInfo(new Date('June 20, 2017'))).toEqual({ | ||
year: '16/17', sem: 'Special Term II', type: 'Instructional', num: 1, | ||
}); | ||
expect(getAcadWeekInfo(new Date('July 25, 2017'))).toEqual({ | ||
year: '16/17', sem: 'Special Term II', type: 'Instructional', num: 6, | ||
}); | ||
expect(getAcadWeekInfo(new Date('August 4, 2017'))).toEqual({ | ||
year: '16/17', sem: null, type: 'Vacation', num: null, | ||
}); | ||
expect(getAcadWeekInfo(new Date('August 7, 2017'))).toEqual({ | ||
year: '17/18', sem: 'Semester 1', type: 'Orientation', num: null, | ||
}); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.