@forge/kvs
1.3.1-next.0-experimental-75a65ea1.3.1-next.0-experimental-1dcd593
out/__test__/index.test.js~
out/__test__/index.test.jsModified−99
Index: package/out/__test__/index.test.js
===================================================================
--- package/out/__test__/index.test.js
+++ package/out/__test__/index.test.js
@@ -1180,104 +1180,5 @@
const { sut } = prepare(response);
const items = [{ key: 'foo', value: 'bar' }];
await expect(sut.batchSet(items)).rejects.toMatchError(new errors_1.ForgeKvsAPIError({ status: 500, statusText: 'Internal Server Error', traceId }, { code: 'INTERNAL_SERVER_ERROR', message: 'An internal server error has occurred' }));
});
- it('should handle batchDelete correctly with mixed entity and non-entity items', async () => {
- const response = new Response(JSON.stringify({
- successfulKeys: [{ key: 'foo', entityName: 'employees' }, { key: 'bar' }],
- failedKeys: [
- {
- key: 'baz',
- entityName: 'departments',
- error: { code: 'KEY_NOT_FOUND', message: 'Key does not exist' }
- }
- ]
- }), {
- status: 200,
- headers: { 'x-trace-id': traceId }
- });
- const { sut, apiClient } = prepare(response);
- const items = [{ key: 'foo', entityName: 'employees' }, { key: 'bar' }, { key: 'baz', entityName: 'departments' }];
- const rs = await sut.batchDelete(items);
- expect(rs).toEqual({
- successfulKeys: [{ key: 'foo', entityName: 'employees' }, { key: 'bar' }],
- failedKeys: [
- {
- key: 'baz',
- entityName: 'departments',
- error: { code: 'KEY_NOT_FOUND', message: 'Key does not exist' }
- }
- ]
- });
- expect(apiClient).toHaveBeenCalledWith('/api/v1/batch/delete', expect.objectContaining({
- body: JSON.stringify(items)
- }));
- });
- it('should handle batchDelete with all successful keys', async () => {
- const response = new Response(JSON.stringify({
- successfulKeys: [{ key: 'foo' }, { key: 'bar' }],
- failedKeys: []
- }), {
- status: 200,
- headers: { 'x-trace-id': traceId }
- });
- const { sut, apiClient } = prepare(response);
- const items = [{ key: 'foo' }, { key: 'bar' }];
- const rs = await sut.batchDelete(items);
- expect(rs).toEqual({
- successfulKeys: [{ key: 'foo' }, { key: 'bar' }],
- failedKeys: []
- });
- expect(apiClient).toHaveBeenCalledWith('/api/v1/batch/delete', expect.objectContaining({
- body: JSON.stringify(items)
- }));
- });
- it('should handle batchDelete with all failed keys', async () => {
- const response = new Response(JSON.stringify({
- successfulKeys: [],
- failedKeys: [
- {
- key: 'foo',
- error: { code: 'PERMISSION_DENIED', message: 'Access denied' }
- },
- {
- key: 'bar',
- entityName: 'employees',
- error: { code: 'KEY_NOT_FOUND', message: 'Key does not exist' }
- }
- ]
- }), {
- status: 200,
- headers: { 'x-trace-id': traceId }
- });
- const { sut, apiClient } = prepare(response);
- const items = [{ key: 'foo' }, { key: 'bar', entityName: 'employees' }];
- const rs = await sut.batchDelete(items);
- expect(rs).toEqual({
- successfulKeys: [],
- failedKeys: [
- {
- key: 'foo',
- error: { code: 'PERMISSION_DENIED', message: 'Access denied' }
- },
- {
- key: 'bar',
- entityName: 'employees',
- error: { code: 'KEY_NOT_FOUND', message: 'Key does not exist' }
- }
- ]
- });
- expect(apiClient).toHaveBeenCalledWith('/api/v1/batch/delete', expect.objectContaining({
- body: JSON.stringify(items)
- }));
- });
- it('should handle batchDelete API error response', async () => {
- const response = new Response(JSON.stringify({ code: 'INTERNAL_SERVER_ERROR', message: 'An internal server error has occurred' }), {
- status: 500,
- statusText: 'Internal Server Error',
- headers: { 'x-trace-id': traceId }
- });
- const { sut } = prepare(response);
- const items = [{ key: 'foo' }];
- await expect(sut.batchDelete(items)).rejects.toMatchError(new errors_1.ForgeKvsAPIError({ status: 500, statusText: 'Internal Server Error', traceId }, { code: 'INTERNAL_SERVER_ERROR', message: 'An internal server error has occurred' }));
- });
});