tests.js 1.71 KB
Newer Older
李晓兵's avatar
李晓兵 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
exports.defineAutoTests = function() {

  var fail = function (done) {
    expect(true).toBe(false);
    done();
  },
  succeed = function (done) {
    expect(true).toBe(true);
    done();
  };

  describe('Plugin availability', function () {
    it("window.plugins.toast should exist", function() {
      expect(window.plugins.toast).toBeDefined();
    });
  });

  describe('API functions', function () {
    it("should define show", function() {
      expect(window.plugins.toast.show).toBeDefined();
    });

    it("should define showWithOptions", function() {
      expect(window.plugins.toast.showWithOptions).toBeDefined();
    });

    it("should define optionsBuilder", function() {
      expect(window.plugins.toast.optionsBuilder).toBeDefined();
    });

    it("should define showShortTop", function() {
      expect(window.plugins.toast.showShortTop).toBeDefined();
    });

    it("should define showShortCenter", function() {
      expect(window.plugins.toast.showShortCenter).toBeDefined();
    });

    it("should define showShortBottom", function() {
      expect(window.plugins.toast.showShortBottom).toBeDefined();
    });

    it("should define showLongTop", function() {
      expect(window.plugins.toast.showLongTop).toBeDefined();
    });

    it("should define showLongCenter", function() {
      expect(window.plugins.toast.showLongCenter).toBeDefined();
    });

    it("should define showLongBottom", function() {
      expect(window.plugins.toast.showLongBottom).toBeDefined();
    });
  });

  describe('Invalid usage', function () {
    it("should fail due to an invalid position", function(done) {
      window.plugins.toast.show('hi', 'short', 'nowhere', fail.bind(null, done), succeed.bind(null, done));
    });
  });
};