Skip to content
Closed
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
22 changes: 20 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,26 @@ const options = {
school: {},
username: undefined,
password: undefined,
authCode: undefined
}
try {
const parsed = require('./options.json')
const isParent = parsed.parent != null
const { school, username, password } = parsed[isParent ? 'parent' : 'child']
const { school, username, password, authCode } = parsed[isParent ? 'parent' : 'child']

options.isParent = isParent
options.school = school
options.username = username
options.password = password
options.authCode = authCode
} catch (e) { // For Travis CI we use environment variables.
options.isParent = process.env.TEST_ISPARENT
options.school.url = process.env.TEST_SCHOOLURL
options.username = process.env.TEST_USERNAME
options.password = process.env.TEST_PASSWORD
options.authCode = process.env.TEST_AUTHCODE
}
if (!options.school.url || !options.username || !options.password) {
if (!options.school.url || !options.username || !options.password || !options.authCode) {
throw new Error('No login information found.')
}

Expand Down Expand Up @@ -173,6 +176,21 @@ describe('Magister', function() {
})
})

describe('absence', function () {
it('should fetch absences', function () {
return m.absences(new Date()).then(r => {
expect(r).to.be.an('array')

for (const absence of r) {
expect(absence).to.be.an.instanceof(magisterjs.AbsenceInfo)
expect(absence.appointment).to.be.a('object')
}

return []
})
})
})

describe('activity', function () {
// TODO: add test for `ActivityElement#signup`

Expand Down