Skip to content

Commit

Permalink
test: add test to ensure all tracking event is used
Browse files Browse the repository at this point in the history
  • Loading branch information
DanSnow committed May 14, 2024
1 parent 464ef76 commit e214af4
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"devDependencies": {
"@0no-co/graphqlsp": "1.12.3",
"@antfu/eslint-config": "2.18.0",
"@effect/vitest": "0.4.3",
"@egoist/tailwindcss-icons": "1.8.0",
"@iconify-json/lucide": "1.1.187",
"@moonrepo/cli": "1.24.4",
Expand Down
19 changes: 19 additions & 0 deletions tests/tracking-event-used.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { expect } from 'vitest'
import { Array, Effect } from 'effect'
import { fs, glob } from 'zx'
import { it } from '@effect/vitest'
import { trackEventSchema } from '../src/lib/tracking-schema'

const eventNames = Array.fromIterable(trackEventSchema.optionsMap.keys()) as string[]

it.effect('use all tracking event', () => {
return Effect.gen(function* () {
const files = yield* Effect.promise(() => glob(['src/**/*', '!**/__tests__/**/*', '!src/lib/tracking-schema/**/*']))
const contents = yield* Effect.all(
files.map((file) => Effect.promise(() => fs.readFile(file, 'utf8'))),
{ concurrency: 'unbounded' },
)

expect(Array.every(eventNames, (name) => Array.some(contents, (content) => content.includes(name)))).toBe(true)
})
})
11 changes: 11 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,16 @@ __metadata:
languageName: node
linkType: hard

"@effect/vitest@npm:0.4.3":
version: 0.4.3
resolution: "@effect/vitest@npm:0.4.3"
peerDependencies:
effect: ^3.1.4
vitest: ^1.4.0
checksum: 10c0/a032147665be8b43ef9b37542b63a039446a8bf85bd6b4f325ff0cc1cc6830890e5e02db95ba808971b559267a4f7ad59ac9c4c02c4fbb431a614d99c6a87854
languageName: node
linkType: hard

"@egoist/tailwindcss-icons@npm:1.8.0":
version: 1.8.0
resolution: "@egoist/tailwindcss-icons@npm:1.8.0"
Expand Down Expand Up @@ -3533,6 +3543,7 @@ __metadata:
dependencies:
"@0no-co/graphqlsp": "npm:1.12.3"
"@antfu/eslint-config": "npm:2.18.0"
"@effect/vitest": "npm:0.4.3"
"@egoist/tailwindcss-icons": "npm:1.8.0"
"@formkit/auto-animate": "npm:^0.8.2"
"@iconify-json/lucide": "npm:1.1.187"
Expand Down

0 comments on commit e214af4

Please sign in to comment.