Files
shields/services/github/github-deployments.spec.js
Dominik Grzelak d1ec834cb5 [Github] Handle the case when the Github deployment status returns null (#5704)
* Handle the case when the Github deployment status returns null

* Integration test null latestStatus response from Github Deployments

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2020-10-15 23:51:31 +00:00

78 lines
1.4 KiB
JavaScript

'use strict'
const { test, given } = require('sazerac')
const GithubDeployments = require('./github-deployments.service')
describe('GithubDeployments', function () {
test(GithubDeployments.render, () => {
given({
state: 'SUCCESS',
}).expect({
message: 'success',
color: 'brightgreen',
})
given({
state: 'ERROR',
}).expect({
message: 'error',
color: 'red',
})
given({
state: 'IN_PROGRESS',
}).expect({
message: 'in progress',
color: undefined,
})
given({
state: 'NO_STATUS',
}).expect({
message: 'no status yet',
color: undefined,
})
})
test(GithubDeployments.prototype.transform, () => {
given({
data: {
repository: {
deployments: {
nodes: [],
},
},
},
}).expectError('Not Found: environment not found')
given({
data: {
repository: {
deployments: {
nodes: [
{
latestStatus: null,
},
],
},
},
},
}).expect({
state: 'NO_STATUS',
})
given({
data: {
repository: {
deployments: {
nodes: [
{
latestStatus: {
state: 'SUCCESS',
},
},
],
},
},
},
}).expect({
state: 'SUCCESS',
})
})
})