
var should = require("should")
    , strava = require("../")
    , testHelper = require("./_helper");

describe('athlete_test', function(){

    describe('#get()', function() {

        it('should return detailed athlete information about athlete associated to access_token (level 3)', function(done) {

            strava.athlete.get({},function(err,payload){

                if(!err) {
                    //console.log(payload);
                    (payload.resource_state).should.be.exactly(3);
                }
                else {
                    console.log(err);
                }

                done();
            });
        });
    });

    describe('#listFriends()', function() {

        it('should return information about friends associated to athlete with access_token', function(done) {

            strava.athlete.listFriends({},function(err,payload){

                if(!err) {
                    //console.log(payload);
                    payload.should.be.instanceof(Array);
                }
                else {
                    console.log(err);
                }

                done();
            });
        });
    });

    describe('#listFollowers()', function() {

        it('should return information about followers associated to athlete with access_token', function(done) {

            strava.athlete.listFollowers({},function(err,payload){

                if(!err) {
                    //console.log(payload);
                    payload.should.be.instanceof(Array);
                }
                else {
                    console.log(err);
                }

                done();
            });
        });
    });

    describe('#listActivities()', function() {

        it('should return information about activities associated to athlete with access_token', function(done) {

            strava.athlete.listActivities({},function(err,payload){

                if(!err) {
                    //console.log(payload);
                    payload.should.be.instanceof(Array);
                }
                else {
                    console.log(err);
                }

                done();
            });
        });
    });

    describe('#listClubs()', function() {

        it('should return information about clubs associated to athlete with access_token', function(done) {

            strava.athlete.listClubs({},function(err,payload){

                if(!err) {
                    //console.log(payload);
                    payload.should.be.instanceof(Array);
                }
                else {
                    console.log(err);
                }

                done();
            });
        });
    });

    describe('#listRoutes()', function() {

        it('should return information about routes associated to athlete with access_token', function(done) {

            strava.athlete.listRoutes({},function(err,payload){

                if(!err) {
                    //console.log(payload);
                    payload.should.be.instanceof(Array);
                }
                else {
                    console.log(err);
                }

                done();
            });
        });
    });

    describe('#update()', function() {

        //grab the athlete so we can revert changes
        var _athletePreEdit;
        before(function(done) {

            testHelper.getSampleAthlete(function(err,payload){
                _athletePreEdit = payload;
                done();
            });
        });

        it('should update the city of the current athlete and revert to original', function(done) {

            var city = "Seattle";

            strava.athlete.update({city:city},function(err,payload){

                if(!err) {
                    //console.log(payload);
                    (payload.resource_state).should.be.exactly(3);
                    (payload.city).should.be.exactly(city);

                    //great! we've proven our point, let's reset the athlete data
                    strava.athlete.update({city:_athletePreEdit.city},function(err,payload){

                        //console.log(payload);
                        (payload.resource_state).should.be.exactly(3);
                        (payload.city).should.be.exactly(_athletePreEdit.city);
                        done();
                    });
                }
                else {
                    console.log(err);
                    done();
                }
            });
        });
    });

});

@@ -1858,39 +1858,190 @@
     
-strava.athlete.listActivities(%7B
+var nowSeconds = Math.floor(Date.now()/1000);%0A            strava.athlete.listActivities(%7B%0A              after: nowSeconds + 3600,%0A              before: nowSeconds + 3600%0A            
 %7D,fu

update tests