describe('MALjs suite', () => {
  var mal;

  beforeEach(function() {
    mal = new MALjs(_ENV.user, _ENV.password);
  });

  it('should be able to set credentials', () => {
    expect(mal.user).toBe(_ENV.user);
    expect(mal.password).toBe(_ENV.password);
  });

  describe('search()', () => {
    var failed;
    var response;

    beforeEach((done) => {
      mal = new MALjs(_ENV.user, _ENV.password);
      mal.search('full metal')
        .then(result => {
          failed = false;
          response = result;
          console.log('success:', result);
          done();
        })
        .catch(err => {
          failed = true;
          console.log('error:', err);
          done();
        });
    });

    it('should be able to search an anime', () => {
      expect(failed).toBe(false);
    });

    it('should return a json response on success', () => {
      expect(typeof response).toBe('object');
    });

    it('should contain an anime item', () => {
      expect(typeof response.anime).toBe('object');
      expect(response.anime.entry.length).toBeGreaterThan(0);
    });

  });

  describe('verifyCredentials()', () => {
    var failed;
    var response;

    beforeEach((done) => {
      mal = new MALjs(_ENV.user, _ENV.password);
      mal.verifyCredentials()
        .then(result => {
          failed = false;
          response = result;
          console.log('success:', result);
          done();
        })
        .catch(err => {
          failed = true;
          console.log('error:', err);
          done();
        });
    });

    it('should be able to retrieve user details', () => {
      expect(failed).toBe(false);
    });
  });

  describe('list()', () => {
    var failed;
    var response;

    beforeEach((done) => {
      mal = new MALjs(_ENV.user, _ENV.password);
      mal.list()
        .then(result => {
          failed = false;
          response = result;
          console.log('success:', result);
          done();
        })
        .catch(err => {
          failed = true;
          console.log('error:', err);
          done();
        });
    });

    it('should be able to retrieve user anime list', () => {
      expect(failed).toBe(false);
    });
  });

  describe('add()', () => {
    var failed;
    var response;

    beforeEach((done) => {
      mal = new MALjs(_ENV.user, _ENV.password);

      mal.add('71', {
        "episode": "1",
        "status": "6",
        "score": "7"
      })
      .then(results => {
        return mal.list();
      })
      .then(results => {
        console.log(results);
        failed = false;
        response = results;
        done();
      })
      .catch(err => {
        failed = true;
        console.log('error:', err);
        done();
      });
    });

    it('should be able to add an anime to the list', () => {
      expect(failed).toBe(false);
      expect(response.myanimelist).toBeDefined();
      expect(response.myanimelist.anime.series_animedb_id).toBe('71');
      expect(response.myanimelist.anime.my_status).toBe('6');
      expect(response.myanimelist.anime.my_watched_episodes).toBe('1');
    });
  });

  describe('update()', () => {
    var failed;
    var response;

    beforeEach((done) => {
      mal = new MALjs(_ENV.user, _ENV.password);

      mal.update('71', {
        "episode": "2",
        "status": "1",
        "score": "7"
      })
      .then(results => {
        return mal.list();
      })
      .then(results => {
        console.log(results);
        failed = false;
        response = results;
        done();
      })
      .catch(err => {
        failed = true;
        console.log('error:', err);
        done();
      });
    });

    it('should be able to update an anime to the list', () => {
      expect(failed).toBe(false);
      expect(response.myanimelist).toBeDefined();
      expect(response.myanimelist.anime.series_animedb_id).toBe('71');
      expect(response.myanimelist.anime.my_status).toBe('1');
      expect(response.myanimelist.anime.my_watched_episodes).toBe('2');
    });
  });

  describe('delete()', () => {
    var failed;
    var response;

    beforeEach((done) => {
      mal = new MALjs(_ENV.user, _ENV.password);

      mal.delete('71')
      .then(results => {
        return mal.list();
      })
      .then(results => {
        console.log(results);
        failed = false;
        response = results;
        done();
      })
      .catch(err => {
        failed = true;
        console.log('error:', err);
        done();
      });
    });

    it('should be able to delete an anime from the list', () => {
      expect(failed).toBe(false);
      expect(response.myanimelist.anime).not.toBeDefined();
    });
  });

});

@@ -250,32 +250,187 @@
 ssword);%0A  %7D);%0A%0A
+  it('should throw an exception when passing in no credentials', function() %7B%0A    expect(function() %7B%0A      new MALjs(_ENV.user);%0A    %7D).toThrow();%0A  %7D);%0A%0A
   describe('sear

test an exception when class is initatied witout credentials