bitbucket-server-utils-cli
Version:
[](https://www.npmjs.com/package/bitbucket-server-utils-cli)
19 lines • 2.58 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var state = require('./state-file.json').v1;
var render_string_1 = __importDefault(require("../utils/render-string"));
beforeAll(function () {
jest.spyOn(Date.prototype, 'getFullYear').mockReturnValue(2020);
jest.spyOn(Date.prototype, 'getMonth').mockReturnValue(1);
jest.spyOn(Date.prototype, 'getDate').mockReturnValue(3);
jest.spyOn(Date.prototype, 'getTime').mockReturnValue(1674410998939);
});
it('should render string with helpers', function () {
var template = "\n year: {{dateYear lastUpdated}}\n month: {{dateMonth lastUpdated}}\n day: {{dateDay lastUpdated}}\n\n commit: {{#commit \"222222d1d6c87172cf2dea0f3c18df6ed687ead4\"}}\n Commit author slug: {{author.slug}}\n {{/commit}}\n\n\n Found {{length repositories}} repositories.\n {{#each repositories}}\n Repository: {{repository.slug.projectSlug}} / {{repository.slug.repoSlug}} with {{length commits}} commits.\n\n {{#ifEqual repository.slug.repoSlug \"repo_2\"}}\n This is Repo 2\n {{/ifEqual}}\n\n Found {{length branches}} branches:\n {{#each branches}}\n Branch: {{displayId}}\n {{/each}}\n\n Found {{length pullRequests}} pull-requests:\n {{#each pullRequests}}\n Pull-request: {{id}}\n From: {{fromRef.latestCommit}}\n {{#commit fromRef.latestCommit}}\n Commit author slug: {{author.slug}}\n {{/commit}}\n {{/each}}\n {{/each}}\n ";
var actual = (0, render_string_1.default)({ state: state, context: state, template: template });
expect(actual).toMatchInlineSnapshot("\n \"\n year: 2020\n month: 2\n day: 3\n\n commit: \n Commit author slug: 123123123\n\n\n Found 2 repositories.\n Repository: PROJ_1 / repo_1 with 2 commits.\n\n\n Found 2 branches:\n Branch: master\n Branch: some-feature\n\n Found 2 pull-requests:\n Pull-request: 128\n From: 222222d1d6c87172cf2dea0f3c18df6ed687ead4\n Commit author slug: 123123123\n Pull-request: 129\n From: 222222d1d6c87172cf2dea0f3c18df6ed687ead4\n Commit author slug: 123123123\n Repository: PROJ_1 / repo_2 with 1 commits.\n\n This is Repo 2\n\n Found 1 branches:\n Branch: master\n\n Found 0 pull-requests:\n \"\n ");
});
//# sourceMappingURL=render-string.spec.js.map