npm package diff

Package: @forge/storage

Versions: 1.6.0 - 1.7.0-next.0

File: package/out/__test__/global-storage.test.js

Index: package/out/__test__/global-storage.test.js
===================================================================
--- package/out/__test__/global-storage.test.js
+++ package/out/__test__/global-storage.test.js
@@ -3,10 +3,9 @@
 const errors_1 = require("../errors");
 const global_storage_1 = require("../global-storage");
 const gql_queries_1 = require("../gql-queries");
 const mocks_1 = require("@atlassian/metrics-interface/dist/mocks");
-const contextAri = 'app-ari';
-const getStorage = (apiClientMock, metrics) => new global_storage_1.GlobalStorage(() => contextAri, apiClientMock, () => metrics);
+const getStorage = (apiClientMock, metrics) => new global_storage_1.GlobalStorage(apiClientMock, () => metrics);
 const getApiClientMock = (response, statusCode = 200) => {
     return jest.fn().mockReturnValue({
         ok: statusCode === 200,
         status: statusCode,
@@ -71,13 +70,8 @@
         const [, { body }] = apiClientMock.mock.calls[0];
         const expectedBody = query ? { query, variables } : { variables };
         expect(JSON.parse(body)).toEqual(expect.objectContaining(expectedBody));
     }
-    beforeEach(() => {
-        global.api = {
-            __getAppAri: jest.fn().mockReturnValue(contextAri)
-        };
-    });
     describe('get', () => {
         it('should call the storage API, passing the provided key and returning the stored value', async () => {
             const apiClientMock = getApiClientMock({
                 data: {
@@ -89,9 +83,8 @@
             const metricMocks = getMetricMock();
             const globalStorage = getStorage(apiClientMock, passMetrics ? metricMocks.mockMetrics : undefined);
             const returnedValue = await globalStorage.get('testKey');
             verifyApiClientCalledWith(apiClientMock, {
-                contextAri,
                 key: 'testKey',
                 encrypted: false
             });
             expect(returnedValue).toEqual('testValue');
@@ -110,9 +103,8 @@
             const metricMocks = getMetricMock();
             const globalStorage = getStorage(apiClientMock, passMetrics ? metricMocks.mockMetrics : undefined);
             const returnedValue = await globalStorage.get('testKey');
             verifyApiClientCalledWith(apiClientMock, {
-                contextAri,
                 key: 'testKey',
                 encrypted: false
             });
             expect(returnedValue).toEqual(undefined);
@@ -131,9 +123,8 @@
             const metricMocks = getMetricMock();
             const globalStorage = getStorage(apiClientMock, passMetrics ? metricMocks.mockMetrics : undefined);
             const returnedValue = await globalStorage.get('testKey');
             verifyApiClientCalledWith(apiClientMock, {
-                contextAri,
                 key: 'testKey',
                 encrypted: false
             });
             expect(returnedValue).toEqual(0);
@@ -152,9 +143,8 @@
             const metricMocks = getMetricMock();
             const globalStorage = getStorage(apiClientMock, passMetrics ? metricMocks.mockMetrics : undefined);
             const returnedValue = await globalStorage.get('testKey');
             verifyApiClientCalledWith(apiClientMock, {
-                contextAri,
                 key: 'testKey',
                 encrypted: false
             });
             expect(returnedValue).toEqual('');
@@ -210,9 +200,8 @@
             const metricMocks = getMetricMock();
             const globalStorage = getStorage(apiClientMock, passMetrics ? metricMocks.mockMetrics : undefined);
             const returnedValue = await globalStorage.getSecret('testKey');
             verifyApiClientCalledWith(apiClientMock, {
-                contextAri,
                 key: 'testKey',
                 encrypted: true
             });
             expect(returnedValue).toEqual('testValue');
@@ -236,9 +225,8 @@
             const globalStorage = getStorage(apiClientMock, passMetrics ? metricMocks.mockMetrics : undefined);
             await globalStorage.set('testKey', 'testValue');
             verifyApiClientCalledWith(apiClientMock, {
                 input: {
-                    contextAri,
                     key: 'testKey',
                     value: 'testValue',
                     encrypted: false
                 }
@@ -292,9 +280,8 @@
             const globalStorage = getStorage(apiClientMock, passMetrics ? metricMocks.mockMetrics : undefined);
             await expect(globalStorage.set('testKey', 'testValue')).rejects.toThrow(errors_1.APIError.forStatus(500));
             verifyApiClientCalledWith(apiClientMock, {
                 input: {
-                    contextAri,
                     key: 'testKey',
                     value: 'testValue',
                     encrypted: false
                 }
@@ -319,9 +306,8 @@
             const globalStorage = getStorage(apiClientMock, passMetrics ? metricMocks.mockMetrics : undefined);
             await globalStorage.setSecret('testKey', 'testValue');
             verifyApiClientCalledWith(apiClientMock, {
                 input: {
-                    contextAri,
                     key: 'testKey',
                     value: 'testValue',
                     encrypted: true
                 }
@@ -346,9 +332,8 @@
             const globalStorage = getStorage(apiClientMock, passMetrics ? metricMocks.mockMetrics : undefined);
             await globalStorage.delete('testKey');
             verifyApiClientCalledWith(apiClientMock, {
                 input: {
-                    contextAri,
                     key: 'testKey',
                     encrypted: false
                 }
             });
@@ -403,9 +388,8 @@
             const globalStorage = getStorage(apiClientMock, passMetrics ? metricMocks.mockMetrics : undefined);
             await globalStorage.deleteSecret('testKey');
             verifyApiClientCalledWith(apiClientMock, {
                 input: {
-                    contextAri,
                     key: 'testKey',
                     encrypted: true
                 }
             });
@@ -426,9 +410,8 @@
             const metricMocks = getMetricMock();
             const globalStorage = getStorage(apiClientMock, passMetrics ? metricMocks.mockMetrics : undefined);
             const returnedValue = await globalStorage.getEntity('testEntityName', 'testEntityKey');
             verifyApiClientCalledWith(apiClientMock, {
-                contextAri,
                 entityName: 'testEntityName',
                 key: 'testEntityKey'
             });
             expect(returnedValue).toEqual('testValue');
@@ -447,9 +430,8 @@
             const metricMocks = getMetricMock();
             const globalStorage = getStorage(apiClientMock, passMetrics ? metricMocks.mockMetrics : undefined);
             const returnedValue = await globalStorage.getEntity('testEntityName', 'testEntityKey');
             verifyApiClientCalledWith(apiClientMock, {
-                contextAri,
                 entityName: 'testEntityName',
                 key: 'testEntityKey'
             });
             expect(returnedValue).toEqual(undefined);
@@ -468,9 +450,8 @@
             const metricMocks = getMetricMock();
             const globalStorage = getStorage(apiClientMock, passMetrics ? metricMocks.mockMetrics : undefined);
             const returnedValue = await globalStorage.getEntity('testEntityName', 'testEntityKey');
             verifyApiClientCalledWith(apiClientMock, {
-                contextAri,
                 entityName: 'testEntityName',
                 key: 'testEntityKey'
             });
             expect(returnedValue).toEqual(0);
@@ -489,9 +470,8 @@
             const metricMocks = getMetricMock();
             const globalStorage = getStorage(apiClientMock, passMetrics ? metricMocks.mockMetrics : undefined);
             const returnedValue = await globalStorage.getEntity('testEntityName', 'testEntityKey');
             verifyApiClientCalledWith(apiClientMock, {
-                contextAri,
                 entityName: 'testEntityName',
                 key: 'testEntityKey'
             });
             expect(returnedValue).toEqual('');
@@ -550,9 +530,8 @@
             const globalStorage = getStorage(apiClientMock, passMetrics ? metricMocks.mockMetrics : undefined);
             await globalStorage.setEntity('testEntityName', 'testEntityKey', 'testValue');
             verifyApiClientCalledWith(apiClientMock, {
                 input: {
-                    contextAri,
                     entityName: 'testEntityName',
                     key: 'testEntityKey',
                     value: 'testValue'
                 }
@@ -606,9 +585,8 @@
             const globalStorage = getStorage(apiClientMock, passMetrics ? metricMocks.mockMetrics : undefined);
             await expect(globalStorage.setEntity('testEntityName', 'testEntityKey', 'testValue')).rejects.toThrow(errors_1.APIError.forStatus(500));
             verifyApiClientCalledWith(apiClientMock, {
                 input: {
-                    contextAri,
                     entityName: 'testEntityName',
                     key: 'testEntityKey',
                     value: 'testValue'
                 }
@@ -633,9 +611,8 @@
             const globalStorage = getStorage(apiClientMock, passMetrics ? metricMocks.mockMetrics : undefined);
             await globalStorage.deleteEntity('testEntityName', 'testEntityKey');
             verifyApiClientCalledWith(apiClientMock, {
                 input: {
-                    contextAri,
                     entityName: 'testEntityName',
                     key: 'testEntityKey'
                 }
             });
@@ -699,13 +676,12 @@
             const cursor = 'cursor';
             const limit = 10;
             const response = await globalStorage.list({ where, cursor, limit });
             verifyApiClientCalledWith(apiClientMock, {
-                contextAri,
                 where,
                 cursor,
                 limit
-            }, gql_queries_1.UntypedQueries.listQuery(contextAri, {}).query);
+            }, gql_queries_1.UntypedQueries.listQuery({}).query);
             expect(response).toEqual(expect.objectContaining({
                 results: [
                     { key: 'key1', value: 'testValue' },
                     { key: 'key2', value: 'testValue' }
@@ -740,13 +716,12 @@
             const cursor = 'cursor';
             const limit = 10;
             const response = await globalStorage.list({ where, cursor, limit });
             verifyApiClientCalledWith(apiClientMock, {
-                contextAri,
                 where,
                 cursor,
                 limit
-            }, gql_queries_1.UntypedQueries.listQueryForCleanup(contextAri, {}).query);
+            }, gql_queries_1.UntypedQueries.listQueryForCleanup({}).query);
             expect(response).toEqual(expect.objectContaining({
                 results: [
                     { key: 'key1', value: 'testValue' },
                     { key: 'key2', value: 'testValue' }
@@ -769,13 +744,12 @@
             const metricMocks = getMetricMock();
             const globalStorage = getStorage(apiClientMock, passMetrics ? metricMocks.mockMetrics : undefined);
             await globalStorage.list({});
             verifyApiClientCalledWith(apiClientMock, {
-                contextAri,
                 where: null,
                 cursor: null,
                 limit: null
-            }, gql_queries_1.UntypedQueries.listQuery(contextAri, {}).query);
+            }, gql_queries_1.UntypedQueries.listQuery({}).query);
             passMetrics
                 ? checkMetricsFired(metricMocks, { store: 'untyped', operation: 'query', encrypted: false }, true)
                 : expect(metricMocks.mockMetrics.counter).not.toHaveBeenCalled();
         });
@@ -845,11 +819,9 @@
             expect(response).toMatchObject({
                 results: [],
                 nextCursor: null
             });
-            verifyApiClientCalledWith(apiClientMock, {
-                contextAri
-            }, gql_queries_1.CustomEntityQueries.listQuery(contextAri, {}).query);
+            verifyApiClientCalledWith(apiClientMock, {}, gql_queries_1.CustomEntityQueries.listQuery({}).query);
             passMetrics
                 ? checkMetricsFired(metricMocks, { store: 'typed', operation: 'query', encrypted: false }, true)
                 : expect(metricMocks.mockMetrics.counter).not.toHaveBeenCalled();
         });
@@ -868,11 +840,9 @@
             expect(response).toMatchObject({
                 results: [],
                 nextCursor: 'DUMMY_CURSOR'
             });
-            verifyApiClientCalledWith(apiClientMock, {
-                contextAri
-            }, gql_queries_1.CustomEntityQueries.listQuery(contextAri, {}).query);
+            verifyApiClientCalledWith(apiClientMock, {}, gql_queries_1.CustomEntityQueries.listQuery({}).query);
             passMetrics
                 ? checkMetricsFired(metricMocks, { store: 'typed', operation: 'query', encrypted: false }, true)
                 : expect(metricMocks.mockMetrics.counter).not.toHaveBeenCalled();
         });