Skip to content

Commit

Permalink
add tests and clean up folder structure
Browse files Browse the repository at this point in the history
  • Loading branch information
storywithoutend committed Nov 20, 2024
1 parent 83df106 commit 9c56c21
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/pages/profile/[name]/Profile.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useRenew } from '@root/ src/hooks/pages/profile/useRenew'
import Head from 'next/head'
import { useEffect, useMemo } from 'react'
import { Trans, useTranslation } from 'react-i18next'
Expand All @@ -12,6 +11,7 @@ import BaseLink from '@app/components/@atoms/BaseLink'
import { Outlink } from '@app/components/Outlink'
import { useAbilities } from '@app/hooks/abilities/useAbilities'
import { useChainName } from '@app/hooks/chain/useChainName'
import { useRenew } from '@app/hooks/pages/profile/useRenew/useRenew'
import { useNameDetails } from '@app/hooks/useNameDetails'
import { useProtectedRoute } from '@app/hooks/useProtectedRoute'
import { useQueryParameterState } from '@app/hooks/useQueryParameterState'
Expand Down
File renamed without changes.
28 changes: 28 additions & 0 deletions src/utils/string.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { it, describe, expect } from "vitest";
import { parseNumericString } from "./string";

describe('parseNumericString', () => {
it('should return an integer', () => {
expect(parseNumericString('123')).toBe(123)
})

it('should return an integer for a decimal', () => {
expect(parseNumericString('123.123')).toBe(123)

Check failure on line 10 in src/utils/string.test.ts

View workflow job for this annotation

GitHub Actions / coverage

src/utils/string.test.ts > parseNumericString > should return an integer for a decimal

AssertionError: expected 123.123 to be 123 // Object.is equality - Expected + Received - 123 + 123.123 ❯ src/utils/string.test.ts:10:43
})

it('should return null for a string', () => {
expect(parseNumericString('abc')).toBe(null)
})

it('should return null for an empty string', () => {
expect(parseNumericString('')).toBe(null)
})

it('should return null for a negative number', () => {
expect(parseNumericString('-123')).toBe(null)

Check failure on line 22 in src/utils/string.test.ts

View workflow job for this annotation

GitHub Actions / coverage

src/utils/string.test.ts > parseNumericString > should return null for a negative number

AssertionError: expected -123 to be null // Object.is equality - Expected: null + Received: -123 ❯ src/utils/string.test.ts:22:40
})

it('should return null for a negative number', () => {
expect(parseNumericString('1a23')).toBe(null)
})
})

0 comments on commit 9c56c21

Please sign in to comment.