actionSheet.test.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. describe("actionsheet", function () {
  2. it("should display the action sheet from an html string",function(done){
  3. var sheet=$(document.body).actionsheet('<a >Back</a><a onclick="alert(\'hi\');" >Show Alert 3</a><a onclick="alert(\'goodbye\');">Show Alert 4</a>');
  4. $("#af_actionsheet").css("display").should.eql("block");
  5. setTimeout(function(){
  6. $("#af_actionsheet a").length.should.eql(4);
  7. sheet.hideSheet();
  8. setTimeout(function(){
  9. $("#af_actionsheet").length.should.eql(0);
  10. done();
  11. },400);
  12. },400);
  13. });
  14. it("should display the action sheet from an array of objects",function(done){
  15. var sheet=$(document.body).actionsheet(
  16. [{
  17. text: 'back',
  18. cssClasses: 'red',
  19. handler: function () {
  20. $.ui.goBack();
  21. }
  22. }, {
  23. text: 'show alert 6',
  24. cssClasses: '',
  25. handler: function () {
  26. alert("goodbye");
  27. }
  28. }]);
  29. $("#af_actionsheet").css("display").should.eql("block");
  30. setTimeout(function(){
  31. $("#af_actionsheet a").length.should.eql(3);
  32. sheet.hideSheet();
  33. setTimeout(function(){
  34. $("#af_actionsheet").length.should.eql(0);
  35. done();
  36. },400);
  37. },400);
  38. });
  39. it("should dismiss the action sheet from an item click",function(done){
  40. var sheet=$(document.body).actionsheet(
  41. [{
  42. text: 'back',
  43. cssClasses: 'red',
  44. handler: function () {
  45. done();
  46. }
  47. }, {
  48. text: 'show alert 6',
  49. cssClasses: ''
  50. }]);
  51. $("#af_actionsheet").css("display").should.eql("block");
  52. setTimeout(function(){
  53. $("#af_action_mask").trigger("click");
  54. $("#af_actionsheet a").eq(0).trigger("click");
  55. //trigger a click on the mask
  56. },400);
  57. });
  58. });