Added a test for state machines being assigned when at least one exists but is not specified and a default one is not provided

This commit is contained in:
Zachary Duncan
2022-07-06 17:03:34 -04:00
committed by Zachary Duncan
parent db4d7e1c9d
commit 2819f1fd84

View File

@@ -22,4 +22,24 @@ class RiveStateMachineTest: XCTestCase {
XCTAssertEqual(model.animation, nil)
XCTAssertEqual(model.stateMachine!.name(), "DefaultSM")
}
// Checks that in the absence of both a default and specified StateMachine
func testFallbackDefaultStateMachine() throws {
let file = try RiveFile(testfileName: "multiple_state_machines")
let model = RiveModel(riveFile: file)
// The RiveViewModel is responsible for configuring the model properly
_ = RiveViewModel(model)
XCTAssertEqual(model.artboard.stateMachineCount(), 4)
XCTAssertEqual(model.artboard.animationCount(), 1)
// There is an Animation in the file but the RiveViewModel
// prioritizes StateMachines
XCTAssertEqual(model.animation, nil)
// Some StateMachine was assigned. If there's at least one in
// the file it will be chosen by index 0
XCTAssertNotEqual(model.stateMachine, nil)
}
}