Skip to content

Commit df1a703

Browse files
authored
Merge pull request #35 from secure-dashboards/feat/add-seeds
2 parents 0e91fd0 + 65a16e6 commit df1a703

File tree

3 files changed

+154
-0
lines changed

3 files changed

+154
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`GitHub Providers mappers Should map organization data correctly 1`] = `
4+
{
5+
"advanced_security_enabled_for_new_repositories": false,
6+
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
7+
"blog": "https://github.com/blog",
8+
"collaborators": 8,
9+
"company": "GitHub",
10+
"default_repository_permission": "read",
11+
"dependabot_alerts_enabled_for_new_repositories": false,
12+
"dependabot_security_updates_enabled_for_new_repositories": false,
13+
"dependency_graph_enabled_for_new_repositories": false,
14+
"deploy_keys_enabled_for_repositories": false,
15+
"description": "A great organization",
16+
"disk_usage": 10000,
17+
"followers": 20,
18+
"following": 0,
19+
"github_archived_at": undefined,
20+
"github_created_at": "2008-01-14T04:33:35Z",
21+
"github_org_id": 1,
22+
"github_updated_at": "2014-03-03T18:58:10Z",
23+
"has_organization_projects": true,
24+
"has_repository_projects": true,
25+
"html_url": "https://github.com/octocat",
26+
"is_verified": true,
27+
"location": "San Francisco",
28+
"login": "github",
29+
"members_allowed_repository_creation_type": "all",
30+
"members_can_create_internal_repositories": false,
31+
"members_can_create_pages": true,
32+
"members_can_create_private_pages": true,
33+
"members_can_create_private_repositories": false,
34+
"members_can_create_public_pages": true,
35+
"members_can_create_public_repositories": false,
36+
"members_can_create_repositories": true,
37+
"members_can_fork_private_repositories": false,
38+
"name": "github",
39+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE=",
40+
"owned_private_repos": 100,
41+
"private_gists": 81,
42+
"public_gists": 1,
43+
"public_repos": 2,
44+
"secret_scanning_enabled_for_new_repositories": false,
45+
"secret_scanning_push_protection_custom_link": "https://github.com/octo-org/octo-repo/blob/main/im-blocked.md",
46+
"secret_scanning_push_protection_custom_link_enabled": false,
47+
"secret_scanning_push_protection_enabled_for_new_repositories": false,
48+
"total_private_repos": 100,
49+
"twitter_username": "github",
50+
"two_factor_requirement_enabled": true,
51+
"url": "https://api.github.com/orgs/github",
52+
"web_commit_signoff_required": false,
53+
}
54+
`;
55+
56+
exports[`GitHub Providers mappers Should map repository data correctly 1`] = `
57+
{
58+
"allow_auto_merge": false,
59+
"allow_forking": true,
60+
"allow_merge_commit": true,
61+
"allow_rebase_merge": true,
62+
"allow_squash_merge": true,
63+
"archived": false,
64+
"clone_url": "https://github.com/octocat/Hello-World.git",
65+
"default_branch": "master",
66+
"delete_branch_on_merge": true,
67+
"dependabot_security_updates_status": undefined,
68+
"description": "This your first repo!",
69+
"disabled": false,
70+
"fork": false,
71+
"forks_count": 9,
72+
"full_name": "octocat/Hello-World",
73+
"git_url": "git:github.com/octocat/Hello-World.git",
74+
"github_archived_at": undefined,
75+
"github_created_at": "2011-01-26T19:01:12Z",
76+
"github_repo_id": 1296269,
77+
"github_updated_at": "2011-01-26T19:14:43Z",
78+
"has_discussions": false,
79+
"has_downloads": true,
80+
"has_issues": true,
81+
"has_pages": false,
82+
"has_projects": true,
83+
"has_wiki": true,
84+
"homepage": "https://github.com",
85+
"html_url": "https://github.com/octocat/Hello-World",
86+
"is_template": false,
87+
"license_key": "mit",
88+
"license_name": "MIT License",
89+
"license_node_id": "MDc6TGljZW5zZW1pdA==",
90+
"license_spdx_id": "MIT",
91+
"license_url": "https://api.github.com/licenses/mit",
92+
"mirror_url": "git:git.example.com/octocat/Hello-World",
93+
"name": "Hello-World",
94+
"network_count": 0,
95+
"node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5",
96+
"open_issues_count": 0,
97+
"secret_scanning_non_provider_patterns_status": undefined,
98+
"secret_scanning_push_protection_status": undefined,
99+
"secret_scanning_status": undefined,
100+
"secret_scanning_validity_checks_status": undefined,
101+
"size": 108,
102+
"ssh_url": "[email protected]:octocat/Hello-World.git",
103+
"stargazers_count": 80,
104+
"subscribers_count": 42,
105+
"svn_url": "https://svn.github.com/octocat/Hello-World",
106+
"topics": [
107+
"octocat",
108+
"atom",
109+
"electron",
110+
"api",
111+
],
112+
"url": "https://api.github.com/repos/octocat/Hello-World",
113+
"visibility": "public",
114+
"watchers_count": 80,
115+
}
116+
`;

__tests__/providers.test.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const { github } = require('../src/providers')
2+
const {
3+
sampleGithubOrg,
4+
sampleGithubRepository
5+
} = require('../__fixtures__')
6+
7+
describe('GitHub Providers', () => {
8+
describe('fetchOrgByLogin', () => {
9+
it.todo('Should fetch organization by login')
10+
it.todo('Should throw an error if the organization does not exist')
11+
it.todo('Should throw an error if there are network issues')
12+
})
13+
14+
describe('fetchOrgReposListByLogin', () => {
15+
it.todo('Should fetch organization repositories by login')
16+
it.todo('Should throw an error if the organization does not exist')
17+
it.todo('Should throw an error if there are network issues')
18+
})
19+
20+
describe('fetchRepoByFullName', () => {
21+
it.todo('Should fetch repository by full name')
22+
it.todo('Should throw an error if the repository does not exist')
23+
it.todo('Should throw an error if there are network issues')
24+
})
25+
26+
describe('mappers', () => {
27+
it('Should map organization data correctly', () => {
28+
const mappedData = github.mappers.org(sampleGithubOrg)
29+
expect(mappedData).toMatchSnapshot()
30+
})
31+
32+
it('Should map repository data correctly', () => {
33+
const mappedData = github.mappers.repo(sampleGithubRepository)
34+
expect(mappedData).toMatchSnapshot()
35+
})
36+
})
37+
})

jest.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export default {
77
'<rootDir>/__tests__/',
88
'<rootDir>/__utils__/',
99
'<rootDir>/src/database/migrations/',
10+
'<rootDir>/src/database/seeds/',
1011
'<rootDir>/src/config/'
1112
],
1213
transformIgnorePatterns: [

0 commit comments

Comments
 (0)