Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

1.3 KB
Raw Blame
import { describe, expect, it } from 'vitest'

import {
  getAddReadReplicaPath,
  getInfrastructurePath,
  getReadReplicaPath,
} from './Infrastructure.utils'

describe('getInfrastructurePath', () => {
  it('builds the path for a project ref', () => {
    expect(getInfrastructurePath('project-ref')).toBe(
      '/project/project-ref/settings/infrastructure'
    )
  })

  it('falls back to the default project placeholder', () => {
    expect(getInfrastructurePath()).toBe('/project/_/settings/infrastructure')
  })
})

describe('getReadReplicaPath', () => {
  it('builds the replica detail path', () => {
    expect(getReadReplicaPath('project-ref', 'replica-1')).toBe(
      '/project/project-ref/settings/infrastructure/replica/replica-1'
    )
  })

  it('falls back to the default project placeholder', () => {
    expect(getReadReplicaPath(undefined, 'replica-1')).toBe(
      '/project/_/settings/infrastructure/replica/replica-1'
    )
  })
})

describe('getAddReadReplicaPath', () => {
  it('opens the add-replica sheet on infrastructure', () => {
    expect(getAddReadReplicaPath('project-ref')).toBe(
      '/project/project-ref/settings/infrastructure?addReplica=true'
    )
  })

  it('falls back to the default project placeholder', () => {
    expect(getAddReadReplicaPath()).toBe('/project/_/settings/infrastructure?addReplica=true')
  })
})