@@ -39,6 +39,22 @@ Rectangle {
3939 widgetId: "previewCommentInput"
4040 }
4141
42+ Loader {
43+ id: previewCommentInputLoader
44+ anchors {
45+ left: parent.left
46+ right: parent.right
47+ top: previewCommentInput.bottom
48+ topMargin: units.gu(2)
49+ }
50+
51+ sourceComponent: PreviewCommentInput {
52+ widgetData: widgetDataNewLabels
53+ widgetId: "previewCommentInputLoader"
54+ }
55+ }
56+
57+
4258 SignalSpy {
4359 id: spy
4460 signalName: "triggered"
@@ -81,5 +97,18 @@ Rectangle {
8197 compare(args[2]["comment"], data.inputText);
8298 }
8399 }
100+
101+ function test_singleton() {
102+ var commentTextAreaLoader = findChild(previewCommentInputLoader, "commentTextArea")
103+
104+ commentTextAreaLoader.text = "singleton test text";
105+
106+ // Simulate widget being destroyed and recreated
107+ previewCommentInputLoader.active = false;
108+ previewCommentInputLoader.active = true;
109+
110+ commentTextAreaLoader = findChild(previewCommentInputLoader, "commentTextArea")
111+ tryCompare(commentTextAreaLoader, "text", "singleton test text");
112+ }
84113 }
85114}