PHP 8.2.30
Preview: layout-template.spec.ts Size: 2.04 KB
/home/byroehnu/easepaybiz.easetack.com/node_modules/adminjs/src/frontend/layout-template.spec.ts

import { expect } from 'chai'

import layoutTemplate from './layout-template.js'
import AdminJS from '../adminjs.js'
import { BrandingOptions } from '../adminjs-options.interface.js'

describe('layoutTemplate', function () {
  context('AdminJS with branding options set as a function', function () {
    const companyName = 'Dynamic Company'
    let html: string

    beforeEach(async function () {
      const adminJs = new AdminJS({
        branding: async () => ({ companyName }),
      })

      html = await layoutTemplate(adminJs, undefined, '/')
    })

    it('renders default company name', function () {
      expect(html).to.contain(companyName)
    })

    it('links to global bundle', async function () {
      expect(html).to.contain('global.bundle.js')
    })
  })

  describe('AdminJS with branding options given', function () {
    const branding = {
      withMadeWithLove: false,
      companyName: 'Other name',
      favicon: '/someImage.png',
    } as BrandingOptions
    let html: string

    beforeEach(async function () {
      const adminJs = new AdminJS({ branding })

      html = await layoutTemplate(adminJs, undefined, '/')
    })

    it('renders company name', function () {
      expect(html).to.contain(branding.companyName)
    })

    it('renders favicon', function () {
      expect(html).to.contain(
        `<link rel="shortcut icon" type="image/png" href="${branding.favicon}" />`,
      )
    })
  })

  context('custom styles and scripts were defined in AdminJS options', function () {
    let html: string
    const scriptUrl = 'http://somescript.com'
    const styleUrl = 'http://somestyle.com'

    beforeEach(async function () {
      const adminJs = new AdminJS({
        assets: {
          styles: [styleUrl],
          scripts: [scriptUrl],
        },
      })

      html = await layoutTemplate(adminJs, undefined, '/')
    })

    it('adds styles to the head section', function () {
      expect(html).to.contain(styleUrl)
    })

    it('adds scripts to the body', function () {
      expect(html).to.contain(scriptUrl)
    })
  })
})

Directory Contents

Dirs: 7 × Files: 8

Name Size Perms Modified Actions
assets DIR
- drwxr-xr-x 2026-03-14 01:49:11
Edit Download
- drwxr-xr-x 2026-03-14 01:49:11
Edit Download
hoc DIR
- drwxr-xr-x 2026-03-14 01:49:11
Edit Download
hooks DIR
- drwxr-xr-x 2026-03-14 01:49:11
Edit Download
- drwxr-xr-x 2026-03-14 01:49:11
Edit Download
store DIR
- drwxr-xr-x 2026-03-14 01:49:11
Edit Download
utils DIR
- drwxr-xr-x 2026-03-14 01:49:11
Edit Download
127 B lr--r--r-- 2026-03-14 01:49:11
Edit Download
2.41 KB lrw-r--r-- 2026-03-05 00:20:26
Edit Download
1.07 KB lrw-r--r-- 2026-03-05 00:20:25
Edit Download
206 B lrw-r--r-- 2026-03-05 00:20:27
Edit Download
2.04 KB lrw-r--r-- 2026-03-05 00:20:27
Edit Download
4.45 KB lrw-r--r-- 2026-03-05 00:20:28
Edit Download
442 B lrw-r--r-- 2026-03-05 00:20:28
Edit Download
4.84 KB lrw-r--r-- 2026-03-05 00:20:28
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).