From 0502e8d247370453e1c6d17e0e5ff19fb47974a9 Mon Sep 17 00:00:00 2001 From: Miguel Beltran Date: Tue, 19 Nov 2024 10:45:37 +0100 Subject: [PATCH] prettier --- .github/workflows/sdk.yaml | 2 +- sdk/__mocks__/RaygunNativeBridge.js | 4 +- sdk/__tests__/RaygunClient.test.tsx | 108 ++++++++++++++-------------- sdk/package.json | 2 +- 4 files changed, 58 insertions(+), 58 deletions(-) diff --git a/.github/workflows/sdk.yaml b/.github/workflows/sdk.yaml index 663f00b..17b1f25 100644 --- a/.github/workflows/sdk.yaml +++ b/.github/workflows/sdk.yaml @@ -44,5 +44,5 @@ jobs: # "dry" causes that if any file is modified, the job fails dry: True # "write" performs changes in place - prettier_options: --write . + prettier_options: --write "**/*.js" "**/*.ts" "**/*.tsx" github_token: ${{ secrets.PERSONAL_GITHUB_TOKEN }} diff --git a/sdk/__mocks__/RaygunNativeBridge.js b/sdk/__mocks__/RaygunNativeBridge.js index 86d8b18..eb2c7c5 100644 --- a/sdk/__mocks__/RaygunNativeBridge.js +++ b/sdk/__mocks__/RaygunNativeBridge.js @@ -1,5 +1,5 @@ -import {NativeModules} from 'react-native'; +import { NativeModules } from 'react-native'; NativeModules.RaygunNativeBridge = { - DEVICE_ID: '1234567890', + DEVICE_ID: '1234567890' }; diff --git a/sdk/__tests__/RaygunClient.test.tsx b/sdk/__tests__/RaygunClient.test.tsx index 107e7d9..da234ec 100644 --- a/sdk/__tests__/RaygunClient.test.tsx +++ b/sdk/__tests__/RaygunClient.test.tsx @@ -3,58 +3,58 @@ import { init, sendError } from '../src/RaygunClient'; import { RaygunClientOptions } from '../src/Types'; describe('RaygunClient', () => { - beforeAll(() => { - const options: RaygunClientOptions = { - apiKey: 'ABCD', - version: '1.2.3', - logLevel: 'off', - enableCrashReporting: true, - enableRealUserMonitoring: false, - disableNativeCrashReporting: true, - }; - init(options); - - global.fetch = jest.fn(() => - Promise.resolve({ - status: 200, - }) - ); - }); - - beforeEach(() => { - fetch.mockClear(); - }); - - it('should send error correctly', async () => { - const error = new Error('Test error'); - await sendError(error); - - // fetch should be called once - expect(fetch).toHaveBeenCalledTimes(1); - - // Check url correct - expect(fetch.mock.calls[0][0]).toBe('https://api.raygun.com/entries?apiKey=ABCD'); - - // Capture body from fetch and check if correct - const body = JSON.parse(fetch.mock.calls[0][1].body); - expect(body.Details.Error.Message).toBe('Test error'); - - // Check if the version is correct - expect(body.Details.Version).toBe('1.2.3'); - }); - - it('should fail to send error', async () => { - fetch.mockImplementationOnce(() => Promise.reject('API is down')); - const error = new Error('Failed error'); - await sendError(error); - - expect(fetch).toHaveBeenCalledTimes(1); - - // failed to send error should be stored in AsyncStorage - const storedErrors = await AsyncStorage.getItem('raygun4reactnative_local_storage'); - expect(storedErrors).not.toBeNull(); - - const errors = JSON.parse(storedErrors); - expect(errors[0].Details.Error.Message).toBe('Failed error'); - }); + beforeAll(() => { + const options: RaygunClientOptions = { + apiKey: 'ABCD', + version: '1.2.3', + logLevel: 'off', + enableCrashReporting: true, + enableRealUserMonitoring: false, + disableNativeCrashReporting: true + }; + init(options); + + global.fetch = jest.fn(() => + Promise.resolve({ + status: 200 + }) + ); + }); + + beforeEach(() => { + fetch.mockClear(); + }); + + it('should send error correctly', async () => { + const error = new Error('Test error'); + await sendError(error); + + // fetch should be called once + expect(fetch).toHaveBeenCalledTimes(1); + + // Check url correct + expect(fetch.mock.calls[0][0]).toBe('https://api.raygun.com/entries?apiKey=ABCD'); + + // Capture body from fetch and check if correct + const body = JSON.parse(fetch.mock.calls[0][1].body); + expect(body.Details.Error.Message).toBe('Test error'); + + // Check if the version is correct + expect(body.Details.Version).toBe('1.2.3'); + }); + + it('should fail to send error', async () => { + fetch.mockImplementationOnce(() => Promise.reject('API is down')); + const error = new Error('Failed error'); + await sendError(error); + + expect(fetch).toHaveBeenCalledTimes(1); + + // failed to send error should be stored in AsyncStorage + const storedErrors = await AsyncStorage.getItem('raygun4reactnative_local_storage'); + expect(storedErrors).not.toBeNull(); + + const errors = JSON.parse(storedErrors); + expect(errors[0].Details.Error.Message).toBe('Failed error'); + }); }); diff --git a/sdk/package.json b/sdk/package.json index 15fb330..8f2f911 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -28,7 +28,7 @@ "run_demo_3:windows": "cd ../demo && npx react-native run-android", "run_demo_3:macos": "cd ../demo && cd ios && pod install && cd ../ && npx react-native run-ios", "run_demo_3:linux": "cd ../demo && gnome-terminal -x bash -c \"npx react-native start\" && npx react-native run-android", - "prettier": "npx prettier --write src", + "prettier": "npx prettier --write **/*.js **/*.ts **/*.tsx", "test": "jest" }, "repository": {