Skip to content
Closed
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
26 changes: 26 additions & 0 deletions packages/theme/src/cli/utilities/theme-file-path.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {validateListingName} from './theme-file-path.js'
import {test, describe, expect} from 'vitest'
import {AbortError} from '@shopify/cli-kit/node/error'

describe('validateListingName', () => {
test.each([
['an empty name', ''],
['the current directory', '.'],
['the parent directory', '..'],
['a POSIX separator', 'modern/../../outside'],
['a Windows separator', 'modern\\..\\..\\outside'],
['a leading POSIX separator', '/outside'],
['a leading Windows separator', '\\outside'],
['an uppercase drive letter', 'C:\\outside'],
['a lowercase drive letter', 'c:outside'],
])('rejects a listing name containing %s', (_description, listingName) => {
expect(() => validateListingName(listingName)).toThrow(AbortError)
})

test.each([['modern'], ['two-words'], ['..periods'], ['...']])(
'accepts the listing name %s, which stays inside the listings directory',
(listingName) => {
expect(() => validateListingName(listingName)).not.toThrow()
},
)
})