func TestLoadContentCorrectContentForData(t *testing.T) {
	dirPath := test.GetTestPath()
	pathToFolder := filepath.Join(dirPath, "foo4")

	test.CreateTestDirectory(pathToFolder)
	test.CreateTestFile(filepath.Join(pathToFolder, "foo1.md"), test.ContentData)

	files := LoadContentData(pathToFolder)

	if len(files) != 1 {
		t.Error("expected 1 files but were : " + fmt.Sprintf("%v", len(files)))
	}

	file := files[0]

	test.TestValues(t, test.ContentDataTitle, file.Title, "title not correctly loaded")

	if file.Date.Unix() != 1427236080 {
		t.Error("date not correctly loaded")
	}
	if len(file.Categories) != len(test.ContentDataCategories) {
		t.Error("category not correctly loaded")
	}
	if file.Categories[0] != test.ContentDataCategories[0] || file.Categories[1] != test.ContentDataCategories[1] {
		t.Error("category content not correctly loaded")
	}

	test.TestValues(t, test.ContentDataContent, file.Content, "content not correctly loaded")
}
Exemple #2
0
func TestGenerateSideBarTestLinksAreSorted(t *testing.T) {
	data := []input.ContentData{testContentData3}
	sideBarContent := GenerateSidebar(testConfigData, data, false)
	expected := "<a href=\"../index.html\">Index</a></br>\n</br>\n<a href=\"../categories/sdf.html\">sdf</a></br>\n<a href=\"../categories/tfsdf.html\">tfsdf</a>"

	test.TestValues(t, expected, sideBarContent, "incorrect generated content")
}
Exemple #3
0
func TestGenerateSideBarForIndexPage(t *testing.T) {
	testConfigData2 := input.ConfigData{IndexName: "Index33"}
	data := []input.ContentData{testContentData3}
	sideBarContent := GenerateSidebar(testConfigData2, data, true)
	expected := "<a href=\"index.html\">Index33</a></br>\n</br>\n<a href=\"categories/sdf.html\">sdf</a></br>\n<a href=\"categories/tfsdf.html\">tfsdf</a>"

	test.TestValues(t, expected, sideBarContent, "incorrect generated content")
}
Exemple #4
0
func TestCreateIndex(t *testing.T) {
	outputDirectory, configData, elements := setupTestEnvironment("1")

	CreateIndexPage(outputDirectory, configData, elements, test.BaseHtmlContent)
	expected := "Index ||| <p>foo</p>\n ||| <h2>Index</h2>\n<a href=\"content/old-pages.html\">(2015-03-24) Old Pages</a></br>\n ||| <a href=\"index.html\">Index</a></br>\n</br>\n<a href=\"categories/x1.html\">X1</a></br>\n<a href=\"categories/x2.html\">X2</a> ||| <p>© foo</p>\n"

	filePath := filepath.Join(outputDirectory, "index.html")
	result := test.GetTestFileContent(filePath)

	test.TestValues(t, expected, result, "incorrect page generated")
}
Exemple #5
0
func TestCreateContent(t *testing.T) {
	outputDirectory, configData, elements := setupTestEnvironment("3")
	contentPath := filepath.Join(outputDirectory, "content")
	test.CreateTestDirectory(contentPath)
	content := elements[0]

	CreateContentPage(outputDirectory, configData, content, elements, test.BaseHtmlContent)
	expected := "Old Pages ||| <p>foo</p>\n ||| <p>2015-03-24 22:28</p></br>\n<h2>Old Pages</h2>\n<p>Old unsupported pages :</p>\n ||| <a href=\"../index.html\">Index</a></br>\n</br>\n<a href=\"../categories/x1.html\">X1</a></br>\n<a href=\"../categories/x2.html\">X2</a> ||| <p>© foo</p>\n"

	filePath := filepath.Join(contentPath, slug.GenerateSlug(test.ContentDataTitle)+".html")
	result := test.GetTestFileContent(filePath)

	test.TestValues(t, expected, result, "incorrect page generated")
}
Exemple #6
0
func TestCreateCategory(t *testing.T) {
	outputDirectory, configData, elements := setupTestEnvironment("2")
	category := test.ContentDataCategories[0]
	categoryPath := filepath.Join(outputDirectory, "categories")
	test.CreateTestDirectory(categoryPath)

	CreateCategoryPage(outputDirectory, configData, category, elements, test.BaseHtmlContent)
	expected := "X1 ||| <p>foo</p>\n ||| <h2>X1</h2>\n<a href=\"../content/old-pages.html\">(2015-03-24) Old Pages</a></br>\n ||| <a href=\"../index.html\">Index</a></br>\n</br>\n<a href=\"../categories/x1.html\">X1</a></br>\n<a href=\"../categories/x2.html\">X2</a> ||| <p>© foo</p>\n"

	filePath := filepath.Join(categoryPath, slug.GenerateSlug(category)+".html")
	result := test.GetTestFileContent(filePath)

	test.TestValues(t, expected, result, "incorrect page generated")
}