Browse Source

build: introduce vitest

replace newly introduced jest tests with vitest

closes #3
master
jk 2 years ago committed by DanConwayDev
parent
commit
96774ba865
No known key found for this signature in database
GPG Key ID: 68E15486D73F75E1
  1. 1
      .gitignore
  2. 5
      jest.config.cjs
  3. 8
      package.json
  4. 3
      src/lib/components/events/content/utils.spec.ts
  5. 1
      tsconfig.json
  6. 8
      vite.config.ts
  7. 610
      yarn.lock

1
.gitignore vendored

@ -11,3 +11,4 @@ vite.config.js.timestamp-* @@ -11,3 +11,4 @@ vite.config.js.timestamp-*
vite.config.ts.timestamp-*
/result
storybook-static
yarn-error.log

5
jest.config.cjs

@ -1,5 +0,0 @@ @@ -1,5 +0,0 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};

8
package.json

@ -13,7 +13,8 @@ @@ -13,7 +13,8 @@
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"test": "storybook build && (concurrently -k -s first \"http-server storybook-static --port 6006 --silent\" \"wait-on tcp:6006 && test-storybook --index-json --maxWorkers=2\") && rm storybook-static -r -f",
"test-update": "storybook build && (concurrently -k -s first \"http-server storybook-static --port 6006 --silent\" \"wait-on tcp:6006 && test-storybook -u --index-json --maxWorkers=2\") && rm storybook-static -r -f"
"test-update": "storybook build && (concurrently -k -s first \"http-server storybook-static --port 6006 --silent\" \"wait-on tcp:6006 && test-storybook -u --index-json --maxWorkers=2\") && rm storybook-static -r -f",
"test-unit": "vitest"
},
"devDependencies": {
"@storybook/addon-a11y": "^7.4.5",
@ -31,7 +32,6 @@ @@ -31,7 +32,6 @@
"@sveltejs/adapter-node": "^1.2.3",
"@sveltejs/kit": "^1.5.0",
"@tailwindcss/typography": "^0.5.10",
"@types/jest": "^29.5.12",
"@types/jest-image-snapshot": "^6.2.1",
"@types/node": "^20.8.2",
"@types/ramda": "^0.29.10",
@ -54,10 +54,10 @@ @@ -54,10 +54,10 @@
"svelte": "^3.54.0",
"svelte-check": "^3.0.1",
"tailwindcss": "^3.3.3",
"ts-jest": "^29.1.2",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"vite": "^4.2.0"
"vite": "^4.2.0",
"vitest": "^1.2.2"
},
"type": "module",
"dependencies": {

3
src/lib/components/events/content/utils.spec.ts

@ -1,8 +1,10 @@ @@ -1,8 +1,10 @@
import { describe, expect, test } from 'vitest'
import { extractPatchMessage } from './utils'
// const simple =
// const example = `From 35ef1fe53b5a460266a1666709d886560d99cd67 Mon Sep 17 00:00:00 2001\nFrom: fiatjaf <fiatjaf@gmail.com>\nDate: Mon, 29 Jan 2024 09:41:27 -0300\nSubject: [PATCH] fix multi-attempt password prompt.\n\nthe print was doing nothing\nand the continue was missing\n---\nfound this bug while copying these functions to be used in nak\n\n helpers.go | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/helpers.go b/helpers.go\nindex 0b3790d..9b5c3da 100644\n--- a/helpers.go\n+++ b/helpers.go\n@@ -176,7 +176,7 @@ func promptDecrypt(ncryptsec1 string) (string, error) {\n \t\t}\n \t\tsec, err := nip49.Decrypt(ncryptsec1, password)\n \t\tif err != nil {\n-\t\t\tfmt.Fprintf(os.Stderr, "failed to decrypt: %s", err)\n+\t\t\tcontinue\n \t\t}\n \t\treturn sec, nil\n \t}\n--\n2.43.0\n', tags: (3) […], kind: 1617, id: "fd5d1be541bf2d20c51ca63265cc893eecb4be8720db9b42abec21b9ca9747de", sig: "d4733b8b32c05d1fb33a76105926fc537e4060df25405521b3f74f91ed7d65f345386260e8a825c79d67c3dd67f5e7eea7d532cda48cb8d45f09f9be19775289", pubkey: "3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d", … }`
describe('extractPatchMessage', () => {
test('extractPatchMessage - normal message end', () => {
expect(
extractPatchMessage(
@ -39,3 +41,4 @@ test.skip('extractPatchMessage - anotherunusual message end', () => { @@ -39,3 +41,4 @@ test.skip('extractPatchMessage - anotherunusual message end', () => {
'Revert "mention: fix broken mentions when there is text is\n directly after"\n\nThis reverts commit af75eed83a2a1dd0eb33a0a27ded71c9f44dacbd.'
)
})
})

1
tsconfig.json

@ -9,5 +9,6 @@ @@ -9,5 +9,6 @@
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"types": ["vitest/globals"],
},
}

8
vite.config.ts

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
import { sveltekit } from '@sveltejs/kit/vite'
import { defineConfig } from 'vite'
export default defineConfig({
plugins: [sveltekit()]
});
plugins: [sveltekit()],
})

610
yarn.lock

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save