Skip to content

Commit

Permalink
projects test.
Browse files Browse the repository at this point in the history
  • Loading branch information
bradgarropy committed Jan 26, 2022
1 parent 9c735e9 commit 2b2fb0e
Show file tree
Hide file tree
Showing 4 changed files with 352 additions and 5 deletions.
339 changes: 337 additions & 2 deletions src/test-utils/mocks/api.ts
Expand Up @@ -50,7 +50,7 @@ const mockTestimonialsResponse = [
},
]

const mockGitHubResponse = {
const mockGitHubSponsorsResponse = {
user: {
sponsorshipsAsMaintainer: {
nodes: [
Expand Down Expand Up @@ -107,8 +107,343 @@ const mockGitHubResponse = {
},
}

const mockGitHubPinnedResponse = {
user: {
pinnedItems: {
nodes: [
{
url: "https://github.com/bradgarropy/bradgarropy.com",
name: "bradgarropy.com",
description: "🏠 my home on the web",
stargazerCount: 35,
repositoryTopics: {
nodes: [
{
topic: {
name: "gatsby",
},
},
{
topic: {
name: "react",
},
},
{
topic: {
name: "eslint",
},
},
{
topic: {
name: "blog",
},
},
{
topic: {
name: "portfolio",
},
},
{
topic: {
name: "hacktoberfest",
},
},
],
},
},
{
url: "https://github.com/bradgarropy/dailytexascountry.com",
name: "dailytexascountry.com",
description: "🤠 texas country music community",
stargazerCount: 3,
repositoryTopics: {
nodes: [
{
topic: {
name: "gatsby",
},
},
{
topic: {
name: "react",
},
},
{
topic: {
name: "styled-components",
},
},
{
topic: {
name: "prettier",
},
},
{
topic: {
name: "eslint",
},
},
{
topic: {
name: "spotify",
},
},
{
topic: {
name: "youtube",
},
},
{
topic: {
name: "twitter",
},
},
{
topic: {
name: "airtable",
},
},
{
topic: {
name: "blog",
},
},
{
topic: {
name: "playlists",
},
},
{
topic: {
name: "episodes",
},
},
{
topic: {
name: "store",
},
},
{
topic: {
name: "dtxc",
},
},
{
topic: {
name: "daily-texas-country",
},
},
{
topic: {
name: "texas-country",
},
},
{
topic: {
name: "country",
},
},
],
},
},
{
url: "https://github.com/bradgarropy/hue-sdk",
name: "hue-sdk",
description: "💡 philips hue sdk",
stargazerCount: 35,
repositoryTopics: {
nodes: [
{
topic: {
name: "node",
},
},
{
topic: {
name: "eslint",
},
},
{
topic: {
name: "prettier",
},
},
{
topic: {
name: "philips",
},
},
{
topic: {
name: "hue",
},
},
{
topic: {
name: "sdk",
},
},
{
topic: {
name: "typescript",
},
},
],
},
},
{
url: "https://github.com/bradgarropy/use-countdown",
name: "use-countdown",
description: "⏳ useCountdown hook",
stargazerCount: 47,
repositoryTopics: {
nodes: [
{
topic: {
name: "typescript",
},
},
{
topic: {
name: "react",
},
},
{
topic: {
name: "react-hook",
},
},
{
topic: {
name: "countdown",
},
},
],
},
},
{
url: "https://github.com/bradgarropy/labman-cli",
name: "labman-cli",
description: "👨🏼‍🔬 github label manager cli",
stargazerCount: 12,
repositoryTopics: {
nodes: [
{
topic: {
name: "github",
},
},
{
topic: {
name: "issues",
},
},
{
topic: {
name: "labels",
},
},
{
topic: {
name: "octokit",
},
},
{
topic: {
name: "javascript",
},
},
{
topic: {
name: "nodejs",
},
},
{
topic: {
name: "cli",
},
},
{
topic: {
name: "node",
},
},
],
},
},
{
url: "https://github.com/bradgarropy/murphy",
name: "murphy",
description: "⏱ the crossfit murph timer",
stargazerCount: 9,
repositoryTopics: {
nodes: [
{
topic: {
name: "svelte",
},
},
{
topic: {
name: "faunadb",
},
},
{
topic: {
name: "netlify",
},
},
{
topic: {
name: "netlify-identity",
},
},
{
topic: {
name: "rollup",
},
},
{
topic: {
name: "murph",
},
},
{
topic: {
name: "murphy",
},
},
{
topic: {
name: "crossfit",
},
},
{
topic: {
name: "workout",
},
},
{
topic: {
name: "timer",
},
},
{
topic: {
name: "tailwind",
},
},
],
},
},
],
},
},
}

export {
mockGitHubResponse,
mockGitHubPinnedResponse,
mockGitHubSponsorsResponse,
mockTestimonialsPaths,
mockTestimonialsResponse,
mockYoutubeResponse,
Expand Down
1 change: 0 additions & 1 deletion src/test-utils/mocks/data.ts
Expand Up @@ -109,7 +109,6 @@ const mockProjects: Project[] = [
"country",
],
},

{
url: "https://github.com/bradgarropy/hue-sdk",
name: "hue-sdk",
Expand Down
13 changes: 13 additions & 0 deletions src/utils/projects.test.ts
@@ -0,0 +1,13 @@
import {graphql} from "@octokit/graphql"
import {mockGitHubPinnedResponse, mockProjects} from "test-utils/mocks"
import {getFeaturedProjects} from "utils/projects"

jest.mock("@octokit/graphql")

const mockOctokit = graphql.defaults as jest.Mock
mockOctokit.mockReturnValue(() => mockGitHubPinnedResponse)

test("gets featured projects", async () => {
const projects = await getFeaturedProjects()
expect(projects).toEqual(mockProjects)
})
4 changes: 2 additions & 2 deletions src/utils/sponsors.test.ts
@@ -1,11 +1,11 @@
import {graphql} from "@octokit/graphql"
import {mockGitHubResponse, mockSponsors} from "test-utils/mocks"
import {mockGitHubSponsorsResponse, mockSponsors} from "test-utils/mocks"
import {getSponsors} from "utils/sponsors"

jest.mock("@octokit/graphql")

const mockOctokit = graphql.defaults as jest.Mock
mockOctokit.mockReturnValue(() => mockGitHubResponse)
mockOctokit.mockReturnValue(() => mockGitHubSponsorsResponse)

test("gets sponsors", async () => {
const sponsors = await getSponsors()
Expand Down

1 comment on commit 2b2fb0e

@vercel
Copy link

@vercel vercel bot commented on 2b2fb0e Jan 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.