package extsvc

import "testing"

// Club Log answers a refused login with its ordinary web page. The operator must
// get a sentence they can act on, not four kilobytes of markup — that was the
// first thing reported once the test started working at all.
func TestLooksLikeHTML(t *testing.T) {
	cases := []struct {
		body string
		want bool
	}{
		{"<!DOCTYPE html>\n<html lang='en'>…403 - Access denied…", true},
		{"  <html><head><title>403</title></head></html>", true},
		{"<HTML>", true},
		{"Invalid credentials", false},
		{"", false},
		// An ADIF answer must never be mistaken for a page.
		{"<eoh>\n<call:5>F4BPO <band:3>20m <eor>", false},
	}
	for _, c := range cases {
		if got := looksLikeHTML(c.body); got != c.want {
			t.Errorf("looksLikeHTML(%.40q) = %v, want %v", c.body, got, c.want)
		}
	}
}
