Skip to content

Commit

Permalink
test: make tests more atomic
Browse files Browse the repository at this point in the history
  • Loading branch information
simonseyock committed Jul 15, 2024
1 parent 4222b85 commit 2ff6162
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions test/maven.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ describe('maven', () => {
logger.error.mockClear();
});

test('updateVersion', () => {
updateVersion(logger, false, '1.1.1', undefined, false, false);
test('updateVersion with all options off', () => {
updateVersion(logger, false, '1.1.1', undefined, false, false);
expect(exec).toBeCalledWith(
'mvn',
[
Expand All @@ -29,7 +29,9 @@ describe('maven', () => {
expect(logger.log).toBeCalledTimes(1);
expect(logger.log).toBeCalledWith(`Updating pom.xml to version 1.1.1`);
expect(logger.error).toBeCalledTimes(0);
});

test('updateVersion with all options on', () => {
updateVersion(logger, true, '1.1.2', 'some/path', true, true);
expect(exec).toBeCalledWith(
'./mvnw',
Expand All @@ -46,12 +48,12 @@ describe('maven', () => {
]
);

expect(logger.log).toBeCalledTimes(2);
expect(logger.log).toBeCalledTimes(1);
expect(logger.log).toBeCalledWith(`Updating pom.xml to version 1.1.2`);
expect(logger.error).toBeCalledTimes(0);
});

test('updateSnapshotVersion', () => {
test('updateSnapshotVersion with all options off', () => {
updateSnapshotVersion(logger, false, undefined, false, false);

expect(exec).toBeCalledWith(
Expand All @@ -68,7 +70,9 @@ describe('maven', () => {
expect(logger.log).toBeCalledTimes(1);
expect(logger.log).toBeCalledWith('Update pom.xml to next snapshot version');
expect(logger.error).toBeCalledTimes(0);
});

test('updateSnapshotVersion with all options on', () => {
updateSnapshotVersion(logger, true, 'some/path', true, true);

expect(exec).toBeCalledWith(
Expand All @@ -86,12 +90,12 @@ describe('maven', () => {
]
);

expect(logger.log).toBeCalledTimes(2);
expect(logger.log).toBeCalledTimes(1);
expect(logger.log).toBeCalledWith('Update pom.xml to next snapshot version');
expect(logger.error).toBeCalledTimes(0);
});

test('deploy', () => {
test('deploy with all options off', () => {
deploy(logger, false, '1.1.3', 'deploy', undefined, false, false);

expect(exec).toBeCalledWith(
Expand All @@ -107,7 +111,9 @@ describe('maven', () => {
expect(logger.log).toBeCalledTimes(1);
expect(logger.log).toBeCalledWith(`Deploying version 1.1.3 with maven`);
expect(logger.error).toBeCalledTimes(0);
});

test('deploy with all options on', () => {
deploy(logger, true, '1.1.4', 'deploy jib:build', 'some/path', true, true);

expect(exec).toBeCalledWith(
Expand All @@ -125,12 +131,12 @@ describe('maven', () => {
]
);

expect(logger.log).toBeCalledTimes(2);
expect(logger.log).toBeCalledTimes(1);
expect(logger.log).toBeCalledWith(`Deploying version 1.1.4 with maven`);
expect(logger.error).toBeCalledTimes(0);
});

test('testMvn', () => {
test('testMvn with all options off', () => {
testMvn(logger, false);

expect(exec).toBeCalledWith(
Expand All @@ -141,15 +147,17 @@ describe('maven', () => {
expect(logger.log).toBeCalledTimes(1);
expect(logger.log).toBeCalledWith('Testing if mvn exists');
expect(logger.error).toBeCalledTimes(0);
});

test('testMvn with all options on', () => {
testMvn(logger, true);

expect(exec).toBeCalledWith(
'./mvnw',
['-v']
);

expect(logger.log).toBeCalledTimes(2);
expect(logger.log).toBeCalledTimes(1);
expect(logger.log).toBeCalledWith('Testing if mvn exists');
expect(logger.error).toBeCalledTimes(0);
});
Expand Down

0 comments on commit 2ff6162

Please sign in to comment.