Skip to content

Commit

Permalink
fix(app): lint
Browse files Browse the repository at this point in the history
  • Loading branch information
elgorditosalsero committed Apr 28, 2023
1 parent 495c3c5 commit bc37bb6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
18 changes: 16 additions & 2 deletions src/utils/GoogleTagManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ const setupGTM = (params: ISnippetsParams): ISetupGTM => {
if (params.nonce) {
script.setAttribute('nonce', params.nonce)
}
script.innerHTML = getGTMScript(params.dataLayerName, params.id, params.environment, params.customDomain, params.customScriptName)
script.innerHTML = getGTMScript(
params.dataLayerName,
params.id,
params.environment,
params.customDomain,
params.customScriptName
)
return script
}

Expand All @@ -45,7 +51,15 @@ const setupGTM = (params: ISnippetsParams): ISetupGTM => {
* @param nonce - Server-generated nonce
* @param id - The ID of the GTM
*/
export const initGTM = ({ dataLayer, dataLayerName, environment, nonce, id, customDomain, customScriptName }: ISnippetsParams): void => {
export const initGTM = ({
dataLayer,
dataLayerName,
environment,
nonce,
id,
customDomain,
customScriptName
}: ISnippetsParams): void => {
const gtm = setupGTM({
dataLayer,
dataLayerName,
Expand Down
6 changes: 3 additions & 3 deletions src/utils/snippets.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ICustomEnvironmentParams, IDataLayer, ISnippets, ISnippetsParams} from '../models/GoogleTagManager'
import { ICustomEnvironmentParams, IDataLayer, ISnippets, ISnippetsParams } from '../models/GoogleTagManager'

export const DEFAULT_DOMAIN = 'https://www.googletagmanager.com'
export const DEFAULT_SCRIPT_NAME = 'gtm.js'
Expand Down Expand Up @@ -28,7 +28,7 @@ export const getIframeSnippet = (
) => {
let params = ``
if (environment) {
const {gtm_auth, gtm_preview} = environment
const { gtm_auth, gtm_preview } = environment
params = `&gtm_auth=${gtm_auth}&gtm_preview=${gtm_preview}&gtm_cookies_win=x`
}
return `<iframe src="${customDomain}/ns.html?id=${id}${params}" height="0" width="0" style="display:none;visibility:hidden" id="tag-manager"></iframe>`
Expand All @@ -51,7 +51,7 @@ export const getGTMScript = (
) => {
let params = ``
if (environment) {
const {gtm_auth, gtm_preview} = environment
const { gtm_auth, gtm_preview } = environment
params = `+"&gtm_auth=${gtm_auth}&gtm_preview=${gtm_preview}&gtm_cookies_win=x"`
}
return `
Expand Down
14 changes: 7 additions & 7 deletions test/snippets.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {DEFAULT_DOMAIN, getDataLayerSnippet, getGTMScript, getIframeSnippet} from '../src/utils/snippets'
import {ISnippetsParams} from '../src/models/GoogleTagManager'
import { DEFAULT_DOMAIN, getDataLayerSnippet, getGTMScript, getIframeSnippet } from '../src/utils/snippets'
import { ISnippetsParams } from '../src/models/GoogleTagManager'

describe('Suite of snippets functions', () => {
describe('Suite of getDataLayerSnippet', () => {
let dataLayer: Object
let dataLayerName: string

beforeEach(() => {
dataLayer = {user: 'testUser'}
dataLayer = { user: 'testUser' }
dataLayerName = 'customDataLayer'
})

Expand Down Expand Up @@ -35,12 +35,12 @@ describe('Suite of snippets functions', () => {
let params: ISnippetsParams

beforeEach(() => {
params = {id: 'GTM-custom-name'}
params = { id: 'GTM-custom-name' }
})

it('should return the script with the default dataLayerName', () => {
const customDataLayerName = 'customDL'
params = {...params, dataLayerName: customDataLayerName}
params = { ...params, dataLayerName: customDataLayerName }

const gtmSnippet = getGTMScript(params.dataLayerName, params.id)

Expand All @@ -54,7 +54,7 @@ describe('Suite of snippets functions', () => {
it('should return the script with the custom domain', () => {
const customDomain = 'https://www.example.com'
const customDataLayerName = 'customDL'
params = {...params, dataLayerName: customDataLayerName, customDomain: customDomain}
params = { ...params, dataLayerName: customDataLayerName, customDomain: customDomain }

const gtmSnippet = getGTMScript(params.dataLayerName, params.id, undefined, params.customDomain)

Expand Down Expand Up @@ -92,7 +92,7 @@ describe('Suite of snippets functions', () => {
let params: ISnippetsParams

beforeEach(() => {
params = {id: 'GTM-iframe'}
params = { id: 'GTM-iframe' }
})

it('should return the iframe snippet with the passed id', () => {
Expand Down

0 comments on commit bc37bb6

Please sign in to comment.