Skip to content

Commit

Permalink
feat(tests): add tests for constants (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
virgofx authored Oct 28, 2024
1 parent 036733a commit ece7b85
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
52 changes: 52 additions & 0 deletions __tests__/constants.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import {
BRANDING_COMMENT,
BRANDING_WIKI,
GITHUB_ACTIONS_BOT_EMAIL,
GITHUB_ACTIONS_BOT_NAME,
PROJECT_URL,
PR_RELEASE_MARKER,
PR_SUMMARY_MARKER,
WIKI_TITLE_REPLACEMENTS,
} from '../src/constants';

describe('constants', () => {
it('should have the correct GitHub Actions bot name', () => {
expect(GITHUB_ACTIONS_BOT_NAME).toBe('GitHub Actions');
});

it('should have the correct GitHub Actions bot email', () => {
expect(GITHUB_ACTIONS_BOT_EMAIL).toBe('41898282+github-actions[bot]@users.noreply.github.com');
});

it('should have the correct PR summary marker', () => {
expect(PR_SUMMARY_MARKER).toBe('<!-- techpivot/terraform-module-releaser — pr-summary-marker -->');
});

it('should have the correct PR release marker', () => {
expect(PR_RELEASE_MARKER).toBe('<!-- techpivot/terraform-module-releaser — release-marker -->');
});

it('should have the correct project URL', () => {
expect(PROJECT_URL).toBe('https://github.com/techpivot/terraform-module-releaser');
});

it('should have the correct branding comment HTML', () => {
const expectedBrandingComment = `<h4 align="center"><sub align="middle">Powered by <img src="https://raw.githubusercontent.com/techpivot/terraform-module-releaser/refs/heads/main/assets/github-mark-top-padding.png" height="16" width="12" align="top" /> <a href="${PROJECT_URL}">techpivot/terraform-module-releaser</a></sub></h4>`;
expect(BRANDING_COMMENT).toBe(expectedBrandingComment);
});

it('should have the correct branding wiki HTML', () => {
const expectedBrandingWiki = `<h4 align="center">Powered by <img src="https://raw.githubusercontent.com/techpivot/terraform-module-releaser/refs/heads/main/assets/github-mark-12x14.png" height="14" width="12" align="top" /> <a href="${PROJECT_URL}">techpivot/terraform-module-releaser</a></h4>`;
expect(BRANDING_WIKI).toBe(expectedBrandingWiki);
});

describe('WIKI_TITLE_REPLACEMENTS', () => {
it('should replace forward slash with division slash', () => {
expect(WIKI_TITLE_REPLACEMENTS['/']).toBe('∕');
});

it('should replace hyphen with figure dash', () => {
expect(WIKI_TITLE_REPLACEMENTS['-']).toBe('‒');
});
});
});
2 changes: 1 addition & 1 deletion assets/coverage-badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ece7b85

Please sign in to comment.