落地输入合规、探索题库、报告日/时辰刷新、账号头像、OEJTS 量表,并补齐 H5 埋点与 Admin 漏斗;同步 ESS 工件、切至自建 Git、清理 GitHub Actions。 Co-authored-by: Cursor <cursoragent@cursor.com>
67 lines
2.1 KiB
Go
67 lines
2.1 KiB
Go
package scale
|
|
|
|
import (
|
|
"strconv"
|
|
"testing"
|
|
)
|
|
|
|
func TestScoreMajority_communication(t *testing.T) {
|
|
key, label := ScoreMajority(map[string]string{
|
|
"q1": "B", "q2": "B", "q3": "A",
|
|
}, CommunicationLabels(), "平衡探索型")
|
|
if key != "B" || label != "感受连接型" {
|
|
t.Fatalf("got %s %s", key, label)
|
|
}
|
|
}
|
|
|
|
func TestScoreMajority_emotion(t *testing.T) {
|
|
key, label := ScoreMajority(map[string]string{
|
|
"q1": "C", "q2": "C", "q3": "C",
|
|
}, EmotionLabels(), "平衡探索型")
|
|
if key != "C" || label != "行动调节型" {
|
|
t.Fatalf("got %s %s", key, label)
|
|
}
|
|
}
|
|
|
|
func TestScoreJungian_ENFP(t *testing.T) {
|
|
// 8 Qs per dim: EI low→E, SN high→N, TF low→F, JP high→P
|
|
meta := map[string]JungianQuestionMeta{}
|
|
answers := map[string]string{}
|
|
add := func(dim string, ids []string, vals []int) {
|
|
for i, id := range ids {
|
|
meta[id] = JungianQuestionMeta{Dimension: dim}
|
|
answers[id] = strconv.Itoa(vals[i])
|
|
}
|
|
}
|
|
add("EI", []string{"e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8"}, []int{1, 1, 2, 1, 2, 1, 1, 2}) // sum 11 → E
|
|
add("SN", []string{"s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8"}, []int{5, 5, 4, 5, 4, 5, 5, 4}) // sum 37 → N
|
|
add("TF", []string{"t1", "t2", "t3", "t4", "t5", "t6", "t7", "t8"}, []int{1, 2, 1, 2, 1, 1, 2, 1}) // sum 11 → F
|
|
add("JP", []string{"j1", "j2", "j3", "j4", "j5", "j6", "j7", "j8"}, []int{5, 4, 5, 5, 4, 5, 5, 4}) // sum 37 → P
|
|
code, _, pct := ScoreJungian(answers, meta, 8)
|
|
if code != "ENFP" {
|
|
t.Fatalf("code=%s want ENFP", code)
|
|
}
|
|
r := BuildJungianResult(code, pct)
|
|
if r["type_code"] != "ENFP" {
|
|
t.Fatalf("type_code=%v", r["type_code"])
|
|
}
|
|
}
|
|
|
|
func TestScoreMajority_empty(t *testing.T) {
|
|
_, label := ScoreMajority(nil, CommunicationLabels(), "平衡探索型")
|
|
if label != "平衡探索型" {
|
|
t.Fatalf("got %s", label)
|
|
}
|
|
}
|
|
|
|
func TestBuildResult_rich(t *testing.T) {
|
|
r := BuildResult("communication-style", "B", "感受连接型")
|
|
if r["overview"] == nil || r["tips"] == nil || r["scripts"] == nil {
|
|
t.Fatalf("missing rich fields: %#v", r)
|
|
}
|
|
r2 := BuildResult("emotion-pattern", "A", "觉察表达型")
|
|
if r2["growth_plan"] == nil || r2["faq"] == nil {
|
|
t.Fatalf("missing emotion rich fields")
|
|
}
|
|
}
|