Something went wrong. Try again.
Browser extension: detect and subscribe to standard.site publications on ATProto
Something went wrong. Try again.
2.3 kB · 63 lines
JavaScript
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364import { describe, expect, it } from 'vitest'import { classifyAuthProbe, latestReleaseZip } from './rc-load.mjs'
describe('latestReleaseZip', () => { it('picks the highest version, not the lexicographically largest', () => { expect( latestReleaseZip([ 'substandard-v1.9.0.zip', 'substandard-v1.10.0.zip', 'substandard-v1.2.1.zip', ]), ).toBe('substandard-v1.10.0.zip') })
it('compares patch versions', () => { expect(latestReleaseZip(['substandard-v1.4.0.zip', 'substandard-v1.4.10.zip'])).toBe( 'substandard-v1.4.10.zip', ) })
it('ignores files that are not release zips', () => { expect(latestReleaseZip(['notes.txt', 'substandard-v1.0.0.zip', 'substandard.zip'])).toBe( 'substandard-v1.0.0.zip', ) })
it('returns undefined when there is nothing to pick', () => { expect(latestReleaseZip([])).toBeUndefined() expect(latestReleaseZip(['README.md'])).toBeUndefined() })})
describe('classifyAuthProbe', () => { // The regression this script exists for: the artifact's bundled metadata // does not cover the id it is actually running under. it('flags the v1.2.1 failure', () => { expect(classifyAuthProbe({ settled: { __error: 'Invalid redirect_uri' } })).toBe( 'invalid-redirect', ) })
it('flags it however the error surfaced', () => { expect(classifyAuthProbe({ threw: 'TypeError: Invalid redirect_uri' })).toBe('invalid-redirect') })
// Reaching identity resolution means the redirect_uri check passed, which is // the only thing this probe is asking about; the bogus handle is expected to // fail right after. it('passes a build that gets as far as resolving the handle', () => { expect( classifyAuthProbe({ settled: { __error: 'Failed to resolve identity: rc-probe.invalid' } }), ).toBe('ok') })
it('passes a build that somehow returned an authorization url', () => { expect(classifyAuthProbe({ settled: 'https://bsky.social/oauth/authorize?x=1' })).toBe('ok') })
// Never reported as a pass: a timeout means the question went unanswered. it('reports a timeout as inconclusive rather than ok', () => { expect(classifyAuthProbe({ timedOut: true })).toBe('inconclusive') })})