PHP Classes

File: tests/js/label-casing.test.js

Recommend this page to a friend!
  Packages of Alberto Arena   Laravel Truss   tests/js/label-casing.test.js   Download  
File: tests/js/label-casing.test.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Laravel Truss
View a diagram of a Laravel application models
Author: By
Last change:
Date: 9 days ago
Size: 1,597 bytes
 

Contents

Class file image Download
import { readFileSync } from 'node:fs'; import { fileURLToPath } from 'node:url'; import { describe, it, expect } from 'vitest'; const css = readFileSync( fileURLToPath(new URL('../../resources/css/truss.css', import.meta.url)), 'utf8' ); // Extract the declaration block for a selector so we can assert on its rules. function rule(selector) { const re = new RegExp( selector.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '\\s*\\{[^}]*\\}' ); return css.match(re)?.[0] ?? ''; } // The toolbar and overlay labels/heads read in sentence case, matching the docs // site, so none of them may force ALL CAPS. The source text is already sentence // case (Filter, Focus, Laravel types, Legend, Fit, Export view), so dropping the // uppercase transform is all it takes. const sentenceCaseSelectors = [ '.truss-field-label', '.truss-zoom button', '.truss-legend-head', '.truss-diff-head', '.truss-popover-head', ]; describe('label casing', () => { it.each(sentenceCaseSelectors)('%s does not force uppercase', (selector) => { const r = rule(selector); expect(r, `no rule found for ${selector}`).not.toBe(''); expect(r).not.toMatch(/text-transform\s*:\s*uppercase/); }); // Diff badges render their status text lowercased ("added"), so they capitalize // to read as "Added" rather than shouting "ADDED". it('diff badges capitalize rather than uppercase', () => { const r = rule('.truss-diff-badge'); expect(r).not.toBe(''); expect(r).not.toMatch(/text-transform\s*:\s*uppercase/); expect(r).toMatch(/text-transform\s*:\s*capitalize/); }); });