Files
Jonathan Adeline 38ccc54c2e chore: update Iconoir to 7.12.2 (#7012)
* chore(deps): update Iconoir to 7.12.2

* test: update grid visibility selector for Iconoir 7

* fix: restore open and slashed eye icons

* docs: document Iconoir 7 plugin changes
2026-12-04 15:36:56 +04:00

41 lines
1.4 KiB
JavaScript

import { readFileSync } from 'node:fs'
import { createRequire } from 'node:module'
import { describe, expect, test } from 'vitest'
import {
DEFAULT_TEMPLATE_ICON,
TEMPLATE_ICONS,
getTemplateIconClass,
} from '@baserow/modules/core/utils/templateIcons'
describe('templateIcons', () => {
test('only lists icons the backend accepts', () => {
// Mirrors `USER_TEMPLATE_ICON_REGEX` and `USER_TEMPLATE_ICON_MAX_LENGTH`.
for (const icon of TEMPLATE_ICONS) {
expect(icon).toMatch(/^iconoir-[a-z0-9]+(-[a-z0-9]+)*$/)
expect(icon.length).toBeLessThanOrEqual(32)
}
expect(new Set(TEMPLATE_ICONS).size).toBe(TEMPLATE_ICONS.length)
expect(TEMPLATE_ICONS).toContain(DEFAULT_TEMPLATE_ICON)
})
test('only lists icons available in Iconoir', () => {
const require = createRequire(import.meta.url)
const css = readFileSync(require.resolve('iconoir/css/iconoir.css'), 'utf8')
for (const icon of TEMPLATE_ICONS) {
expect(css.includes(`.${icon}::before{`)).toBe(true)
}
})
test.each([
['iconoir-bookmark-empty', 'iconoir-bookmark'],
['iconoir-eye-empty', 'baserow-icon-eye'],
['iconoir-eye-off', 'baserow-icon-eye-off'],
['iconoir-shop', 'iconoir-shop-four-tiles-window'],
['iconoir-table', 'iconoir-table'],
['', DEFAULT_TEMPLATE_ICON],
])('resolves %j to %s', (storedIcon, expectedIcon) => {
expect(getTemplateIconClass(storedIcon)).toBe(expectedIcon)
})
})