import { getFileExtension, parseFilename } from '../filename'

describe('parseFilename', () => {
  it('should parse file name', () => {
    expect(parseFilename('a.png')).toEqual({
      filename: 'a',
      extension: 'png',
      isFilename: true,
    })
  })

  it('should handle non-filename strings', () => {
    expect(parseFilename('abcd-efg-hij')).toEqual({
      filename: '',
      extension: '',
      isFilename: false,
    })
  })
})

describe('getFileExtension', () => {
  it('should return file extension from a string', () => {
    expect(getFileExtension('a.png')).toEqual('png')
    expect(getFileExtension('abcd.jpg.png')).toEqual('png')
    expect(getFileExtension('abcd')).toEqual('')
  })
})
