Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions packages/ensjs/src/utils/getNameType.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { describe, expect, it } from 'vitest'
import { getNameType } from './getNameType'

describe('getNameType', () => {
it('should return "tld" for empty string', () => {
expect(getNameType('')).toBe('tld')
})

it('should return "tld" for a non-eth top-level domain', () => {
expect(getNameType('com')).toBe('tld')
})

it('should return "eth-tld" for eth top-level domain', () => {
expect(getNameType('eth')).toBe('eth-tld')
})

it('should return "other-2ld" for a non-eth second-level domain', () => {
expect(getNameType('example.com')).toBe('other-2ld')
})

it('should return "eth-2ld" for eth second-level domain', () => {
expect(getNameType('example.eth')).toBe('eth-2ld')
})

it('should return "other-subname" for a non-eth subname', () => {
expect(getNameType('sub.example.com')).toBe('other-subname')
})

it('should return "eth-subname" for eth subname', () => {
expect(getNameType('sub.example.eth')).toBe('eth-subname')
})
})