silverwolf-x's picture
download
raw
1.58 kB
import { SuffixPathnameNormalizer } from './suffix'
describe('SuffixPathnameNormalizer', () => {
describe('match', () => {
it('should return false if the pathname does not end with `.rsc`', () => {
const normalizer = new SuffixPathnameNormalizer('.rsc')
const pathnames = ['/foo', '/foo/bar', '/fooo/bar']
for (const pathname of pathnames) {
expect(normalizer.match(pathname)).toBe(false)
}
})
it('should return true if it matches', () => {
const normalizer = new SuffixPathnameNormalizer('.rsc')
const pathnames = ['/foo.rsc', '/foo/bar.rsc', '/fooo/bar.rsc']
for (const pathname of pathnames) {
expect(normalizer.match(pathname)).toBe(true)
}
})
})
describe('normalize', () => {
it('should return the same pathname if we are not matched and the pathname does not end with `.rsc`', () => {
const normalizer = new SuffixPathnameNormalizer('.rsc')
const pathnames = ['/foo', '/foo/bar', '/fooo/bar']
for (const pathname of pathnames) {
expect(normalizer.normalize(pathname)).toBe(pathname)
}
})
it('should strip the `.rsc` extension from the pathname when it matches', () => {
const normalizer = new SuffixPathnameNormalizer('.rsc')
const pathnames = ['/foo.rsc', '/foo/bar.rsc', '/fooo/bar.rsc']
const expected = ['/foo', '/foo/bar', '/fooo/bar']
for (const pathname of pathnames) {
expect(normalizer.normalize(pathname)).toBe(
expected[pathnames.indexOf(pathname)]
)
}
})
})
})

Xet Storage Details

Size:
1.58 kB
·
Xet hash:
d2b43d861f76024216f9957cf6bfd56f7c1964af3499c176a86631f20041a527

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.