extends "res://addons/gut/test.gd"

const TagExtractor = preload("res://scripts/text/tag_extractor.gd")


func test_fact_extracted_and_stripped():
	var r := TagExtractor.extract("A muddy road. [FACT: the eastern bridge is out]")
	assert_eq(r["facts"], ["the eastern bridge is out"])
	assert_eq(r["clean_text"], "A muddy road.")


func test_positive_and_negative_disposition():
	assert_eq(TagExtractor.extract("\"Aye.\" [ADJUST_DISPOSITION: +5]")["dispositions"], [5])
	assert_eq(TagExtractor.extract("[ADJUST_DISPOSITION: -10]")["dispositions"], [-10])


func test_move_parsed_with_args():
	var r := TagExtractor.extract("[MOVE: offer_quest(14)]")
	assert_eq(r["moves"][0]["name"], "offer_quest")
	assert_eq(r["moves"][0]["args"], ["14"])


func test_move_with_no_args():
	var r := TagExtractor.extract("[MOVE: refuse()]")
	assert_eq(r["moves"][0]["name"], "refuse")
	assert_eq(r["moves"][0]["args"], [])


func test_multiple_facts_collected():
	var r := TagExtractor.extract("Hi [FACT: a] mid [FACT: b] end")
	assert_eq(r["facts"], ["a", "b"])
	assert_eq(r["clean_text"], "Hi mid end")


func test_no_tags_is_clean_passthrough():
	var r := TagExtractor.extract("no tags here")
	assert_eq(r["facts"], [])
	assert_eq(r["dispositions"], [])
	assert_eq(r["moves"], [])
	assert_eq(r["clean_text"], "no tags here")
