Skip to content

Commit

Permalink
Test JSON narrowing (#4840)
Browse files Browse the repository at this point in the history
### WHY are these changes introduced?

Adds test coverage for JSON type narrowing functionality to ensure proper validation of string map objects. This module was low on coverage.

### Measuring impact

How do we know this change was effective? Please choose one:

- [x] n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
- [ ] Existing analytics will cater for this addition
- [ ] PR includes analytics changes to measure impact

### Checklist

- [x] I've considered possible cross-platform impacts (Mac, Linux, Windows)
- [x] I've considered possible [documentation](https://shopify.dev) changes
  • Loading branch information
shauns authored Nov 12, 2024
2 parents 585e042 + 4ecff71 commit 13f7bb2
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/cli-kit/src/public/common/ts/json-narrowing.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {assertStringMap} from './json-narrowing.js'
import {BugError} from '@shopify/cli-kit/node/error'
import {describe, expect, test} from 'vitest'

describe('json-narrowing', () => {
test('assertStringMap', () => {
assertStringMap({yes: 'please'})
})
test('assertStringMap fails on null', () => {
expect(() => assertStringMap(null)).toThrow(BugError)
})
test('assertStringMap fails on non-object', () => {
expect(() => assertStringMap('hello')).toThrow(BugError)
})
})

0 comments on commit 13f7bb2

Please sign in to comment.