npm package diff
Package: @forge/storage
Versions: 1.5.15-experimental-f6dcf26 - 1.5.15-experimental-204139e
File: package/out/__test__/transaction-api.test.js
Index: package/out/__test__/transaction-api.test.js
===================================================================
--- package/out/__test__/transaction-api.test.js
+++ package/out/__test__/transaction-api.test.js
@@ -0,0 +1,54 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+const __1 = require("..");
+const transaction_api_1 = require("../transaction-api");
+const contextAri = 'app-ari';
+const getStorage = (apiClientMock) => new __1.GlobalStorage(() => contextAri, apiClientMock);
+const getApiClientMock = (response, statusCode = 200) => {
+ return jest.fn().mockReturnValue({
+ ok: statusCode === 200,
+ status: statusCode,
+ text: jest.fn().mockResolvedValue(JSON.stringify(response))
+ });
+};
+describe('Transaction', () => {
+ it('KVS Test', async () => {
+ const apiClientMock = getApiClientMock({
+ data: {
+ appStoredEntity: {
+ value: 'testValue'
+ }
+ }
+ });
+ const globalStorage = getStorage(apiClientMock);
+ await new transaction_api_1.DefaultTransactionBuilder(globalStorage)
+ .set('user1', { name: 'anirudh' })
+ .set('user2', { name: 'Shivam' })
+ .delete('FSQL-101')
+ .execute();
+ });
+ it('Custom Entity Test', async () => {
+ const apiClientMock = getApiClientMock({
+ data: {
+ appStoredEntity: {
+ value: 'testValue'
+ }
+ }
+ });
+ const globalStorage = getStorage(apiClientMock);
+ await new transaction_api_1.DefaultTransactionBuilder(globalStorage)
+ .entity('users')
+ .set('user1', { name: 'anirudh' })
+ .andCondition('name', __1.FilterConditions.beginsWith('An'))
+ .andCondition('age', __1.FilterConditions.isLessThan(20))
+ .set('user2', { name: 'Shivam' })
+ .orCondition('name', __1.FilterConditions.beginsWith('Si'))
+ .orCondition('type', __1.FilterConditions.equalsTo('admin'))
+ .entity('projects')
+ .delete('FSQL-101')
+ .andCondition('type', __1.FilterConditions.equalsTo('BUG'))
+ .set('ESS-2', { type: 'Story' })
+ .andCondition('name', __1.FilterConditions.doesNotExist())
+ .execute();
+ });
+});