Created
March 22, 2016 20:34
-
-
Save wolframkriesing/15a6f8c4b3069153558e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import assert from 'assert'; | |
function sendClockIn(gpsAvailability) { | |
return new Promise((resolve, reject) => { | |
gpsAvailability | |
.then(resolve) | |
.catch(reject); | |
}); | |
} | |
const availableGpsCoordinates = { lat: 23, lon: 42 }; | |
const gpsIsAvailable = new Promise((resolve, reject) => { | |
resolve(availableGpsCoordinates); | |
}); | |
const gpsIsNotAvailable = new Promise((resolve, reject) => { | |
reject(); | |
}); | |
describe.only('time tracking', () => { | |
context('GPS is required', () => { | |
it('sends clock-in when GPS is available', () => { | |
return sendClockIn(gpsIsAvailable); | |
}); | |
it('sends clock-in with coordinates when GPS is available', (done) => { | |
sendClockIn(gpsIsAvailable) | |
.then((result) => { | |
assert.deepEqual(result, availableGpsCoordinates); | |
done(); | |
}) | |
.catch((e) => done(e)) | |
; | |
}); | |
it('does NOT send clock-in when no GPS is available', (done) => { | |
sendClockIn(gpsIsNotAvailable) | |
.then(() => assert(false, 'Promise should have been rejected')) | |
.catch(done); | |
}); | |
it('warns the user when no GPS is available', () => { | |
}); | |
}); | |
context('GPS is optional', () => { | |
it('does NOT send GPS data when no GPS is available', () => { | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment