Skip to content

Commit

Permalink
Merge be41179 into 914194e
Browse files Browse the repository at this point in the history
  • Loading branch information
alinayh committed Sep 14, 2023
2 parents 914194e + be41179 commit b271fad
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 7 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/code_format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Code Format
on: [push, pull_request]
jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: npm ci
- name: Run Prettier and ESLint
run: |
npm run format
npm run lint
- name: Commit and push formatting changes
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email 'action@github.com'
git add -A
git commit -m "Auto-fix formatting issues with Prettier and ESLint" || echo "No changes to commit"
git push
9 changes: 9 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.github/
coverage/
docs/
etc/
lib/
dist/
package*.json
LICENSE
THIRD-PARTY-NOTICES
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
],
"scripts": {
"build": "rm -rf lib/** && tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && npm run api-extractor && npm run generate-docs && npm run generate-notices && vite build",
"lint": "eslint .",
"format": "prettier --write .",
"lint": "eslint . --fix",
"api-extractor": "api-extractor run --local --verbose",
"generate-docs": "api-documenter markdown --input-folder temp --output-folder docs && rm -rf temp",
"prepublishOnly": "npm run build",
Expand Down
10 changes: 5 additions & 5 deletions tests/AnalyticsEventReporter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ describe('Test report function', () => {
});
});

it('should call post with correct fields, report should return error json if post returns an error',
it('call post with correct fields, report should return error json if post returns an error',
async () => {
const mockSetupSessionId = getOrSetupSessionId as jest.MockedFunction<typeof getOrSetupSessionId>;

Expand Down Expand Up @@ -217,7 +217,7 @@ describe('Test report function', () => {
});


it('should call post with correct fields, should set sessionId undefined if session tracking disabled',
it('call post with correct fields and set sessionId undefined if session tracking disabled',
async () => {
const mockSetupSessionId = getOrSetupSessionId as jest.MockedFunction<typeof getOrSetupSessionId>;

Expand Down Expand Up @@ -320,7 +320,7 @@ describe('Test report function', () => {
});
});

it('calling report with an argument with no with call should result in request body coming from report',
it('report with an argument with no with() should result in request body coming from report',
async () => {
mockPostWithBeacon.mockReturnValueOnce(true);
mockUseBeacon.mockReturnValueOnce(true);
Expand Down Expand Up @@ -357,7 +357,7 @@ describe('Test report function', () => {
});
});

it('calling report with no argument and no with call should result in invalid request body and error',
it('report with no argument and no with() should result in invalid request body and error',
async () => {
mockPostWithFetch.mockResolvedValue({
ok: false,
Expand Down Expand Up @@ -409,7 +409,7 @@ describe('Test report function', () => {
});
});

it('calling with more than once should result in unique objects that can be called with unique values',
it('multiple with() should result in unique objects with unique values',
async () => {
mockPostWithBeacon.mockReturnValueOnce(true);
mockUseBeacon.mockReturnValueOnce(true);
Expand Down
2 changes: 1 addition & 1 deletion tests/post.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { EventPayload } from '../src/EventPayload';
import { EventAPIResponse } from '../src/EventAPIResponse';
import { postWithBeacon, postWithFetch, useBeacon } from '../src/post';
const fetchMock = /** @type {FetchMockJest} */ (require('fetch-mock-jest'));
import fetchMock from 'fetch-mock-jest';

describe('Test post util function', () => {

Expand Down

0 comments on commit b271fad

Please sign in to comment.