import { FileType, GeneratedFile, ProjectPluginStructure } from '@teleporthq/teleport-types'
import { appendGlobalCss, appendPageScript } from '../../src/global-css'
// A page as Prettier writes it with strict whitespace (the editor's "strict
// white spacing for HTML" setting): no closing tag stands on its own.
const STRICT_PAGE = [
'',
'
HomeContent
',
].join('\n')
const structureWith = (page: string): ProjectPluginStructure =>
({
files: new Map([
['index', { path: [''], files: [{ name: 'index', fileType: FileType.HTML, content: page }] }],
]),
} as unknown as ProjectPluginStructure)
const pageOf = (structure: ProjectPluginStructure): string =>
(structure.files.get('index').files as GeneratedFile[])[0].content
describe('Global CSS and page scripts in a page whose tags close the strict way', () => {
it('a project without a stylesheet carries the CSS inside the head, after the doctype', () => {
const structure = structureWith(STRICT_PAGE)
appendGlobalCss(structure, '.rail { overflow: hidden; }\n')
const page = pageOf(structure)
expect(page.startsWith('')).toBe(true)
expect(page.indexOf('