Skip to content

Commit

Permalink
test(link): add more coverage for the creation of link
Browse files Browse the repository at this point in the history
  • Loading branch information
C0ZEN committed Nov 5, 2021
1 parent 84ecb34 commit 95078df
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 22 deletions.
28 changes: 14 additions & 14 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Editor configuration, see https://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = lf

[*.md]
max_line_length = off
trim_trailing_whitespace = false
# Editor configuration, see https://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
end_of_line = lf

[*.md]
max_line_length = off
trim_trailing_whitespace = false
6 changes: 3 additions & 3 deletions .gitconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[alias]
branch-name = "!git rev-parse --abbrev-ref HEAD"
push-upstream = "!f(){ git push -u origin $(git branch-name); };f"
[alias]
branch-name = "!git rev-parse --abbrev-ref HEAD"
push-upstream = "!f(){ git push -u origin $(git branch-name); };f"
8 changes: 4 additions & 4 deletions .github/issue_label_bot.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
label-alias:
bug: 'bug'
feature_request: 'feature-request'
question: 'question'
label-alias:
bug: 'bug'
feature_request: 'feature-request'
question: 'question'
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
access=public
access=public
27 changes: 27 additions & 0 deletions src/utils/link/create-link.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { createLink } from './create-link';
import * as faker from 'faker';
import * as TerminalLinkModule from 'terminal-link';

describe(`createLink()`, (): void => {
let name: string;
let link: string;

let terminalLinkSpy: jest.SpyInstance;

beforeEach((): void => {
name = faker.random.word();
link = faker.internet.url();

terminalLinkSpy = jest.spyOn(TerminalLinkModule, `default`).mockReturnValue(`dummy-link`);
});

it(`should create a link formatted for a terminal and return it`, (): void => {
expect.assertions(3);

const result = createLink(name, link);

expect(terminalLinkSpy).toHaveBeenCalledTimes(1);
expect(terminalLinkSpy).toHaveBeenCalledWith(name, link);
expect(result).toStrictEqual(`dummy-link`);
});
});

0 comments on commit 95078df

Please sign in to comment.