morning-builds-core
Version:
Core functionality for Morning Builds
51 lines • 2.34 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
jest.mock('../src/clients');
var object_helper_1 = require("./object-helper");
var comments_1 = require("../src/managers/comments");
var fail_categories_1 = require("../src/fail-categories");
var clients_1 = require("../src/clients");
describe('manager/comments', function () {
var commentsManager = new comments_1.Comments(new clients_1.Clients(object_helper_1.config));
describe('#assembleBuildsWithErrorInComments()', function () {
it('returns build with list a comment related to mapped errors', function (done) {
// Mocked client will return a list with one valid mapped error comment for PLAN01
commentsManager
.assembleBuildsWithErrorInComments([
object_helper_1.createBuild({ planKey: 'PLAN01' }),
])
.then(function (buildResults) {
expect(buildResults).toHaveLength(1);
expect(buildResults[0]).toMatchObject({
build: { planKey: 'PLAN01' },
failDetails: ['Hung Build state'],
failReason: fail_categories_1.categories.infrastructureError,
});
done();
});
});
it('won\'t return a build that has a non-mapped-error comment', function (done) {
// Mock will return a comment that does not indicate an mapped error for PLAN02
commentsManager
.assembleBuildsWithErrorInComments([
object_helper_1.createBuild({ planKey: 'PLAN02' }),
])
.then(function (buildResults) {
expect(buildResults).toHaveLength(0);
done();
});
});
it('won\'t return a build that has no comments associated with it', function (done) {
// Mock client will return an empty array of comments for PLAN03
commentsManager
.assembleBuildsWithErrorInComments([
object_helper_1.createBuild({ planKey: 'PLAN03' }),
])
.then(function (buildResults) {
expect(buildResults).toHaveLength(0);
done();
});
});
});
});
//# sourceMappingURL=comments-manager-test.js.map