Skip to content

Instantly share code, notes, and snippets.

@wolframkriesing
Created March 22, 2016 20:34
Show Gist options
  • Save wolframkriesing/15a6f8c4b3069153558e to your computer and use it in GitHub Desktop.
Save wolframkriesing/15a6f8c4b3069153558e to your computer and use it in GitHub Desktop.
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