1 import Quick
2 import Nimble
3 
4 @testable import EXDevMenuInterface
5 
6 class DevMenuActionTest: QuickSpec {
specnull7   override func spec() {
8     it("Action should be serializable") {
9       let action = DevMenuAction(withId: "action-1", {})
10       action.isAvailable = { true }
11       action.isEnabled = { true }
12       action.label = { "action-1-label" }
13       action.detail = { "action-1-details" }
14       action.glyphName = { "action-1-glyphname" }
15       action.registerKeyCommand(input: "r", modifiers: .command)
16 
17       let serilizedData = action.serialize()
18 
19       expect(serilizedData["type"] as? Int).to(equal(ItemType.action.rawValue))
20       expect(serilizedData["actionId"] as? String).to(equal("action-1"))
21       expect(serilizedData["isAvailable"] as? Bool).to(beTrue())
22       expect(serilizedData["isEnabled"] as? Bool).to(beTrue())
23       expect(serilizedData["label"] as? String).to(equal("action-1-label"))
24       expect(serilizedData["detail"] as? String).to(equal("action-1-details"))
25       expect(serilizedData["glyphName"] as? String).to(equal("action-1-glyphname"))
26 
27       let keyCommand = serilizedData["keyCommand"] as! [String: Any]
28 
29       expect(keyCommand["input"] as? String).to(equal("r"))
30       expect(keyCommand["modifiers"] as? Int).to(equal(1 << 2))
31     }
32 
33     it("Action callable should be contain passed action") {
34       var wasCalled = false
35       let action = DevMenuAction(withId: "action-1", { wasCalled = true })
36 
37       action.callable.call()
38 
39       expect(wasCalled).to(beTrue())
40     }
41   }
42 }
43