Skip to content

Commit

Permalink
[#225] Clean up code comments and mocks (#226)
Browse files Browse the repository at this point in the history
Make use of Jest's automocking for automatically mocking the whole
`client` module with `jest.mock`. This automatically sets all exports of
the module to mock functions (jest.fn()).

Align the module level documentation to use multi-line comments.

[closes #225]
  • Loading branch information
klappradla authored Apr 16, 2020
1 parent f30a1e2 commit 3e420c9
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 25 deletions.
16 changes: 13 additions & 3 deletions src/common/adapters/github.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
/**
* GitHub and GitHub Enterprise adapter
*
* The adapter uses the DOM to extract ticket information from issues.
*/

import { $all, $has, $text, $value } from './helpers';

// Element classes on GitHub have slightly changed over time.
// To maintain support for some older GitHub Enterprise instances,
// the adapter will attempt different versions of selectors.
/**
* DOM selectors
*
* Element classes on GitHub have slightly changed over time.
* To maintain support for some older GitHub Enterprise instances, the adapter
* will attempt different versions of selectors.
*/
export const selectors = {
default: {
issuesPage: '.js-check-all-container .js-issue-row.selected',
Expand Down
6 changes: 6 additions & 0 deletions src/common/adapters/gitlab.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* Gitlab adapter
*
* The adapter uses the DOM to extract information about tickets.
*/

import { $has, $text } from './helpers';

async function scan(loc, doc) {
Expand Down
23 changes: 13 additions & 10 deletions src/common/adapters/jira.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// Jira adapter
//
// This adapter extracts the identifier of the selected issue from the page URL
// and uses the Jira API to retrieve the corresponding ticket information.
//
// https://developer.atlassian.com/server/jira/platform/rest-apis/
//
// * Backlog and Active Sprints: https://<YOUR-SUBDOMAIN>.atlassian.net/secure/RapidBoard.jspa?…&selectedIssue=<ISSUE-KEY>
// * Issues and filters: https://<YOUR-SUBDOMAIN>.atlassian.net/projects/<PROJECT-KEY>/issues/<ISSUE-KEY>
// * Issue view: https://<YOUR-SUBDOMAIN>.atlassian.net/browse/<ISSUE-KEY>
/**
* Jira adapter
*
* The adapter extracts the identifier of the selected issue from the page URL
* and uses the Jira API to retrieve the corresponding ticket information.
*
* https://developer.atlassian.com/server/jira/platform/rest-apis/
*
* Supported page URLs:
* - Backlog and Active Sprints: https://<YOUR-SUBDOMAIN>.atlassian.net/secure/RapidBoard.jspa?…&selectedIssue=<ISSUE-KEY>
* - Issues and filters: https://<YOUR-SUBDOMAIN>.atlassian.net/projects/<PROJECT-KEY>/issues/<ISSUE-KEY>
* - Issue view: https://<YOUR-SUBDOMAIN>.atlassian.net/browse/<ISSUE-KEY>
*/

import { match } from 'micro-match';

Expand Down
2 changes: 1 addition & 1 deletion src/common/adapters/jira.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import client from '../client';
import loc from './__helpers__/location';
import scan from './jira';

jest.mock('../client', () => jest.fn());
jest.mock('../client');

const key = 'RC-654';

Expand Down
2 changes: 1 addition & 1 deletion src/common/adapters/notion.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import client from '../client';
import loc from './__helpers__/location';
import scan from './notion';

jest.mock('../client', () => jest.fn());
jest.mock('../client');

describe('notion adapter', () => {
const id = '5b1d7dd7-9107-4890-b2ec-83175b8eda83';
Expand Down
20 changes: 11 additions & 9 deletions src/common/adapters/trello.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// Trello adapter
//
// This adapter extracts the identifier of the selected card (short link) from
// the page URL and uses the Trello API to retrieve the corresponding card
// information.
//
// https://developers.trello.com/v1.0/reference#introduction
//
// Card view: https://trello.com/c/<SHORT-LINK>/1-ticket-title
/**
* Trello adapter
*
* The adapter extracts the identifier of the selected card (short link) from
* the page URL and uses the Trello API to retrieve the corresponding card
* information.
*
* https://developers.trello.com/v1.0/reference#introduction
*
* Card view: https://trello.com/c/<SHORT-LINK>/1-ticket-title
*/

import { match } from 'micro-match';

Expand Down
2 changes: 1 addition & 1 deletion src/common/adapters/trello.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import client from '../client';
import loc from './__helpers__/location';
import scan from './trello';

jest.mock('../client', () => jest.fn());
jest.mock('../client');

const key = 'haKn65Sy';

Expand Down

0 comments on commit 3e420c9

Please sign in to comment.