import { injectBootstrapConfig } from './bootstrap'; const SHELL = '
'; /** Every value these tests inject, as the client reads it back off the global. */ interface TestBootstrap { first?: boolean; second?: number; note?: string; flag?: boolean; } /** Runs the shell's injected scripts the way a browser would, so the assertions * are about what the client receives rather than about the markup's spelling. */ const bootstrapOf = (html: string): TestBootstrap => { const scripts = [...html.matchAll(/'; const html = injectBootstrapConfig(SHELL, { sentinel: 'data-librechat-test="true"', values: { note }, }); expect(html).not.toContain(''); expect(html.match(/<\/script>/g)).toHaveLength(1); expect(bootstrapOf(html)).toEqual({ note }); }); it('keeps `$` sequences in a value literal instead of expanding them', () => { const note = "$& $` $' $1 $$"; expect( bootstrapOf( injectBootstrapConfig(SHELL, { sentinel: 'data-librechat-test="true"', values: { note } }), ).note, ).toBe(note); expect( bootstrapOf( injectBootstrapConfig('', { sentinel: 'data-librechat-test="true"', values: { note }, }), ).note, ).toBe(note); }); it('lands ahead of the app in a document with no head at all', () => { const html = injectBootstrapConfig('', { sentinel: 'data-librechat-test="true"', values: { flag: true }, }); expect(html).toContain('