A developer has created a new Sling Model named Thud. The developer wants to create a unit test for this Sling Model.
Thud
What must be changed for the unit test to successfully test the getName method of the Thud Sling Model?
getName
The mock context must contain a resource at /content/foo with the property value that the Sling Model injects for getName(). ctx.load().json() imports the JSON fixture into the mock resource hierarchy; merely setting the current resource path does not create that resource or its data. The Sling Mocks documentation identifies context.load().json(...) as the mechanism for loading test content and supports manually registering Sling Models with addModelsForClasses(...).
/content/foo
getName()
ctx.load().json()
context.load().json(...)
addModelsForClasses(...)
Community Discussion