Skip to content

Commit

Permalink
test: add theme
Browse files Browse the repository at this point in the history
  • Loading branch information
LuciNyan committed Feb 28, 2024
1 parent 1ed7a22 commit 7250418
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/pixel-profile/src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ type Theme = Record<
>

export const THEME: Theme = {
monica: {
summer: {
color: 'white',
background: 'linear-gradient(to bottom right, #0c7bb3, #f2bae8)'
background: 'linear-gradient(to bottom right, #74dcc4, #4597e9)'
},
blue_chill: {
color: 'white',
background: 'linear-gradient(to bottom right, #5580eb, #2aeeff)'
},
rainbow: {
color: 'white',
Expand All @@ -19,13 +23,9 @@ export const THEME: Theme = {
'#79c300 57.12%, #1961ae 57.12%, #1961ae 71.4%, #31137c 71.4%, ' +
'#31137c 85.24%, #61007d 85.24%, #61007d 100%)'
},
summer: {
color: 'white',
background: 'linear-gradient(to bottom right, #74dcc4, #4597e9)'
},
blue_chill: {
monica: {
color: 'white',
background: 'linear-gradient(to bottom right, #5580eb, #2aeeff)'
background: 'linear-gradient(to bottom right, #0c7bb3, #f2bae8)'
}
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 68 additions & 0 deletions packages/pixel-profile/test/theme.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { renderStats } from '../src'
// @ts-expect-error ...
import { toMatchImageSnapshot } from 'jest-image-snapshot'
import { describe, expect, it } from 'vitest'

declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace jest {
interface Matchers<R> {
toMatchImageSnapshot(): R
}
}
}

expect.extend({ toMatchImageSnapshot })

const stats = {
name: 'User Name',
username: 'username',
totalStars: 999,
totalCommits: 99999,
totalIssues: 99,
totalPRs: 9,
contributedTo: 9999,
avatarUrl: '',
rank: {
level: 'S',
percentile: 0,
score: 0
}
}

describe('Theme', () => {
it('Render card with summer theme and custom color', async () => {
const png = await renderStats(stats, { theme: 'summer', color: 'yellow' })
expect(png).toMatchImageSnapshot()
})

it('Render card with summer theme and custom background', async () => {
const png = await renderStats(stats, { theme: 'summer', background: 'black' })
expect(png).toMatchImageSnapshot()
})

it('Render card with summer theme and screen effect', async () => {
const png = await renderStats(stats, { theme: 'summer', screenEffect: true })
expect(png).toMatchImageSnapshot()
})

it('Render card with summer theme', async () => {
const png = await renderStats(stats, { theme: 'summer' })
expect(png).toMatchImageSnapshot()
})

it('Render card with blue_chill theme', async () => {
const png = await renderStats(stats, { theme: 'blue_chill' })
expect(png).toMatchImageSnapshot()
})

it('Render card with rainbow theme', async () => {
const png = await renderStats(stats, { theme: 'rainbow' })
expect(png).toMatchImageSnapshot()
})

it('Render card with monica theme', async () => {
const png = await renderStats(stats, { theme: 'monica' })
expect(png).toMatchImageSnapshot()
})
})

0 comments on commit 7250418

Please sign in to comment.