import { expect } from "chai"; import WebDAVProvider from "@ff/scene/assets/WebDAVProvider"; const origin = "http://localhost:8000"; /** A PROPFIND response entry, as webdav-server sends it: absolute, percent-encoded href */ function response(path: string, folder: boolean) { const name = decodeURI(path.split("/").filter(part => !!part).pop()); return `${origin}/${path}HTTP/1.1 200 OK` + `Wed, 21 Oct 2026 14:43:22 GMT` + `2026-10-21T14:43:22-02:00` + `${name}` + (folder ? `` : `1404text/html`) + ``; } /** Recursive listing of a folder holding one article */ function listing(folder: string) { const root = encodeURI(folder) + "/"; return `` + response(root, true) + response(root + "articles/", true) + response(root + "articles/new-article-FR.html", false) + ``; } // plain, with a non-ASCII character, with a space: URL encoding changes the last two const folders = [ "scene", "scène", "my scene" ]; describe("WebDAVProvider", function(){ describe("parseListing()", function(){ folders.forEach(folder => { it(`returns paths relative to root folder '${folder}'`, function(){ const provider = new WebDAVProvider(`${origin}/${encodeURI(folder)}/`); const paths = provider.parseListing(listing(folder)).map(info => info.path); expect(paths).to.have.members([ "", "articles/", "articles/new-article-FR.html" ]); }); }); }); });