Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions __tests__/__snapshots__/providers.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`GitHub Providers mappers Should map organization data correctly 1`] = `
{
"advanced_security_enabled_for_new_repositories": false,
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"blog": "https://github.com/blog",
"collaborators": 8,
"company": "GitHub",
"default_repository_permission": "read",
"dependabot_alerts_enabled_for_new_repositories": false,
"dependabot_security_updates_enabled_for_new_repositories": false,
"dependency_graph_enabled_for_new_repositories": false,
"deploy_keys_enabled_for_repositories": false,
"description": "A great organization",
"disk_usage": 10000,
"followers": 20,
"following": 0,
"github_archived_at": undefined,
"github_created_at": "2008-01-14T04:33:35Z",
"github_org_id": 1,
"github_updated_at": "2014-03-03T18:58:10Z",
"has_organization_projects": true,
"has_repository_projects": true,
"html_url": "https://github.com/octocat",
"is_verified": true,
"location": "San Francisco",
"login": "github",
"members_allowed_repository_creation_type": "all",
"members_can_create_internal_repositories": false,
"members_can_create_pages": true,
"members_can_create_private_pages": true,
"members_can_create_private_repositories": false,
"members_can_create_public_pages": true,
"members_can_create_public_repositories": false,
"members_can_create_repositories": true,
"members_can_fork_private_repositories": false,
"name": "github",
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE=",
"owned_private_repos": 100,
"private_gists": 81,
"public_gists": 1,
"public_repos": 2,
"secret_scanning_enabled_for_new_repositories": false,
"secret_scanning_push_protection_custom_link": "https://github.com/octo-org/octo-repo/blob/main/im-blocked.md",
"secret_scanning_push_protection_custom_link_enabled": false,
"secret_scanning_push_protection_enabled_for_new_repositories": false,
"total_private_repos": 100,
"twitter_username": "github",
"two_factor_requirement_enabled": true,
"url": "https://api.github.com/orgs/github",
"web_commit_signoff_required": false,
}
`;

exports[`GitHub Providers mappers Should map repository data correctly 1`] = `
{
"allow_auto_merge": false,
"allow_forking": true,
"allow_merge_commit": true,
"allow_rebase_merge": true,
"allow_squash_merge": true,
"archived": false,
"clone_url": "https://github.com/octocat/Hello-World.git",
"default_branch": "master",
"delete_branch_on_merge": true,
"dependabot_security_updates_status": undefined,
"description": "This your first repo!",
"disabled": false,
"fork": false,
"forks_count": 9,
"full_name": "octocat/Hello-World",
"git_url": "git:github.com/octocat/Hello-World.git",
"github_archived_at": undefined,
"github_created_at": "2011-01-26T19:01:12Z",
"github_repo_id": 1296269,
"github_updated_at": "2011-01-26T19:14:43Z",
"has_discussions": false,
"has_downloads": true,
"has_issues": true,
"has_pages": false,
"has_projects": true,
"has_wiki": true,
"homepage": "https://github.com",
"html_url": "https://github.com/octocat/Hello-World",
"is_template": false,
"license_key": "mit",
"license_name": "MIT License",
"license_node_id": "MDc6TGljZW5zZW1pdA==",
"license_spdx_id": "MIT",
"license_url": "https://api.github.com/licenses/mit",
"mirror_url": "git:git.example.com/octocat/Hello-World",
"name": "Hello-World",
"network_count": 0,
"node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5",
"open_issues_count": 0,
"secret_scanning_non_provider_patterns_status": undefined,
"secret_scanning_push_protection_status": undefined,
"secret_scanning_status": undefined,
"secret_scanning_validity_checks_status": undefined,
"size": 108,
"ssh_url": "git@github.com:octocat/Hello-World.git",
"stargazers_count": 80,
"subscribers_count": 42,
"svn_url": "https://svn.github.com/octocat/Hello-World",
"topics": [
"octocat",
"atom",
"electron",
"api",
],
"url": "https://api.github.com/repos/octocat/Hello-World",
"visibility": "public",
"watchers_count": 80,
}
`;
37 changes: 37 additions & 0 deletions __tests__/providers.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const { github } = require('../src/providers')
const {
sampleGithubOrg,
sampleGithubRepository
} = require('../__fixtures__')

describe('GitHub Providers', () => {
describe('fetchOrgByLogin', () => {
it.todo('Should fetch organization by login')
it.todo('Should throw an error if the organization does not exist')
it.todo('Should throw an error if there are network issues')
})

describe('fetchOrgReposListByLogin', () => {
it.todo('Should fetch organization repositories by login')
it.todo('Should throw an error if the organization does not exist')
it.todo('Should throw an error if there are network issues')
})

describe('fetchRepoByFullName', () => {
it.todo('Should fetch repository by full name')
it.todo('Should throw an error if the repository does not exist')
it.todo('Should throw an error if there are network issues')
})

describe('mappers', () => {
it('Should map organization data correctly', () => {
const mappedData = github.mappers.org(sampleGithubOrg)
expect(mappedData).toMatchSnapshot()
})

it('Should map repository data correctly', () => {
const mappedData = github.mappers.repo(sampleGithubRepository)
expect(mappedData).toMatchSnapshot()
})
})
})
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default {
'<rootDir>/__tests__/',
'<rootDir>/__utils__/',
'<rootDir>/src/database/migrations/',
'<rootDir>/src/database/seeds/',
'<rootDir>/src/config/'
],
transformIgnorePatterns: [
Expand Down