tests.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. exports.defineAutoTests = function() {
  2. var fail = function (done) {
  3. expect(true).toBe(false);
  4. done();
  5. },
  6. succeed = function (done) {
  7. expect(true).toBe(true);
  8. done();
  9. };
  10. describe('Plugin availability', function () {
  11. it("window.plugins.toast should exist", function() {
  12. expect(window.plugins.toast).toBeDefined();
  13. });
  14. });
  15. describe('API functions', function () {
  16. it("should define show", function() {
  17. expect(window.plugins.toast.show).toBeDefined();
  18. });
  19. it("should define showWithOptions", function() {
  20. expect(window.plugins.toast.showWithOptions).toBeDefined();
  21. });
  22. it("should define optionsBuilder", function() {
  23. expect(window.plugins.toast.optionsBuilder).toBeDefined();
  24. });
  25. it("should define showShortTop", function() {
  26. expect(window.plugins.toast.showShortTop).toBeDefined();
  27. });
  28. it("should define showShortCenter", function() {
  29. expect(window.plugins.toast.showShortCenter).toBeDefined();
  30. });
  31. it("should define showShortBottom", function() {
  32. expect(window.plugins.toast.showShortBottom).toBeDefined();
  33. });
  34. it("should define showLongTop", function() {
  35. expect(window.plugins.toast.showLongTop).toBeDefined();
  36. });
  37. it("should define showLongCenter", function() {
  38. expect(window.plugins.toast.showLongCenter).toBeDefined();
  39. });
  40. it("should define showLongBottom", function() {
  41. expect(window.plugins.toast.showLongBottom).toBeDefined();
  42. });
  43. });
  44. describe('Invalid usage', function () {
  45. it("should fail due to an invalid position", function(done) {
  46. window.plugins.toast.show('hi', 'short', 'nowhere', fail.bind(null, done), succeed.bind(null, done));
  47. });
  48. });
  49. };