import { isExistSrfKey, isExistSessionKey } from '@/core/utils/service-exist-util'; describe('isExistSrfKey unit test', () => { test('data has a primary key', () => { const data = { test: '1', srfkey: "faddsada", } const funcName = 'Get'; expect(isExistSrfKey(funcName, data)).toBe(true); }); test('data has no primary key', () => { const data = { test: '1', } const funcName = 'Get'; expect(() => isExistSrfKey(funcName, data)).toThrowError(`执行「${funcName}」不存在「srfkey」无法处理`); }) }) describe('isExistSessionKey unit test', () => { test('context has a srfsessionkey', () => { const context = { test: '1', srfsessionkey: 'dadadadsasdasd', } const funcName = 'Get'; expect(isExistSessionKey(funcName, context)).toBe(true); }); test('context has no srfsessionkey', () => { const context = { test: '1', } const funcName = 'Get'; expect(() => isExistSessionKey(funcName, context)).toThrowError(`执行「${funcName}」不存在「srfsessionkey」无法处理`); }); })