Skip to content

Commit

Permalink
Adding unit tests for startHeartbeats and startRegistryFetches
Browse files Browse the repository at this point in the history
  • Loading branch information
jquatier committed May 1, 2016
1 parent 0695aa0 commit a435765
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions test/EurekaClient.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,58 @@ describe('Eureka client', () => {
});
});

describe('startHeartbeats()', () => {
let config;
let client;
let renewSpy;
let clock;
before(() => {
config = makeConfig();
client = new Eureka(config);
renewSpy = sinon.stub(client, 'renew');
clock = sinon.useFakeTimers();
});

after(() => {
renewSpy.restore();
clock.restore();
});

it('should call renew on interval', () => {
client.startHeartbeats();
clock.tick(30000);
expect(renewSpy).to.have.been.calledOnce;
clock.tick(30000);
expect(renewSpy).to.have.been.calledTwice;
});
});

describe('startRegistryFetches()', () => {
let config;
let client;
let fetchRegistrySpy;
let clock;
before(() => {
config = makeConfig();
client = new Eureka(config);
fetchRegistrySpy = sinon.stub(client, 'fetchRegistry');
clock = sinon.useFakeTimers();
});

after(() => {
fetchRegistrySpy.restore();
clock.restore();
});

it('should call renew on interval', () => {
client.startRegistryFetches();
clock.tick(30000);
expect(fetchRegistrySpy).to.have.been.calledOnce;
clock.tick(30000);
expect(fetchRegistrySpy).to.have.been.calledTwice;
});
});

describe('stop()', () => {
let config;
let client;
Expand Down

0 comments on commit a435765

Please sign in to comment.