import { describe, it, expect } from 'vitest'
import { isEmptyGeometrySourceError } from './is-empty-geometry-source-error'

describe('isEmptyGeometrySourceError', () => {
  it('does not match the sitesel-gen 400 message', () => {
    expect(
      isEmptyGeometrySourceError(
        new Error(
          "loading data of VectorTileLayer(spam): There aren't any rows with geometry data in this result set",
        ),
      ),
    ).toBe(false)
  })

  it('matches the america-us 412 message', () => {
    expect(isEmptyGeometrySourceError(new Error('Error (412): eggs'))).toBe(
      true,
    )
  })

  it('does not match unrelated errors', () => {
    expect(
      isEmptyGeometrySourceError(new Error('Network request failed')),
    ).toBe(false)
  })
})
