Skip to content

Commit

Permalink
refactor(packages/sui-react-web-vitals): fix logger.cwv test
Browse files Browse the repository at this point in the history
  • Loading branch information
nucliweb committed Feb 8, 2024
1 parent 6c1f1a2 commit a2f49b5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
6 changes: 1 addition & 5 deletions packages/sui-react-web-vitals/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ export default function WebVitalsReporter({
}, [onReport])

useMount(() => {
const {
deviceMemory,
connection: {effectiveType},
hardwareConcurrency
} = window.navigator
const {deviceMemory, connection: {effectiveType} = {}, hardwareConcurrency} = window.navigator || {}

const getRouteid = () => {
return route?.id
Expand Down
14 changes: 7 additions & 7 deletions packages/sui-react-web-vitals/test/browser/indexSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ describe('WebVitalsReporter', () => {
])
})

it.skip('should track inp with deviceMemory, networkConnection, and hardwareConcurrency using logger cwv', async () => {
it('should track inp with deviceMemory, networkConnection, and hardwareConcurrency using logger cwv', async () => {
const logger = {
cwv: sinon.spy()
}
Expand All @@ -302,15 +302,15 @@ describe('WebVitalsReporter', () => {
await waitFor(() => [
expect(
logger.cwv.calledWith({
amount: 304,
deviceMemory: 8,
effectiveType: '4g',
eventType: 'body',
hardwareConcurrency: 10,
name: 'cwv.inp',
amount: 304,
path: '/',
target: undefined,
visibilityState: 'hidden'
visibilityState: document.visibilityState,
eventType: 'body',
deviceMemory: 8,
effectiveType: '4g',
hardwareConcurrency: 10
})
).to.be.true
])
Expand Down

0 comments on commit a2f49b5

Please sign in to comment.