Skip to content

Commit c6ec8da

Browse files
authored
Replace jest with vitest (#701)
* chore(package): Update to vitest v4 * fix(vitest): Suppress noisy logs * feat(vitest): Remove jest replace with vitest * fix(View > All Albums): Display photo reference as the map performance is good * fix(Edit > Album): Paste DMS geo coordinates * chore(Edit > Album): Extract DMS pattern * chore(vitest): Remove jest config
2 parents 94814d7 + 6a42aae commit c6ec8da

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+4552
-8110
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ generated.ts
3636

3737
# Python
3838
models
39+
!src/models
3940
weights.log
4041
api.log
4142

__tests__/api/album.test.ts

Lines changed: 0 additions & 45 deletions
This file was deleted.

__tests__/api/album.vitest.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// @vitest-environment node
2+
3+
import { describe, expect, test } from 'vitest'
4+
5+
import { NextRequest } from 'next/server'
6+
import { GET, POST } from '../../app/api/galleries/[gallery]/albums/[album]/route'
7+
import config from '../../src/models/config'
8+
9+
describe('Album endpoint', () => {
10+
describe('Expect result', () => {
11+
test('* GET has album', async () => {
12+
const response = await GET(
13+
new NextRequest('http://test'),
14+
{ params: Promise.resolve({ gallery: config.defaultGallery, album: config.defaultAlbum }) },
15+
)
16+
const result = await response.json()
17+
18+
expect(response.status).toBe(200)
19+
20+
expect(result.album.items.length).toBeGreaterThan(0)
21+
expect(result.album.items[0].filename).toBe('2001-03-21-01.jpg')
22+
})
23+
})
24+
25+
describe('Expect error', () => {
26+
test('* POST verb is denied', async () => {
27+
const response = await POST(new NextRequest('http://test', { method: 'POST' }))
28+
const result = await response.json()
29+
30+
expect(response.status).toBe(405)
31+
expect(result.error.message.toLowerCase()).toContain('not allowed')
32+
33+
expect(result.album.length).toBe(0)
34+
})
35+
})
36+
})

__tests__/api/albums.test.ts

Lines changed: 0 additions & 46 deletions
This file was deleted.

__tests__/api/albums.vitest.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// @vitest-environment node
2+
3+
import { describe, expect, test } from 'vitest'
4+
5+
import { NextRequest } from 'next/server'
6+
import { GET, POST } from '../../app/api/galleries/[gallery]/albums/route'
7+
import { type GalleryAlbumsBody } from '../../src/lib/albums'
8+
import config from '../../src/models/config'
9+
10+
describe('Albums endpoint', () => {
11+
describe('Expect result', () => {
12+
test('* GET has albums', async () => {
13+
const response = await GET(
14+
new NextRequest('http://test'),
15+
{ params: Promise.resolve({ gallery: config.defaultGallery }) },
16+
)
17+
const result: GalleryAlbumsBody = await response.json()
18+
19+
expect(response.status).toBe(200)
20+
21+
expect(result.demo.albums.length).toBeGreaterThan(0)
22+
expect(result.demo.albums[0].name).toBe(config.defaultAlbum)
23+
})
24+
})
25+
26+
describe('Expect error', () => {
27+
test('* POST verb is denied', async () => {
28+
const response = await POST(new NextRequest('http://test', { method: 'POST' }))
29+
const result = await response.json()
30+
31+
expect(response.status).toBe(405)
32+
expect(result.error.message.toLowerCase()).toContain('not allowed')
33+
34+
expect(result.albums.length).toBe(0)
35+
})
36+
})
37+
})

__tests__/api/filesystems.test.ts

Lines changed: 0 additions & 147 deletions
This file was deleted.

0 commit comments

Comments
 (0)