Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Ce dépôt a été archivé le 2022-05-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
nyaa-pantsu/util/filelist/filelist_test.go
Ramon Dantas 86447b853c Add tree-view file list (Done) (#724)
* Add tree-view file list

* Add TotalSize field to folders

* Remove bootstrap/jquery related code

* Add icons to filelist, some CSS formatting

Moved a few styles from the format string for the tree view, to CSS
(where possible). Make icons look consistent under all themes.

* Make filelist hideable again, show it when JS is disabled
2017-05-25 00:13:56 +10:00

49 lignes
956 o
Go

package filelist;
import (
"testing"
"html/template"
"github.com/NyaaPantsu/nyaa/model"
)
func makeDummyFile(path ...string) (file model.File) {
file.SetPath(path)
return
}
func dashes(n uint) (out string) {
var i uint
for i = 0; i < n; i++ {
out += "-"
}
return
}
func TestFilelist(T *testing.T) {
files := []model.File{
makeDummyFile("A", "B", "C.txt"),
makeDummyFile("A", "C", "C.txt"),
makeDummyFile("B.txt"),
}
expected := "A\n"+
"-B\n"+
"--C.txt\n"+
"-C\n"+
"--C.txt\n"+
"B.txt\n"
filelist := FileListToFolder(files)
out, err := filelist.MakeFolderTreeView("{{dashes .NestLevel}}{{.FolderName}}\n", "{{dashes .NestLevel}}{{.Filename}}\n", map[string]interface{}{
"dashes": dashes,
}, nil)
if err != nil {
T.Fatalf("%v", err)
return
}
if out != template.HTML(expected) {
T.Fatalf("Error: expected %s, got %s", expected, out)
return
}
}