-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add tests for resolvers (#132)
- Loading branch information
Showing
10 changed files
with
181 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const resolvers = require('./resolvers'); | ||
|
||
describe('resolvers', () => { | ||
it('should contain all resolvers', () => { | ||
expect(resolvers).toHaveProperty('Commit'); | ||
expect(resolvers).toHaveProperty('Config'); | ||
expect(resolvers).toHaveProperty('GitObject'); | ||
expect(resolvers).toHaveProperty('Promotion'); | ||
expect(resolvers).toHaveProperty('Query'); | ||
expect(resolvers).toHaveProperty('Status'); | ||
expect(resolvers).toHaveProperty('Ticket'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
jest.mock('config'); | ||
|
||
const commitResolver = require('./commit'); | ||
|
||
describe('resolvers', () => { | ||
describe('Commit', () => { | ||
describe('message', () => { | ||
it('should return correctly', () => { | ||
expect( | ||
commitResolver.message({ commit: { message: 'lorem' } }) | ||
).toEqual('lorem'); | ||
}); | ||
}); | ||
|
||
describe('commitType', () => { | ||
it('should return single for one commit', () => { | ||
expect( | ||
commitResolver.commitType({ | ||
parents: ['sha1'], | ||
}) | ||
).toEqual('single'); | ||
}); | ||
|
||
it('should return merge for two commits', () => { | ||
expect( | ||
commitResolver.commitType({ | ||
parents: ['sha1', 'sha2'], | ||
}) | ||
).toEqual('merge'); | ||
}); | ||
|
||
it('should return octopus for three commits', () => { | ||
expect( | ||
commitResolver.commitType({ | ||
parents: ['sha1', 'sha2', 'sha3'], | ||
}) | ||
).toEqual('octopus'); | ||
}); | ||
|
||
it('should return single for no commit', () => { | ||
expect( | ||
commitResolver.commitType({ | ||
parents: [], | ||
}) | ||
).toEqual('single'); | ||
}); | ||
}); | ||
|
||
describe('tickets', () => { | ||
it('should null with a missing commit sha', async () => { | ||
expect( | ||
await commitResolver.tickets({ commit: { message: 'lorem' } }) | ||
).toEqual(null); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module.exports = { | ||
promotions(parent) { | ||
return parent.promotions.jobs; | ||
promotions(config) { | ||
return config.promotions.jobs; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
jest.mock('config'); | ||
|
||
const configResolver = require('./config'); | ||
|
||
describe('resolvers', () => { | ||
describe('Config', () => { | ||
describe('promotions', () => { | ||
it('should jobs', () => { | ||
expect( | ||
configResolver.promotions({ | ||
promotions: { | ||
connection: 'circleci-public', | ||
jobs: [ | ||
'build', | ||
'deploy_integration', | ||
'deploy_staging', | ||
'deploy_prod', | ||
], | ||
}, | ||
}) | ||
).toEqual([ | ||
'build', | ||
'deploy_integration', | ||
'deploy_staging', | ||
'deploy_prod', | ||
]); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,6 @@ module.exports = { | |
} | ||
|
||
context.config = contextConfig; | ||
|
||
/* eslint-enable no-param-reassign */ | ||
|
||
return { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,6 @@ module.exports = { | |
config, | ||
}); | ||
|
||
// console.log(result); | ||
return result; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
module.exports = { | ||
id(parent) { | ||
return parent.number; | ||
id(ticket) { | ||
return ticket.number; | ||
}, | ||
|
||
status(parent) { | ||
return parent.state; | ||
status(ticket) { | ||
return ticket.state; | ||
}, | ||
|
||
title(parent) { | ||
return parent.title; | ||
title(ticket) { | ||
return ticket.title; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters