diff --git a/playground.nix b/playground.nix index b0ac5ca..8be94d8 100644 --- a/playground.nix +++ b/playground.nix @@ -11,7 +11,7 @@ pkgs.buildNpmPackage { src = ./playground; - npmDepsHash = "sha256-gSP3f9loTPkeYK3l0Q1d28QXhujErE19k92flsh7EzA="; + npmDepsHash = "sha256-+Nyy05KFyLF2T9LtjgJ+KmrnICTXi1ylP4GFNbe8C64="; nativeBuildInputs = [ pkgs.wasm-bindgen-cli diff --git a/playground/package-lock.json b/playground/package-lock.json index 8ee5cb9..19373ae 100644 --- a/playground/package-lock.json +++ b/playground/package-lock.json @@ -897,9 +897,9 @@ "license": "MIT" }, "node_modules/nanoid": { - "version": "3.3.11", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", - "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", + "version": "3.3.19", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.19.tgz", + "integrity": "sha512-Y2tUNy4ouw6tq5oDSKeQYGOyhkUBhNOcGV/02KC+6kd9eDGqdZd++mjMiIDilrBYvjEnCYvVtsuHCuP+okSfug==", "dev": true, "funding": [ { diff --git a/playground/tests/dependencies/nanoid.test.mjs b/playground/tests/dependencies/nanoid.test.mjs new file mode 100644 index 0000000..fa8715e --- /dev/null +++ b/playground/tests/dependencies/nanoid.test.mjs @@ -0,0 +1,20 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import { nanoid } from 'nanoid'; +import postcss from 'postcss'; + +test('PostCSS Input IDs remain nonempty and distinct for anonymous stylesheets', () => { + const first = postcss.parse('.editor { color: red }').source.input; + const second = postcss.parse('.editor { color: blue }').source.input; + assert.match(first.id, /^$/); + assert.notEqual(first.id, second.id); + assert.equal(first.css, '.editor { color: red }'); +}); + +test('generated stylesheet identifiers preserve the requested size and URL-safe alphabet', () => { + for (const size of [0, 6, 21, 64]) { + const id = nanoid(size); + assert.equal(id.length, size); + assert.match(id, /^[A-Za-z0-9_-]*$/); + } +});