package wikipress

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestGetFileExtension(t *testing.T) {
	tts := []struct {
		name         string
		file         File
		expExtension string
	}{
		{
			name: "markedown file",
			file: File{
				Name: "home.md",
			},
			expExtension: "md",
		},
		{
			name: "multible dot",
			file: File{
				Name: "foo.br.jpg",
			},
			expExtension: "jpg",
		},
		{
			name: "with folder",
			file: File{
				Name: "foo/bar/test.txt",
			},
			expExtension: "txt",
		},
		{
			name: "no dot",
			file: File{
				Name: "something",
			},
			expExtension: "",
		},
	}

	for _, tt := range tts {
		t.Run(tt.name, func(t *testing.T) {
			extension := tt.file.GetExtension()
			assert.Equal(t, tt.expExtension, extension, "should be right extension")
		})
	}
}
