@reallukemanning/folio 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/copy-components.js +31 -0
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/core/copy-components.js.html +178 -0
- package/coverage/core/eslint.config.js.html +184 -0
- package/coverage/core/index.html +146 -0
- package/coverage/core/src/__tests__/benchmarks/ProjectCard.bench.tsx.html +364 -0
- package/coverage/core/src/__tests__/benchmarks/ProjectView.bench.tsx.html +484 -0
- package/coverage/core/src/__tests__/benchmarks/github.bench.ts.html +244 -0
- package/coverage/core/src/__tests__/benchmarks/index.html +191 -0
- package/coverage/core/src/__tests__/benchmarks/npm.bench.ts.html +271 -0
- package/coverage/core/src/__tests__/benchmarks/product-hunt.bench.ts.html +259 -0
- package/coverage/core/src/__tests__/benchmarks/utilities.bench.ts.html +478 -0
- package/coverage/core/src/components/FeaturedProject.test.tsx.html +697 -0
- package/coverage/core/src/components/FeaturedProject.tsx.html +163 -0
- package/coverage/core/src/components/ProjectCard/ProjectCard.test.tsx.html +928 -0
- package/coverage/core/src/components/ProjectCard/ProjectCard.tsx.html +379 -0
- package/coverage/core/src/components/ProjectCard/index.html +146 -0
- package/coverage/core/src/components/ProjectCard/index.ts.html +88 -0
- package/coverage/core/src/components/ProjectGrid/ProjectGrid.test.tsx.html +292 -0
- package/coverage/core/src/components/ProjectGrid/ProjectGrid.tsx.html +103 -0
- package/coverage/core/src/components/ProjectGrid/index.html +146 -0
- package/coverage/core/src/components/ProjectGrid/index.ts.html +88 -0
- package/coverage/core/src/components/ProjectList/ProjectList.test.tsx.html +292 -0
- package/coverage/core/src/components/ProjectList/ProjectList.tsx.html +103 -0
- package/coverage/core/src/components/ProjectList/index.html +146 -0
- package/coverage/core/src/components/ProjectList/index.ts.html +88 -0
- package/coverage/core/src/components/ProjectView/ProjectView.test.tsx.html +1108 -0
- package/coverage/core/src/components/ProjectView/ProjectView.tsx.html +589 -0
- package/coverage/core/src/components/ProjectView/index.html +146 -0
- package/coverage/core/src/components/ProjectView/index.ts.html +88 -0
- package/coverage/core/src/components/index.html +146 -0
- package/coverage/core/src/components/index.ts.html +97 -0
- package/coverage/core/src/index.html +116 -0
- package/coverage/core/src/index.ts.html +94 -0
- package/coverage/core/src/lib/__tests__/defineProjects.test.ts.html +421 -0
- package/coverage/core/src/lib/__tests__/filterByFeatured.test.ts.html +523 -0
- package/coverage/core/src/lib/__tests__/filterByStatus.test.ts.html +664 -0
- package/coverage/core/src/lib/__tests__/filterByType.test.ts.html +631 -0
- package/coverage/core/src/lib/__tests__/github.test.ts.html +1783 -0
- package/coverage/core/src/lib/__tests__/hybrid-config.test.ts.html +1345 -0
- package/coverage/core/src/lib/__tests__/index.html +311 -0
- package/coverage/core/src/lib/__tests__/normalise.test.ts.html +1585 -0
- package/coverage/core/src/lib/__tests__/npm-config.test.ts.html +385 -0
- package/coverage/core/src/lib/__tests__/npm.test.ts.html +1135 -0
- package/coverage/core/src/lib/__tests__/product-hunt-config.test.ts.html +397 -0
- package/coverage/core/src/lib/__tests__/product-hunt.test.ts.html +505 -0
- package/coverage/core/src/lib/__tests__/sortByDate.test.ts.html +751 -0
- package/coverage/core/src/lib/__tests__/sortByName.test.ts.html +832 -0
- package/coverage/core/src/lib/__tests__/sortByStars.test.ts.html +703 -0
- package/coverage/core/src/lib/defineProjects.ts.html +100 -0
- package/coverage/core/src/lib/filterByFeatured.ts.html +133 -0
- package/coverage/core/src/lib/filterByStatus.ts.html +145 -0
- package/coverage/core/src/lib/filterByType.ts.html +133 -0
- package/coverage/core/src/lib/github.ts.html +517 -0
- package/coverage/core/src/lib/index.html +281 -0
- package/coverage/core/src/lib/index.ts.html +130 -0
- package/coverage/core/src/lib/normalise.ts.html +868 -0
- package/coverage/core/src/lib/npm.ts.html +199 -0
- package/coverage/core/src/lib/product-hunt.ts.html +256 -0
- package/coverage/core/src/lib/sortByDate.ts.html +175 -0
- package/coverage/core/src/lib/sortByName.ts.html +172 -0
- package/coverage/core/src/lib/sortByStars.ts.html +172 -0
- package/coverage/core/src/types/index.html +116 -0
- package/coverage/core/src/types/index.ts.html +517 -0
- package/coverage/core/vitest.config.ts.html +178 -0
- package/coverage/coverage-final.json +53 -0
- package/coverage/coverage-summary.json +54 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +266 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +210 -0
- package/dist/cli-components/FeaturedProject/FeaturedProject.d.ts +6 -0
- package/dist/cli-components/FeaturedProject/FeaturedProject.d.ts.map +1 -0
- package/dist/cli-components/FeaturedProject/FeaturedProject.js +9 -0
- package/dist/cli-components/FeaturedProject/FeaturedProject.js.map +1 -0
- package/dist/cli-components/FeaturedProject/FeaturedProject.tsx +54 -0
- package/dist/cli-components/FeaturedProject/index.d.ts +3 -0
- package/dist/cli-components/FeaturedProject/index.d.ts.map +1 -0
- package/dist/cli-components/FeaturedProject/index.js +2 -0
- package/dist/cli-components/FeaturedProject/index.js.map +1 -0
- package/dist/cli-components/FeaturedProject/index.ts +2 -0
- package/dist/cli-components/ProjectCard/ProjectCard.d.ts +26 -0
- package/dist/cli-components/ProjectCard/ProjectCard.d.ts.map +1 -0
- package/dist/cli-components/ProjectCard/ProjectCard.js +33 -0
- package/dist/cli-components/ProjectCard/ProjectCard.js.map +1 -0
- package/dist/cli-components/ProjectCard/ProjectCard.tsx +90 -0
- package/dist/cli-components/ProjectCard/index.d.ts +3 -0
- package/dist/cli-components/ProjectCard/index.d.ts.map +1 -0
- package/dist/cli-components/ProjectCard/index.js +2 -0
- package/dist/cli-components/ProjectCard/index.js.map +1 -0
- package/dist/cli-components/ProjectCard/index.ts +2 -0
- package/dist/cli-components/ProjectGrid/ProjectGrid.d.ts +5 -0
- package/dist/cli-components/ProjectGrid/ProjectGrid.d.ts.map +1 -0
- package/dist/cli-components/ProjectGrid/ProjectGrid.js +8 -0
- package/dist/cli-components/ProjectGrid/ProjectGrid.js.map +1 -0
- package/dist/cli-components/ProjectGrid/ProjectGrid.tsx +6 -0
- package/dist/cli-components/ProjectGrid/index.d.ts +3 -0
- package/dist/cli-components/ProjectGrid/index.d.ts.map +1 -0
- package/dist/cli-components/ProjectGrid/index.js +2 -0
- package/dist/cli-components/ProjectGrid/index.js.map +1 -0
- package/dist/cli-components/ProjectGrid/index.ts +2 -0
- package/dist/cli-components/ProjectList/ProjectList.d.ts +5 -0
- package/dist/cli-components/ProjectList/ProjectList.d.ts.map +1 -0
- package/dist/cli-components/ProjectList/ProjectList.js +8 -0
- package/dist/cli-components/ProjectList/ProjectList.js.map +1 -0
- package/dist/cli-components/ProjectList/ProjectList.tsx +6 -0
- package/dist/cli-components/ProjectList/index.d.ts +3 -0
- package/dist/cli-components/ProjectList/index.d.ts.map +1 -0
- package/dist/cli-components/ProjectList/index.js +2 -0
- package/dist/cli-components/ProjectList/index.js.map +1 -0
- package/dist/cli-components/ProjectList/index.ts +2 -0
- package/dist/cli-components/ProjectView/ProjectView.d.ts +17 -0
- package/dist/cli-components/ProjectView/ProjectView.d.ts.map +1 -0
- package/dist/cli-components/ProjectView/ProjectView.js +39 -0
- package/dist/cli-components/ProjectView/ProjectView.js.map +1 -0
- package/dist/cli-components/ProjectView/ProjectView.tsx +117 -0
- package/dist/cli-components/ProjectView/index.d.ts +3 -0
- package/dist/cli-components/ProjectView/index.d.ts.map +1 -0
- package/dist/cli-components/ProjectView/index.js +2 -0
- package/dist/cli-components/ProjectView/index.js.map +1 -0
- package/dist/cli-components/ProjectView/index.ts +2 -0
- package/dist/cli-components/types.d.ts +52 -0
- package/dist/cli-components/types.d.ts.map +1 -0
- package/dist/cli-components/types.js +2 -0
- package/dist/cli-components/types.js.map +1 -0
- package/dist/cli-components/types.ts +58 -0
- package/dist/cli-types.d.ts +52 -0
- package/dist/cli-types.d.ts.map +1 -0
- package/dist/cli-types.js +2 -0
- package/dist/cli-types.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +21 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/add.d.ts +2 -0
- package/dist/commands/add.d.ts.map +1 -0
- package/dist/commands/add.js +166 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/init.d.ts +6 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +231 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/components/FeaturedProject.d.ts +7 -0
- package/dist/components/FeaturedProject.d.ts.map +1 -0
- package/dist/components/FeaturedProject.js +10 -0
- package/dist/components/FeaturedProject.js.map +1 -0
- package/dist/components/FeaturedProject.test.tsx +204 -0
- package/dist/components/FeaturedProject.tsx +26 -0
- package/dist/components/ProjectCard/ProjectCard.d.ts +26 -0
- package/dist/components/ProjectCard/ProjectCard.d.ts.map +1 -0
- package/dist/components/ProjectCard/ProjectCard.js +39 -0
- package/dist/components/ProjectCard/ProjectCard.js.map +1 -0
- package/dist/components/ProjectCard/ProjectCard.test.tsx +281 -0
- package/dist/components/ProjectCard/ProjectCard.tsx +98 -0
- package/dist/components/ProjectCard/index.d.ts +2 -0
- package/dist/components/ProjectCard/index.d.ts.map +1 -0
- package/dist/components/ProjectCard/index.js +2 -0
- package/dist/components/ProjectCard/index.js.map +1 -0
- package/dist/components/ProjectCard/index.ts +1 -0
- package/dist/components/ProjectGrid/ProjectGrid.d.ts +5 -0
- package/dist/components/ProjectGrid/ProjectGrid.d.ts.map +1 -0
- package/dist/components/ProjectGrid/ProjectGrid.js +8 -0
- package/dist/components/ProjectGrid/ProjectGrid.js.map +1 -0
- package/dist/components/ProjectGrid/ProjectGrid.test.tsx +69 -0
- package/dist/components/ProjectGrid/ProjectGrid.tsx +6 -0
- package/dist/components/ProjectGrid/index.d.ts +2 -0
- package/dist/components/ProjectGrid/index.d.ts.map +1 -0
- package/dist/components/ProjectGrid/index.js +2 -0
- package/dist/components/ProjectGrid/index.js.map +1 -0
- package/dist/components/ProjectGrid/index.ts +1 -0
- package/dist/components/ProjectList/ProjectList.d.ts +5 -0
- package/dist/components/ProjectList/ProjectList.d.ts.map +1 -0
- package/dist/components/ProjectList/ProjectList.js +8 -0
- package/dist/components/ProjectList/ProjectList.js.map +1 -0
- package/dist/components/ProjectList/ProjectList.test.tsx +69 -0
- package/dist/components/ProjectList/ProjectList.tsx +6 -0
- package/dist/components/ProjectList/index.d.ts +2 -0
- package/dist/components/ProjectList/index.d.ts.map +1 -0
- package/dist/components/ProjectList/index.js +2 -0
- package/dist/components/ProjectList/index.js.map +1 -0
- package/dist/components/ProjectList/index.ts +1 -0
- package/dist/components/ProjectView/ProjectView.d.ts +20 -0
- package/dist/components/ProjectView/ProjectView.d.ts.map +1 -0
- package/dist/components/ProjectView/ProjectView.js +64 -0
- package/dist/components/ProjectView/ProjectView.js.map +1 -0
- package/dist/components/ProjectView/ProjectView.test.tsx +341 -0
- package/dist/components/ProjectView/ProjectView.tsx +168 -0
- package/dist/components/ProjectView/index.d.ts +2 -0
- package/dist/components/ProjectView/index.d.ts.map +1 -0
- package/dist/components/ProjectView/index.js +2 -0
- package/dist/components/ProjectView/index.js.map +1 -0
- package/dist/components/ProjectView/index.ts +1 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +5 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index.ts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/defineProjects.d.ts +3 -0
- package/dist/lib/defineProjects.d.ts.map +1 -0
- package/dist/lib/defineProjects.js +4 -0
- package/dist/lib/defineProjects.js.map +1 -0
- package/dist/lib/filterByFeatured.d.ts +3 -0
- package/dist/lib/filterByFeatured.d.ts.map +1 -0
- package/dist/lib/filterByFeatured.js +10 -0
- package/dist/lib/filterByFeatured.js.map +1 -0
- package/dist/lib/filterByStatus.d.ts +3 -0
- package/dist/lib/filterByStatus.d.ts.map +1 -0
- package/dist/lib/filterByStatus.js +13 -0
- package/dist/lib/filterByStatus.js.map +1 -0
- package/dist/lib/filterByType.d.ts +3 -0
- package/dist/lib/filterByType.d.ts.map +1 -0
- package/dist/lib/filterByType.js +10 -0
- package/dist/lib/filterByType.js.map +1 -0
- package/dist/lib/github.d.ts +24 -0
- package/dist/lib/github.d.ts.map +1 -0
- package/dist/lib/github.js +107 -0
- package/dist/lib/github.js.map +1 -0
- package/dist/lib/index.d.ts +16 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +12 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/normalise.d.ts +4 -0
- package/dist/lib/normalise.d.ts.map +1 -0
- package/dist/lib/normalise.js +221 -0
- package/dist/lib/normalise.js.map +1 -0
- package/dist/lib/npm.d.ts +7 -0
- package/dist/lib/npm.d.ts.map +1 -0
- package/dist/lib/npm.js +28 -0
- package/dist/lib/npm.js.map +1 -0
- package/dist/lib/product-hunt.d.ts +12 -0
- package/dist/lib/product-hunt.d.ts.map +1 -0
- package/dist/lib/product-hunt.js +40 -0
- package/dist/lib/product-hunt.js.map +1 -0
- package/dist/lib/sortByDate.d.ts +4 -0
- package/dist/lib/sortByDate.d.ts.map +1 -0
- package/dist/lib/sortByDate.js +21 -0
- package/dist/lib/sortByDate.js.map +1 -0
- package/dist/lib/sortByName.d.ts +4 -0
- package/dist/lib/sortByName.d.ts.map +1 -0
- package/dist/lib/sortByName.js +21 -0
- package/dist/lib/sortByName.js.map +1 -0
- package/dist/lib/sortByStars.d.ts +4 -0
- package/dist/lib/sortByStars.d.ts.map +1 -0
- package/dist/lib/sortByStars.js +21 -0
- package/dist/lib/sortByStars.js.map +1 -0
- package/dist/test-setup.d.ts +2 -0
- package/dist/test-setup.d.ts.map +1 -0
- package/dist/test-setup.js +2 -0
- package/dist/test-setup.js.map +1 -0
- package/dist/types/index.d.ts +121 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/eslint.config.js +33 -0
- package/package.json +47 -0
- package/playwright-report/index.html +85 -0
- package/src/__tests__/benchmarks/ProjectCard.bench.tsx +93 -0
- package/src/__tests__/benchmarks/ProjectView.bench.tsx +133 -0
- package/src/__tests__/benchmarks/github.bench.ts +53 -0
- package/src/__tests__/benchmarks/npm.bench.ts +62 -0
- package/src/__tests__/benchmarks/product-hunt.bench.ts +58 -0
- package/src/__tests__/benchmarks/utilities.bench.ts +131 -0
- package/src/cli-components/FeaturedProject/FeaturedProject.tsx +54 -0
- package/src/cli-components/FeaturedProject/index.ts +2 -0
- package/src/cli-components/ProjectCard/ProjectCard.tsx +90 -0
- package/src/cli-components/ProjectCard/index.ts +2 -0
- package/src/cli-components/ProjectGrid/ProjectGrid.tsx +6 -0
- package/src/cli-components/ProjectGrid/index.ts +2 -0
- package/src/cli-components/ProjectList/ProjectList.tsx +6 -0
- package/src/cli-components/ProjectList/index.ts +2 -0
- package/src/cli-components/ProjectView/ProjectView.tsx +117 -0
- package/src/cli-components/ProjectView/index.ts +2 -0
- package/src/cli-components/types.ts +58 -0
- package/src/cli-types.ts +58 -0
- package/src/cli.ts +26 -0
- package/src/commands/add.ts +191 -0
- package/src/commands/init.ts +260 -0
- package/src/components/FeaturedProject.test.tsx +204 -0
- package/src/components/FeaturedProject.tsx +26 -0
- package/src/components/ProjectCard/ProjectCard.test.tsx +281 -0
- package/src/components/ProjectCard/ProjectCard.tsx +98 -0
- package/src/components/ProjectCard/index.ts +1 -0
- package/src/components/ProjectGrid/ProjectGrid.test.tsx +69 -0
- package/src/components/ProjectGrid/ProjectGrid.tsx +6 -0
- package/src/components/ProjectGrid/index.ts +1 -0
- package/src/components/ProjectList/ProjectList.test.tsx +69 -0
- package/src/components/ProjectList/ProjectList.tsx +6 -0
- package/src/components/ProjectList/index.ts +1 -0
- package/src/components/ProjectView/ProjectView.test.tsx +341 -0
- package/src/components/ProjectView/ProjectView.tsx +168 -0
- package/src/components/ProjectView/index.ts +1 -0
- package/src/components/index.ts +4 -0
- package/src/index.ts +3 -0
- package/src/lib/__tests__/defineProjects.test.ts +112 -0
- package/src/lib/__tests__/filterByFeatured.test.ts +146 -0
- package/src/lib/__tests__/filterByStatus.test.ts +193 -0
- package/src/lib/__tests__/filterByType.test.ts +182 -0
- package/src/lib/__tests__/github.test.ts +566 -0
- package/src/lib/__tests__/hybrid-config.test.ts +420 -0
- package/src/lib/__tests__/normalise.test.ts +500 -0
- package/src/lib/__tests__/npm-config.test.ts +100 -0
- package/src/lib/__tests__/npm.test.ts +350 -0
- package/src/lib/__tests__/product-hunt-config.test.ts +104 -0
- package/src/lib/__tests__/product-hunt.test.ts +140 -0
- package/src/lib/__tests__/sortByDate.test.ts +222 -0
- package/src/lib/__tests__/sortByName.test.ts +249 -0
- package/src/lib/__tests__/sortByStars.test.ts +206 -0
- package/src/lib/defineProjects.ts +5 -0
- package/src/lib/filterByFeatured.ts +16 -0
- package/src/lib/filterByStatus.ts +20 -0
- package/src/lib/filterByType.ts +16 -0
- package/src/lib/github.ts +144 -0
- package/src/lib/index.ts +15 -0
- package/src/lib/normalise.ts +261 -0
- package/src/lib/npm.ts +38 -0
- package/src/lib/product-hunt.ts +57 -0
- package/src/lib/sortByDate.ts +30 -0
- package/src/lib/sortByName.ts +29 -0
- package/src/lib/sortByStars.ts +29 -0
- package/src/test-setup.ts +1 -0
- package/src/types/index.ts +144 -0
- package/test-results/.last-run.json +62 -0
- package/tsconfig.json +29 -0
- package/vitest.config.ts +31 -0
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
2
|
+
import { normalise, normalizeStats } from '../normalise'
|
|
3
|
+
import type { ManualProjectInput, GitHubProjectInput, NpmProjectInput, ProductHuntProjectInput } from '../../types'
|
|
4
|
+
import { fetchGitHubRepo } from '../github'
|
|
5
|
+
import { fetchNpmPackage } from '../npm'
|
|
6
|
+
import { fetchProductHuntPost } from '../product-hunt'
|
|
7
|
+
|
|
8
|
+
vi.mock('../github')
|
|
9
|
+
vi.mock('../npm')
|
|
10
|
+
vi.mock('../product-hunt')
|
|
11
|
+
|
|
12
|
+
const mockedFetchGitHubRepo = vi.mocked(fetchGitHubRepo)
|
|
13
|
+
const mockedFetchNpmPackage = vi.mocked(fetchNpmPackage)
|
|
14
|
+
const mockedFetchProductHuntPost = vi.mocked(fetchProductHuntPost)
|
|
15
|
+
|
|
16
|
+
describe('normalise', () => {
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
vi.clearAllMocks()
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
describe('manual project normalization', () => {
|
|
22
|
+
it('should normalize a minimal manual project', async () => {
|
|
23
|
+
const input: ManualProjectInput = {
|
|
24
|
+
id: 'test-manual',
|
|
25
|
+
type: 'manual',
|
|
26
|
+
status: 'active',
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const result = await normalise(input)
|
|
30
|
+
|
|
31
|
+
expect(result.id).toBe('test-manual')
|
|
32
|
+
expect(result.type).toBe('manual')
|
|
33
|
+
expect(result.status).toBe('active')
|
|
34
|
+
expect(result.featured).toBe(false)
|
|
35
|
+
expect(result.name).toBe('')
|
|
36
|
+
expect(result.description).toBe('')
|
|
37
|
+
expect(result.stats).toBeNull()
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('should normalize a manual project with all fields', async () => {
|
|
41
|
+
const input: ManualProjectInput = {
|
|
42
|
+
id: 'full-manual',
|
|
43
|
+
type: 'manual',
|
|
44
|
+
status: 'shipped',
|
|
45
|
+
featured: true,
|
|
46
|
+
name: 'Manual Project',
|
|
47
|
+
tagline: 'A tagline',
|
|
48
|
+
description: 'A description',
|
|
49
|
+
background: 'Background info',
|
|
50
|
+
why: 'Why I built this',
|
|
51
|
+
image: 'https://example.com/image.png',
|
|
52
|
+
struggles: [{ type: 'warn', text: 'A warning' }],
|
|
53
|
+
timeline: [{ date: '2024-01-01', note: 'Started' }],
|
|
54
|
+
posts: [{ title: 'Post', date: '2024-01-01', url: 'https://example.com' }],
|
|
55
|
+
stack: ['React', 'TypeScript'],
|
|
56
|
+
links: { live: 'https://example.com' },
|
|
57
|
+
stats: { stars: 100, downloads: '1000' },
|
|
58
|
+
createdAt: '2024-01-01',
|
|
59
|
+
updatedAt: '2024-06-01',
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const result = await normalise(input)
|
|
63
|
+
|
|
64
|
+
expect(result.name).toBe('Manual Project')
|
|
65
|
+
expect(result.tagline).toBe('A tagline')
|
|
66
|
+
expect(result.description).toBe('A description')
|
|
67
|
+
expect(result.background).toBe('Background info')
|
|
68
|
+
expect(result.why).toBe('Why I built this')
|
|
69
|
+
expect(result.image).toBe('https://example.com/image.png')
|
|
70
|
+
expect(result.struggles).toEqual([{ type: 'warn', text: 'A warning' }])
|
|
71
|
+
expect(result.timeline).toEqual([{ date: '2024-01-01', note: 'Started' }])
|
|
72
|
+
expect(result.posts).toEqual([{ title: 'Post', date: '2024-01-01', url: 'https://example.com' }])
|
|
73
|
+
expect(result.stack).toEqual(['React', 'TypeScript'])
|
|
74
|
+
expect(result.links).toEqual({ live: 'https://example.com' })
|
|
75
|
+
expect(result.stats).toEqual({ stars: 100, downloads: '1000' })
|
|
76
|
+
expect(result.featured).toBe(true)
|
|
77
|
+
expect(result.createdAt).toBe('2024-01-01')
|
|
78
|
+
expect(result.updatedAt).toBe('2024-06-01')
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
it('should not apply override fields for manual project (override only works for github/hybrid)', async () => {
|
|
82
|
+
const input: ManualProjectInput = {
|
|
83
|
+
id: 'override-manual',
|
|
84
|
+
type: 'manual',
|
|
85
|
+
status: 'active',
|
|
86
|
+
name: 'Original Name',
|
|
87
|
+
description: 'Original Description',
|
|
88
|
+
override: {
|
|
89
|
+
name: 'Overridden Name',
|
|
90
|
+
description: 'Overridden Description',
|
|
91
|
+
},
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const result = await normalise(input)
|
|
95
|
+
|
|
96
|
+
expect(result.name).toBe('Original Name')
|
|
97
|
+
expect(result.description).toBe('Original Description')
|
|
98
|
+
})
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
describe('GitHub project normalization', () => {
|
|
102
|
+
it('should normalize a GitHub project with fetched data', async () => {
|
|
103
|
+
mockedFetchGitHubRepo.mockResolvedValue({
|
|
104
|
+
name: 'github-repo',
|
|
105
|
+
description: 'GitHub description',
|
|
106
|
+
stargazers_count: 100,
|
|
107
|
+
forks_count: 20,
|
|
108
|
+
language: 'TypeScript',
|
|
109
|
+
topics: ['react', 'typescript'],
|
|
110
|
+
html_url: 'https://github.com/user/repo',
|
|
111
|
+
homepage: 'https://example.com',
|
|
112
|
+
created_at: '2024-01-01T00:00:00Z',
|
|
113
|
+
updated_at: '2024-06-01T00:00:00Z',
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
const input: GitHubProjectInput = {
|
|
117
|
+
id: 'test-github',
|
|
118
|
+
type: 'github',
|
|
119
|
+
repo: 'user/repo',
|
|
120
|
+
status: 'active',
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const result = await normalise(input)
|
|
124
|
+
|
|
125
|
+
expect(result.name).toBe('github-repo')
|
|
126
|
+
expect(result.description).toBe('GitHub description')
|
|
127
|
+
expect(result.stats).toEqual({ stars: 100, forks: 20 })
|
|
128
|
+
expect(result.language).toBe('TypeScript')
|
|
129
|
+
expect(result.links.github).toBe('https://github.com/user/repo')
|
|
130
|
+
expect(result.links.live).toBe('https://example.com')
|
|
131
|
+
expect(mockedFetchGitHubRepo).toHaveBeenCalledWith('user/repo')
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
it('should handle GitHub fetch failure gracefully', async () => {
|
|
135
|
+
mockedFetchGitHubRepo.mockResolvedValue(null)
|
|
136
|
+
|
|
137
|
+
const input: GitHubProjectInput = {
|
|
138
|
+
id: 'failed-github',
|
|
139
|
+
type: 'github',
|
|
140
|
+
repo: 'user/nonexistent',
|
|
141
|
+
status: 'active',
|
|
142
|
+
name: 'Fallback Name',
|
|
143
|
+
description: 'Fallback Description',
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const result = await normalise(input)
|
|
147
|
+
|
|
148
|
+
expect(result.name).toBe('Fallback Name')
|
|
149
|
+
expect(result.description).toBe('Fallback Description')
|
|
150
|
+
expect(result.stats).toBeNull()
|
|
151
|
+
expect(result.language).toBeNull()
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
it('should use override fields for GitHub project', async () => {
|
|
155
|
+
mockedFetchGitHubRepo.mockResolvedValue({
|
|
156
|
+
name: 'github-name',
|
|
157
|
+
description: 'GitHub description',
|
|
158
|
+
stargazers_count: 100,
|
|
159
|
+
forks_count: 20,
|
|
160
|
+
language: 'TypeScript',
|
|
161
|
+
topics: [],
|
|
162
|
+
html_url: 'https://github.com/user/repo',
|
|
163
|
+
homepage: null,
|
|
164
|
+
created_at: '2024-01-01T00:00:00Z',
|
|
165
|
+
updated_at: '2024-06-01T00:00:00Z',
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
const input: GitHubProjectInput = {
|
|
169
|
+
id: 'override-github',
|
|
170
|
+
type: 'github',
|
|
171
|
+
repo: 'user/repo',
|
|
172
|
+
status: 'active',
|
|
173
|
+
override: {
|
|
174
|
+
name: 'Custom Name',
|
|
175
|
+
description: 'Custom Description',
|
|
176
|
+
},
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const result = await normalise(input)
|
|
180
|
+
|
|
181
|
+
expect(result.name).toBe('Custom Name')
|
|
182
|
+
expect(result.description).toBe('Custom Description')
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
it('should include repo in the output', async () => {
|
|
186
|
+
mockedFetchGitHubRepo.mockResolvedValue(null)
|
|
187
|
+
|
|
188
|
+
const input: GitHubProjectInput = {
|
|
189
|
+
id: 'repo-test',
|
|
190
|
+
type: 'github',
|
|
191
|
+
repo: 'user/my-repo',
|
|
192
|
+
status: 'active',
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const result = await normalise(input)
|
|
196
|
+
|
|
197
|
+
expect(result.repo).toBe('user/my-repo')
|
|
198
|
+
})
|
|
199
|
+
|
|
200
|
+
it('should merge input links with GitHub links', async () => {
|
|
201
|
+
mockedFetchGitHubRepo.mockResolvedValue({
|
|
202
|
+
name: 'repo',
|
|
203
|
+
description: 'desc',
|
|
204
|
+
stargazers_count: 0,
|
|
205
|
+
forks_count: 0,
|
|
206
|
+
language: null,
|
|
207
|
+
topics: [],
|
|
208
|
+
html_url: 'https://github.com/user/repo',
|
|
209
|
+
homepage: null,
|
|
210
|
+
created_at: '2024-01-01T00:00:00Z',
|
|
211
|
+
updated_at: '2024-01-01T00:00:00Z',
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
const input: GitHubProjectInput = {
|
|
215
|
+
id: 'links-test',
|
|
216
|
+
type: 'github',
|
|
217
|
+
repo: 'user/repo',
|
|
218
|
+
status: 'active',
|
|
219
|
+
links: {
|
|
220
|
+
npm: 'https://npmjs.com/package/my-pkg',
|
|
221
|
+
},
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const result = await normalise(input)
|
|
225
|
+
|
|
226
|
+
expect(result.links.github).toBe('https://github.com/user/repo')
|
|
227
|
+
expect(result.links.npm).toBe('https://npmjs.com/package/my-pkg')
|
|
228
|
+
})
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
describe('npm project normalization', () => {
|
|
232
|
+
it('should normalize an npm project with fetched data', async () => {
|
|
233
|
+
mockedFetchNpmPackage.mockResolvedValue({
|
|
234
|
+
name: 'my-package',
|
|
235
|
+
version: '2.0.0',
|
|
236
|
+
downloads: 10000,
|
|
237
|
+
})
|
|
238
|
+
|
|
239
|
+
const input: NpmProjectInput = {
|
|
240
|
+
id: 'test-npm',
|
|
241
|
+
type: 'npm',
|
|
242
|
+
package: 'my-package',
|
|
243
|
+
status: 'active',
|
|
244
|
+
name: 'My Package',
|
|
245
|
+
description: 'Package description',
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const result = await normalise(input)
|
|
249
|
+
|
|
250
|
+
expect(result.name).toBe('My Package')
|
|
251
|
+
expect(result.description).toBe('Package description')
|
|
252
|
+
expect(result.stats).toEqual({
|
|
253
|
+
downloads: '10000',
|
|
254
|
+
version: '2.0.0',
|
|
255
|
+
})
|
|
256
|
+
expect(result.package).toBe('my-package')
|
|
257
|
+
expect(mockedFetchNpmPackage).toHaveBeenCalledWith('my-package')
|
|
258
|
+
})
|
|
259
|
+
|
|
260
|
+
it('should handle npm fetch failure gracefully', async () => {
|
|
261
|
+
mockedFetchNpmPackage.mockResolvedValue(null)
|
|
262
|
+
|
|
263
|
+
const input: NpmProjectInput = {
|
|
264
|
+
id: 'failed-npm',
|
|
265
|
+
type: 'npm',
|
|
266
|
+
package: 'nonexistent-pkg',
|
|
267
|
+
status: 'active',
|
|
268
|
+
name: 'Package Name',
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
const result = await normalise(input)
|
|
272
|
+
|
|
273
|
+
expect(result.name).toBe('Package Name')
|
|
274
|
+
expect(result.stats).toBeNull()
|
|
275
|
+
})
|
|
276
|
+
})
|
|
277
|
+
|
|
278
|
+
describe('Product Hunt project normalization', () => {
|
|
279
|
+
it('should normalize a Product Hunt project with fetched data', async () => {
|
|
280
|
+
mockedFetchProductHuntPost.mockResolvedValue({
|
|
281
|
+
name: 'Product Name',
|
|
282
|
+
tagline: 'Product tagline',
|
|
283
|
+
description: 'Product description',
|
|
284
|
+
votes_count: 500,
|
|
285
|
+
comments_count: 50,
|
|
286
|
+
featured_at: '2024-01-15T00:00:00Z',
|
|
287
|
+
website: 'https://example.com',
|
|
288
|
+
url: 'https://producthunt.com/posts/product',
|
|
289
|
+
})
|
|
290
|
+
|
|
291
|
+
const input: ProductHuntProjectInput = {
|
|
292
|
+
id: 'test-ph',
|
|
293
|
+
type: 'product-hunt',
|
|
294
|
+
slug: 'my-product',
|
|
295
|
+
status: 'shipped',
|
|
296
|
+
name: 'Input Name',
|
|
297
|
+
tagline: 'Input Tagline',
|
|
298
|
+
description: 'Input Description',
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
const result = await normalise(input)
|
|
302
|
+
|
|
303
|
+
expect(result.name).toBe('Input Name')
|
|
304
|
+
expect(result.tagline).toBe('Input Tagline')
|
|
305
|
+
expect(result.description).toBe('Input Description')
|
|
306
|
+
expect(result.stats).toEqual({
|
|
307
|
+
upvotes: 500,
|
|
308
|
+
comments: 50,
|
|
309
|
+
launchDate: '2024-01-15T00:00:00Z',
|
|
310
|
+
})
|
|
311
|
+
expect(result.slug).toBe('my-product')
|
|
312
|
+
expect(mockedFetchProductHuntPost).toHaveBeenCalledWith('my-product')
|
|
313
|
+
})
|
|
314
|
+
|
|
315
|
+
it('should handle Product Hunt fetch failure gracefully', async () => {
|
|
316
|
+
mockedFetchProductHuntPost.mockResolvedValue(null)
|
|
317
|
+
|
|
318
|
+
const input: ProductHuntProjectInput = {
|
|
319
|
+
id: 'failed-ph',
|
|
320
|
+
type: 'product-hunt',
|
|
321
|
+
slug: 'nonexistent',
|
|
322
|
+
status: 'active',
|
|
323
|
+
name: 'Fallback Name',
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
const result = await normalise(input)
|
|
327
|
+
|
|
328
|
+
expect(result.name).toBe('Fallback Name')
|
|
329
|
+
expect(result.stats).toBeNull()
|
|
330
|
+
})
|
|
331
|
+
})
|
|
332
|
+
|
|
333
|
+
describe('featured handling', () => {
|
|
334
|
+
it('should default featured to false', async () => {
|
|
335
|
+
const input: ManualProjectInput = {
|
|
336
|
+
id: 'no-featured',
|
|
337
|
+
type: 'manual',
|
|
338
|
+
status: 'active',
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
const result = await normalise(input)
|
|
342
|
+
|
|
343
|
+
expect(result.featured).toBe(false)
|
|
344
|
+
})
|
|
345
|
+
|
|
346
|
+
it('should preserve featured=true', async () => {
|
|
347
|
+
const input: ManualProjectInput = {
|
|
348
|
+
id: 'featured-true',
|
|
349
|
+
type: 'manual',
|
|
350
|
+
status: 'active',
|
|
351
|
+
featured: true,
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
const result = await normalise(input)
|
|
355
|
+
|
|
356
|
+
expect(result.featured).toBe(true)
|
|
357
|
+
})
|
|
358
|
+
})
|
|
359
|
+
|
|
360
|
+
describe('language color handling', () => {
|
|
361
|
+
it('should set language color for known languages', async () => {
|
|
362
|
+
mockedFetchGitHubRepo.mockResolvedValue({
|
|
363
|
+
name: 'repo',
|
|
364
|
+
description: 'desc',
|
|
365
|
+
stargazers_count: 0,
|
|
366
|
+
forks_count: 0,
|
|
367
|
+
language: 'TypeScript',
|
|
368
|
+
topics: [],
|
|
369
|
+
html_url: 'https://github.com/user/repo',
|
|
370
|
+
homepage: null,
|
|
371
|
+
created_at: '2024-01-01T00:00:00Z',
|
|
372
|
+
updated_at: '2024-01-01T00:00:00Z',
|
|
373
|
+
})
|
|
374
|
+
|
|
375
|
+
const input: GitHubProjectInput = {
|
|
376
|
+
id: 'lang-color',
|
|
377
|
+
type: 'github',
|
|
378
|
+
repo: 'user/repo',
|
|
379
|
+
status: 'active',
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
const result = await normalise(input)
|
|
383
|
+
|
|
384
|
+
expect(result.language).toBe('TypeScript')
|
|
385
|
+
expect(result.languageColor).toBe('#3178c6')
|
|
386
|
+
})
|
|
387
|
+
|
|
388
|
+
it('should handle unknown languages', async () => {
|
|
389
|
+
mockedFetchGitHubRepo.mockResolvedValue({
|
|
390
|
+
name: 'repo',
|
|
391
|
+
description: 'desc',
|
|
392
|
+
stargazers_count: 0,
|
|
393
|
+
forks_count: 0,
|
|
394
|
+
language: 'UnknownLanguage',
|
|
395
|
+
topics: [],
|
|
396
|
+
html_url: 'https://github.com/user/repo',
|
|
397
|
+
homepage: null,
|
|
398
|
+
created_at: '2024-01-01T00:00:00Z',
|
|
399
|
+
updated_at: '2024-01-01T00:00:00Z',
|
|
400
|
+
})
|
|
401
|
+
|
|
402
|
+
const input: GitHubProjectInput = {
|
|
403
|
+
id: 'unknown-lang',
|
|
404
|
+
type: 'github',
|
|
405
|
+
repo: 'user/repo',
|
|
406
|
+
status: 'active',
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
const result = await normalise(input)
|
|
410
|
+
|
|
411
|
+
expect(result.language).toBe('UnknownLanguage')
|
|
412
|
+
expect(result.languageColor).toBeNull()
|
|
413
|
+
})
|
|
414
|
+
})
|
|
415
|
+
})
|
|
416
|
+
|
|
417
|
+
describe('normalizeStats', () => {
|
|
418
|
+
it('should normalize stars', () => {
|
|
419
|
+
const result = normalizeStats({ stars: 1500 }, 'github')
|
|
420
|
+
|
|
421
|
+
expect(result).toContainEqual({ label: 'Stars', value: '1.5K' })
|
|
422
|
+
})
|
|
423
|
+
|
|
424
|
+
it('should normalize forks', () => {
|
|
425
|
+
const result = normalizeStats({ forks: 250 }, 'github')
|
|
426
|
+
|
|
427
|
+
expect(result).toContainEqual({ label: 'Forks', value: '250' })
|
|
428
|
+
})
|
|
429
|
+
|
|
430
|
+
it('should normalize downloads with unit', () => {
|
|
431
|
+
const result = normalizeStats({ downloads: 10000 }, 'npm')
|
|
432
|
+
|
|
433
|
+
expect(result).toContainEqual({ label: 'Downloads', value: '10.0K', unit: 'month' })
|
|
434
|
+
})
|
|
435
|
+
|
|
436
|
+
it('should normalize version with v prefix', () => {
|
|
437
|
+
const result = normalizeStats({ version: '1.2.3' }, 'npm')
|
|
438
|
+
|
|
439
|
+
expect(result).toContainEqual({ label: 'Version', value: 'v1.2.3' })
|
|
440
|
+
})
|
|
441
|
+
|
|
442
|
+
it('should not duplicate v prefix', () => {
|
|
443
|
+
const result = normalizeStats({ version: 'v2.0.0' }, 'npm')
|
|
444
|
+
|
|
445
|
+
expect(result).toContainEqual({ label: 'Version', value: 'v2.0.0' })
|
|
446
|
+
})
|
|
447
|
+
|
|
448
|
+
it('should normalize upvotes', () => {
|
|
449
|
+
const result = normalizeStats({ upvotes: 500 }, 'product-hunt')
|
|
450
|
+
|
|
451
|
+
expect(result).toContainEqual({ label: 'Upvotes', value: '500' })
|
|
452
|
+
})
|
|
453
|
+
|
|
454
|
+
it('should normalize comments', () => {
|
|
455
|
+
const result = normalizeStats({ comments: 75 }, 'product-hunt')
|
|
456
|
+
|
|
457
|
+
expect(result).toContainEqual({ label: 'Comments', value: '75' })
|
|
458
|
+
})
|
|
459
|
+
|
|
460
|
+
it('should normalize launchDate', () => {
|
|
461
|
+
const result = normalizeStats({ launchDate: '2024-01-15' }, 'product-hunt')
|
|
462
|
+
|
|
463
|
+
expect(result).toContainEqual({ label: 'Launched', value: expect.any(String) })
|
|
464
|
+
})
|
|
465
|
+
|
|
466
|
+
it('should format large numbers with M suffix', () => {
|
|
467
|
+
const result = normalizeStats({ stars: 2500000 }, 'github')
|
|
468
|
+
|
|
469
|
+
expect(result).toContainEqual({ label: 'Stars', value: '2.5M' })
|
|
470
|
+
})
|
|
471
|
+
|
|
472
|
+
it('should handle empty stats', () => {
|
|
473
|
+
const result = normalizeStats({}, 'github')
|
|
474
|
+
|
|
475
|
+
expect(result).toEqual([])
|
|
476
|
+
})
|
|
477
|
+
|
|
478
|
+
it('should handle null/undefined values', () => {
|
|
479
|
+
const result = normalizeStats({ stars: null, forks: undefined }, 'github')
|
|
480
|
+
|
|
481
|
+
expect(result).toEqual([])
|
|
482
|
+
})
|
|
483
|
+
|
|
484
|
+
it('should handle invalid numbers', () => {
|
|
485
|
+
const result = normalizeStats({ stars: 'not-a-number' }, 'github')
|
|
486
|
+
|
|
487
|
+
expect(result).toEqual([])
|
|
488
|
+
})
|
|
489
|
+
|
|
490
|
+
it('should combine multiple stats', () => {
|
|
491
|
+
const result = normalizeStats({
|
|
492
|
+
stars: 100,
|
|
493
|
+
forks: 50,
|
|
494
|
+
downloads: 1000,
|
|
495
|
+
version: '1.0.0',
|
|
496
|
+
}, 'hybrid')
|
|
497
|
+
|
|
498
|
+
expect(result).toHaveLength(4)
|
|
499
|
+
})
|
|
500
|
+
})
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
import { normalise } from '../normalise'
|
|
3
|
+
import type { NpmProjectInput } from '../../types'
|
|
4
|
+
|
|
5
|
+
describe('npm config recognition', () => {
|
|
6
|
+
it('should recognize an npm project when type is "npm"', async () => {
|
|
7
|
+
const input: NpmProjectInput = {
|
|
8
|
+
id: 'test-npm',
|
|
9
|
+
type: 'npm',
|
|
10
|
+
package: 'test-package',
|
|
11
|
+
status: 'active',
|
|
12
|
+
name: 'Test Package',
|
|
13
|
+
tagline: 'A test package',
|
|
14
|
+
description: 'This is a test description',
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const result = await normalise(input)
|
|
18
|
+
|
|
19
|
+
expect(result.type).toBe('npm')
|
|
20
|
+
expect(result.id).toBe('test-npm')
|
|
21
|
+
expect(result.package).toBe('test-package')
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it('should match the package property to the npm package name', async () => {
|
|
25
|
+
const input: NpmProjectInput = {
|
|
26
|
+
id: 'test-npm',
|
|
27
|
+
type: 'npm',
|
|
28
|
+
package: 'my-awesome-package',
|
|
29
|
+
status: 'active',
|
|
30
|
+
name: 'My Awesome Package',
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const result = await normalise(input)
|
|
34
|
+
|
|
35
|
+
expect(result.package).toBe('my-awesome-package')
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it('should handle npm project with all optional fields', async () => {
|
|
39
|
+
const input: NpmProjectInput = {
|
|
40
|
+
id: 'full-npm',
|
|
41
|
+
type: 'npm',
|
|
42
|
+
package: 'full-package',
|
|
43
|
+
status: 'shipped',
|
|
44
|
+
featured: true,
|
|
45
|
+
name: 'Full Package',
|
|
46
|
+
tagline: 'A complete npm package',
|
|
47
|
+
description: 'Description of the package',
|
|
48
|
+
background: 'Background info',
|
|
49
|
+
why: 'Why I built it',
|
|
50
|
+
struggles: [],
|
|
51
|
+
timeline: [],
|
|
52
|
+
posts: [],
|
|
53
|
+
stack: ['TypeScript', 'React'],
|
|
54
|
+
links: {
|
|
55
|
+
npm: 'https://npmjs.com/package/full-package',
|
|
56
|
+
github: 'https://github.com/user/full-package',
|
|
57
|
+
},
|
|
58
|
+
stats: {
|
|
59
|
+
downloads: '10000',
|
|
60
|
+
version: '1.0.0',
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const result = await normalise(input)
|
|
65
|
+
|
|
66
|
+
expect(result.type).toBe('npm')
|
|
67
|
+
expect(result.package).toBe('full-package')
|
|
68
|
+
expect(result.name).toBe('Full Package')
|
|
69
|
+
expect(result.tagline).toBe('A complete npm package')
|
|
70
|
+
expect(result.description).toBe('Description of the package')
|
|
71
|
+
expect(result.background).toBe('Background info')
|
|
72
|
+
expect(result.why).toBe('Why I built it')
|
|
73
|
+
expect(result.stack).toEqual(['TypeScript', 'React'])
|
|
74
|
+
expect(result.links).toEqual({
|
|
75
|
+
npm: 'https://npmjs.com/package/full-package',
|
|
76
|
+
github: 'https://github.com/user/full-package',
|
|
77
|
+
})
|
|
78
|
+
expect(result.stats).toEqual({
|
|
79
|
+
downloads: '10000',
|
|
80
|
+
version: '1.0.0',
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
it('should handle npm project with minimal config', async () => {
|
|
85
|
+
const input: NpmProjectInput = {
|
|
86
|
+
id: 'minimal-npm',
|
|
87
|
+
type: 'npm',
|
|
88
|
+
package: 'minimal-package',
|
|
89
|
+
status: 'active',
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const result = await normalise(input)
|
|
93
|
+
|
|
94
|
+
expect(result.type).toBe('npm')
|
|
95
|
+
expect(result.package).toBe('minimal-package')
|
|
96
|
+
expect(result.name).toBe('')
|
|
97
|
+
expect(result.tagline).toBe('')
|
|
98
|
+
expect(result.description).toBe('')
|
|
99
|
+
})
|
|
100
|
+
})
|