Skip to content

Commit

Permalink
⬆️ chore(core): Update msw dependency (#1037)
Browse files Browse the repository at this point in the history
  • Loading branch information
duckception authored Dec 12, 2023
1 parent 7e876fe commit a406e3a
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 155 deletions.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@vitest/coverage-v8": "1.0.0-beta.0",
"archiver": "^6.0.1",
"memfs": "^4.5.0",
"msw": "^1.3.2",
"msw": "^2.0.11",
"rimraf": "^5.0.1",
"tsconfig": "workspace:*",
"typescript": "^5.2.2",
Expand Down
15 changes: 9 additions & 6 deletions packages/core/test/downloadFile.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import path from 'node:path'
import axios from 'axios'
import { fs, vol } from 'memfs'
import { rest } from 'msw'
import { http, HttpResponse } from 'msw'
import { setupServer } from 'msw/node'
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'
import { downloadFile } from '../src/downloadFile'
import { downloadFile } from '../src'

const ROOT_DIR = '/tmp'
const FILE_NAME = 'duck.txt'
Expand All @@ -13,8 +13,8 @@ const FILE_PATH = path.join(ROOT_DIR, FILE_NAME)
const MOCK_URL = `https://example.com/${FILE_NAME}`

const server = setupServer(
rest.get(MOCK_URL, (_, res, ctx) => {
return res(ctx.text(FILE_CONTENT))
http.get(MOCK_URL, () => {
return HttpResponse.text(FILE_CONTENT)
})
)

Expand Down Expand Up @@ -61,8 +61,11 @@ describe('downloadFile', () => {

it('throws an error if the file cannot be downloaded', async () => {
server.use(
rest.get(MOCK_URL, (_, res, ctx) => {
return res(ctx.status(500), ctx.json({ message: 'Internal server error' }))
http.get(MOCK_URL, () => {
return new HttpResponse(null, {
status: 500,
statusText: 'Internal Server Error'
})
})
)

Expand Down
3 changes: 2 additions & 1 deletion packages/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "./tsconfig.build.json",
"compilerOptions": {
"rootDir": "."
"rootDir": ".",
"lib": ["DOM"]
},
"include": [
"src",
Expand Down
Loading

0 comments on commit a406e3a

Please sign in to comment.