mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-12-04 05:43:27 +01:00
Step 1 of #710. Goldens pin what a run prints before the entry code moves, and the renames follow two naming rules added to RFC-001. No behavior change.
50 lines
1.3 KiB
Go
50 lines
1.3 KiB
Go
package browser
|
|
|
|
import (
|
|
"sort"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
var platformOf = map[string]func(Browser) Platform{
|
|
"darwin": func(browser Browser) Platform { return browser.Darwin },
|
|
"linux": func(browser Browser) Platform { return browser.Linux },
|
|
"windows": func(browser Browser) Platform { return browser.Windows },
|
|
}
|
|
|
|
func namesOn(platform func(Browser) Platform) []string {
|
|
var names []string
|
|
for _, browser := range browsers {
|
|
if len(platform(browser).UserDataDirPaths) > 0 {
|
|
names = append(names, browser.Name)
|
|
}
|
|
}
|
|
return names
|
|
}
|
|
|
|
func TestSupported_ListsThisOSRowsInTableOrder(t *testing.T) {
|
|
var names []string
|
|
for _, browser := range Supported() {
|
|
names = append(names, browser.Name)
|
|
}
|
|
assert.Equal(t, namesOn(Browser.Platform), names)
|
|
}
|
|
|
|
func TestLookup_FindsEveryRowWhateverTheOS(t *testing.T) {
|
|
for _, want := range browsers {
|
|
got, ok := Lookup(want.Name)
|
|
require.True(t, ok, want.Name)
|
|
assert.Equal(t, want, got)
|
|
}
|
|
_, ok := Lookup("netscape")
|
|
assert.False(t, ok)
|
|
}
|
|
|
|
func TestNames_AreSupportedSorted(t *testing.T) {
|
|
names := Names()
|
|
assert.True(t, sort.StringsAreSorted(names), "the -b help has always listed them sorted")
|
|
assert.ElementsMatch(t, namesOn(Browser.Platform), names)
|
|
}
|