Skip to content

Commit

Permalink
tests: add remaining tests for identity features in SitesService (#566)
Browse files Browse the repository at this point in the history
* chore: define more specific constants for source of URLs

* chore: move siteUrls type to repoInfo

* tests: add remaining tests for identity features

* tests: add spy method to check if extractAuthorEmail was called
  • Loading branch information
dcshzj authored and alexanderleegs committed Mar 16, 2023
1 parent e1b1ba5 commit c7b11cb
Show file tree
Hide file tree
Showing 5 changed files with 668 additions and 33 deletions.
2 changes: 2 additions & 0 deletions src/fixtures/identity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,5 @@ export const MOCK_COMMIT_MESSAGE_OBJECT_TWO = {
fileName: MOCK_COMMIT_FILENAME_TWO,
userId: mockIsomerUserId,
}

export const MOCK_COMMON_ACCESS_TOKEN_GITHUB_NAME = "isomergithub1"
13 changes: 11 additions & 2 deletions src/fixtures/repoInfo.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import { GitHubRepositoryData } from "@root/types/repoInfo"

export const MOCK_STAGING_URL_GITHUB = "https://repo-staging.netlify.app"
export const MOCK_STAGING_URL_CONFIGYML =
"https://repo-staging-configyml.netlify.app"
export const MOCK_STAGING_URL_DB = "https://repo-staging-db.netlify.app"

export const MOCK_PRODUCTION_URL_GITHUB = "https://repo-prod.netlify.app"
export const MOCK_PRODUCTION_URL_CONFIGYML =
"https://repo-prod-configyml.netlify.app"
export const MOCK_PRODUCTION_URL_DB = "https://repo-prod-db.netlify.app"

export const repoInfo: GitHubRepositoryData = {
name: "repo",
private: false,
description:
"Staging: https://repo-staging.netlify.app | Production: https://repo-prod.netlify.app",
description: `Staging: ${MOCK_STAGING_URL_GITHUB} | Production: ${MOCK_PRODUCTION_URL_GITHUB}`,
pushed_at: "2021-09-09T02:41:37Z",
permissions: {
admin: true,
Expand Down
9 changes: 5 additions & 4 deletions src/services/identity/SitesService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ import { UnprocessableError } from "@root/errors/UnprocessableError"
import { genericGitHubAxiosInstance } from "@root/services/api/AxiosInstance"
import { GitHubCommitData } from "@root/types/commitData"
import { ConfigYmlData } from "@root/types/configYml"
import type { GitHubRepositoryData, RepositoryData } from "@root/types/repoInfo"
import type {
GitHubRepositoryData,
RepositoryData,
SiteUrls,
} from "@root/types/repoInfo"
import { SiteInfo } from "@root/types/siteInfo"
import { GitHubService } from "@services/db/GitHubService"
import { ConfigYmlService } from "@services/fileServices/YmlFileServices/ConfigYmlService"
Expand All @@ -33,9 +37,6 @@ interface SitesServiceProps {
reviewRequestService: ReviewRequestService
}

type SiteUrlTypes = "staging" | "prod"
type SiteUrls = { [key in SiteUrlTypes]: string }

class SitesService {
// NOTE: Explicitly specifying using keyed properties to ensure
// that the types are synced.
Expand Down
Loading

0 comments on commit c7b11cb

Please sign in to comment.