mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 09:25:06 +03:00
* update gh action, update vitest config * debug * debug cov * idk try something different * test2 * test3 * add base path * rm debug * add apiAuthenticate tests * supabaseClient tests * apiWrappers tests * add apiHelpers tests * add configcat tests * add formatSql tests * add github tests * add cloudprovider utils tests * add helpers tests * fix typeerr * add missing readonly err * fix typeerrrs * fix type errors in apiWrapper tests * fix apiHelpers test * add packages/ui tests * add coveralls flags * try coveralls parallel config * fix coveralls parallel config --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
50 lines
1.1 KiB
TypeScript
50 lines
1.1 KiB
TypeScript
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
import { readOnly } from './supabaseClient'
|
|
|
|
vi.mock('lib/constants', () => ({
|
|
IS_PLATFORM: true,
|
|
}))
|
|
|
|
const readOnlyErrMessage = 'Read only error'
|
|
|
|
vi.mock('@supabase/supabase-js', () => ({
|
|
createClient: vi.fn(() => ({
|
|
from: vi.fn(() => ({
|
|
insert: () => {
|
|
throw readOnlyErrMessage
|
|
},
|
|
delete: () => {
|
|
throw readOnlyErrMessage
|
|
},
|
|
update: () => {
|
|
throw readOnlyErrMessage
|
|
},
|
|
})),
|
|
rpc: () => {
|
|
throw readOnlyErrMessage
|
|
},
|
|
})),
|
|
}))
|
|
|
|
describe('supabaseClient', () => {
|
|
it('should be defined', () => {
|
|
expect(readOnly).toBeDefined()
|
|
})
|
|
|
|
it('should throw on inserts', () => {
|
|
expect(() => readOnly.from('').insert({})).toThrowError()
|
|
})
|
|
|
|
it('should throw on deletes', () => {
|
|
expect(() => readOnly.from('').delete({})).toThrowError()
|
|
})
|
|
|
|
it('should throw on updates', () => {
|
|
expect(() => readOnly.from('').update({})).toThrowError()
|
|
})
|
|
|
|
it('should throw on rpc', () => {
|
|
expect(() => readOnly.rpc({})).toThrowError()
|
|
})
|
|
})
|