summaryrefslogtreecommitdiff
path: root/node_modules/entities/src/escape.spec.ts
blob: 582af1a115b1ae8d43fd851f54e8271a8a4cb739 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { describe, it, expect } from "vitest";
import * as entities from "./index.js";

describe("escape HTML", () => {
    it("should escape HTML attribute values", () =>
        expect(entities.escapeAttribute('<a " attr > & value \u00A0!')).toBe(
            "<a &quot; attr > &amp; value &nbsp;!",
        ));

    it("should escape HTML text", () =>
        expect(entities.escapeText('<a " text > & value \u00A0!')).toBe(
            '&lt;a " text &gt; &amp; value &nbsp;!',
        ));
});