* idがない場合や、イベントがない場合は空文字列を該当のプロパティに入れる*/\r
event: function(str) {\r
str = str || "";\r
- var dot = str.indexOf("."),\r
- id = "",\r
- event = "";\r
- if (dot > -1) {\r
+ if (str.indexOf(".") > -1) {\r
/*ドットが見つかった場合、IDとイベントに分けておく*/\r
var ide = str.split(".");\r
- id = ide[0];\r
- event = ide[1];\r
+ /* エラーが起きて、idが空文字列ならば、evtも空文字列。逆も然り*/\r
+ return {\r
+ id: (ide[1] && ide[0]),\r
+ event: (ide[0] && ide[1])\r
+ };\r
} else {\r
- event = str;\r
+ return {\r
+ id: "",\r
+ event: str\r
+ };\r
}\r
- return {\r
- id: id,\r
- event: event\r
- };\r
}\r
} );\r
} );\r
var evt = begin.event();\r
expect(evt.id).toBe("");\r
expect(evt.event).toBe("");\r
+ evt = begin.event("");\r
+ expect(evt.id).toBe("");\r
+ expect(evt.event).toBe("");\r
+ evt = begin.event(".");\r
+ expect(evt.id).toBe("");\r
+ expect(evt.event).toBe("");\r
+\r
+ evt = begin.event("a");\r
+ expect(evt.id).toBe("");\r
+ expect(evt.event).toBe("a");\r
+ evt = begin.event("a.b");\r
+ expect(evt.id).toBe("a");\r
+ expect(evt.event).toBe("b");\r
} );\r
/*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/\r
it("should be this for the value (the valid partion)", function() {\r
-\r
-\r
+ var evt = begin.event("id.event");\r
+ expect(evt.id).toBe("id");\r
+ expect(evt.event).toBe("event");\r
+ evt = begin.event("event");\r
+ expect(evt.id).toBe("");\r
+ expect(evt.event).toBe("event");\r
} );\r
/*無効同値クラスを調べておく (Equivalence partitioning, the following is the invalid partion)*/\r
it("should be this for the value (the invalid partion)", function() {\r
- } );\r
+ evt = begin.event("...");\r
+ expect(evt.id).toBe("");\r
+ expect(evt.event).toBe("");\r
+ evt = begin.event(".event");\r
+ expect(evt.id).toBe("");\r
+ expect(evt.event).toBe("");\r
+ evt = begin.event("id.");\r
+ expect(evt.id).toBe("");\r
+ expect(evt.event).toBe(""); } );\r
} );\r
} );\r
} )\r