1 | "use strict";
|
2 | var __assign = (this && this.__assign) || function () {
|
3 | __assign = Object.assign || function(t) {
|
4 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5 | s = arguments[i];
|
6 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7 | t[p] = s[p];
|
8 | }
|
9 | return t;
|
10 | };
|
11 | return __assign.apply(this, arguments);
|
12 | };
|
13 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
14 | return new (P || (P = Promise))(function (resolve, reject) {
|
15 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
16 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
17 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
18 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
19 | });
|
20 | };
|
21 | var __generator = (this && this.__generator) || function (thisArg, body) {
|
22 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
23 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
24 | function verb(n) { return function (v) { return step([n, v]); }; }
|
25 | function step(op) {
|
26 | if (f) throw new TypeError("Generator is already executing.");
|
27 | while (_) try {
|
28 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
29 | if (y = 0, t) op = [op[0] & 2, t.value];
|
30 | switch (op[0]) {
|
31 | case 0: case 1: t = op; break;
|
32 | case 4: _.label++; return { value: op[1], done: false };
|
33 | case 5: _.label++; y = op[1]; op = [0]; continue;
|
34 | case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
35 | default:
|
36 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
37 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
38 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
39 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
40 | if (t[2]) _.ops.pop();
|
41 | _.trys.pop(); continue;
|
42 | }
|
43 | op = body.call(thisArg, _);
|
44 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
45 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
46 | }
|
47 | };
|
48 | var __importStar = (this && this.__importStar) || function (mod) {
|
49 | if (mod && mod.__esModule) return mod;
|
50 | var result = {};
|
51 | if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
52 | result["default"] = mod;
|
53 | return result;
|
54 | };
|
55 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
56 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
57 | };
|
58 | var _this = this;
|
59 | Object.defineProperty(exports, "__esModule", { value: true });
|
60 | var log_parse_1 = __importStar(require("../log-parse"));
|
61 | var make_commit_from_msg_1 = __importDefault(require("./make-commit-from-msg"));
|
62 | describe('parsePR', function () {
|
63 | test('should do nothing without merge commit', function () {
|
64 | var commit = make_commit_from_msg_1.default('Not a merge');
|
65 | expect(log_parse_1.parsePR(commit)).toEqual(commit);
|
66 | });
|
67 | test('should parse number base and comment', function () {
|
68 | var commit = make_commit_from_msg_1.default('Merge pull request #1234 from Another PR\nComments about the PR');
|
69 | expect(log_parse_1.parsePR(commit)).toEqual(__assign({}, commit, { pullRequest: {
|
70 | number: 1234,
|
71 | base: 'Another PR'
|
72 | }, subject: 'Comments about the PR' }));
|
73 | });
|
74 | });
|
75 | describe('parseSquashPR', function () {
|
76 | test('should do nothing squash merge commit', function () {
|
77 | var commit = make_commit_from_msg_1.default('Not a squash');
|
78 | expect(log_parse_1.parseSquashPR(commit)).toEqual(commit);
|
79 | });
|
80 | test('should parse PR number and comment', function () {
|
81 | var commit = make_commit_from_msg_1.default('Some Message (#1234)');
|
82 | expect(log_parse_1.parseSquashPR(commit)).toEqual(__assign({}, commit, { pullRequest: {
|
83 | number: 1234
|
84 | }, subject: 'Some Message' }));
|
85 | });
|
86 | });
|
87 | describe('normalizeCommits', function () {
|
88 | test('should do nothing with normal commits', function () { return __awaiter(_this, void 0, void 0, function () {
|
89 | var logParse, commits, _a;
|
90 | return __generator(this, function (_b) {
|
91 | switch (_b.label) {
|
92 | case 0:
|
93 | logParse = new log_parse_1.default();
|
94 | commits = [
|
95 | make_commit_from_msg_1.default('First'),
|
96 | make_commit_from_msg_1.default('Second'),
|
97 | make_commit_from_msg_1.default('Third')
|
98 | ];
|
99 | _a = expect;
|
100 | return [4 , logParse.normalizeCommits(commits)];
|
101 | case 1:
|
102 | _a.apply(void 0, [_b.sent()]).toMatchSnapshot();
|
103 | return [2 ];
|
104 | }
|
105 | });
|
106 | }); });
|
107 | });
|
108 |
|
\ | No newline at end of file |