brand.test.ts 1.1 KB

123456789101112131415161718192021222324252627282930
  1. import { createHash } from 'node:crypto'
  2. import { readFile } from 'node:fs/promises'
  3. import { resolve } from 'node:path'
  4. import { describe, expect, it } from 'vitest'
  5. function pngSize(data: Buffer): { width: number; height: number } {
  6. expect(data.subarray(1, 4).toString()).toBe('PNG')
  7. return { width: data.readUInt32BE(16), height: data.readUInt32BE(20) }
  8. }
  9. describe('brand assets', () => {
  10. it('keeps the mobile AppIcon as the exact brand source', async () => {
  11. const data = await readFile(resolve('public/brand/AppIcon-1024.png'))
  12. expect(createHash('sha256').update(data).digest('hex')).toBe(
  13. 'e19c03450c62238aeb70ad735f612d4bfc61964e1473b1be4bdca1d9230bd086',
  14. )
  15. expect(pngSize(data)).toEqual({ width: 1024, height: 1024 })
  16. })
  17. it.each([
  18. ['favicon-32.png', 32],
  19. ['logo-64.png', 64],
  20. ['apple-touch-icon.png', 180],
  21. ['icon-192.png', 192],
  22. ['icon-512.png', 512],
  23. ])('generates %s without changing aspect ratio', async (name, size) => {
  24. const data = await readFile(resolve('public/icons', name))
  25. expect(pngSize(data)).toEqual({ width: size, height: size })
  26. })
  27. })