Skip to content

Commit

Permalink
Convert git_helper_spec to use Jest
Browse files Browse the repository at this point in the history
  • Loading branch information
reidmit committed Feb 16, 2019
1 parent 9ce5fb1 commit 844a77a
Showing 1 changed file with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import Git_helper from '../../tasks/helpers/git_helper';
import MockPromises from 'mock-promises';
import GitHelper from '../../tasks/helpers/git_helper';

describe('GitHelper', () => {
let gitHelper;

beforeEach(() => {
gitHelper = new Git_helper();
gitHelper = new GitHelper();
});

describe('#getLatestCommit', () => {
describe('when the tag does not exist', () => {
describe('when the major version branch exists', () => {
beforeEach(async(done) => {
beforeEach(async () => {
spyOn(gitHelper, 'git').and.callFake(command => {
if (command === 'branch') {
return Promise.resolve(' v8\n v9\n* v10\n master');
Expand All @@ -20,7 +19,6 @@ describe('GitHelper', () => {
}
});
await gitHelper.getLatestCommit('10.0.0');
done();
});

it('gets the latest commit on that branch', () => {
Expand All @@ -30,7 +28,7 @@ describe('GitHelper', () => {
});

describe('when the major version branch does not exists', () => {
beforeEach(async(done) => {
beforeEach(async () => {
spyOn(gitHelper, 'git').and.callFake(command => {
if (command === 'branch') {
return Promise.resolve(' v8\n v9\n* master');
Expand All @@ -39,7 +37,6 @@ describe('GitHelper', () => {
}
});
await gitHelper.getLatestCommit('10.0.0');
done();
});

it('gets the latest commit on master', () => {
Expand All @@ -50,15 +47,12 @@ describe('GitHelper', () => {
});

describe('when the tag does exist', () => {
beforeEach(async(done) => {
beforeEach(async () => {
spyOn(gitHelper, 'git').and.returnValue(Promise.resolve(''));
await gitHelper.getLatestCommit('10.0.0');
done();
});

it('returns the commit of that tag', () => {
MockPromises.tick(100);

expect(gitHelper.git).toHaveBeenCalledWith('rev-parse 10.0.0');
expect(gitHelper.git).not.toHaveBeenCalledWith('log master -1 --oneline --format=format:%H');
});
Expand Down

0 comments on commit 844a77a

Please sign in to comment.