Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action tests #4

Merged
merged 2 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: 'Build Test'

on:
push:
branches:
- '**'

jobs:
build-test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v2
- name: Running Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
# Actual Tests
- run: npm i
- run: npm run lint --if-present
- run: npm run typecheck --if-present
- run: npm run bundle --if-present
6 changes: 3 additions & 3 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ const dummyClient = {
fetch: () => undefined,
set: () => undefined,
execute: () => undefined,
return: () => {},
return: () => undefined,
get: () => undefined,
attachEvent: () => {},
detachEvent: () => {},
attachEvent: () => undefined,
detachEvent: () => undefined,
}

describe('Hubspot MC event handler works correctly', () => {
Expand Down
6 changes: 2 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ComponentSettings, Manager, MCEvent } from '@managed-components/types'
import { uuidv4NoDashes, hashString, getRegionPrefix } from './utils'
import UAParser from 'ua-parser-js'

export const sendEvent =
(settings: ComponentSettings) => async (event: MCEvent) => {
Expand Down Expand Up @@ -131,9 +130,8 @@ export const handleChatEvent =

const getFormEventRequestData = (event: MCEvent, portalId: string) => {
const { client, payload } = event
let {
formId,
formClass,
let { formId, formClass } = payload
const {
timestamp,
email,
firstName,
Expand Down
4 changes: 3 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ export const uuidv4NoDashes = () => {
}

export const hashString = (t: string) => {
for (var e = 0, n = t.length - 1; n >= 0; n--) {
let e = 0,
n = 0
for (e = 0, n = t.length - 1; n >= 0; n--) {
let i = t.charCodeAt(n)
e =
0 !== (i = 266338304 & (e = ((e << 6) & 268435455) + i + (i << 14)))
Expand Down