summaryrefslogtreecommitdiff
path: root/StoneIsland/plugins/cordova-plugin-sim/tests/tests.js
blob: f962fd5eed33fecc3f29076e17106c7893a7d53c (plain)
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
exports.defineAutoTests = function() {
  describe('SIM Information (window.plugins.sim)', function () {
    it('should exist', function() {
      expect(window.plugins.sim).toBeDefined();
    });

    it('should contain getSimInfo that is a function', function() {
      expect(window.plugins.sim.getSimInfo).toBeDefined();
      expect(typeof window.plugins.sim.getSimInfo).toBe('function');
    });

  });
};

exports.defineManualTests = function(contentEl, createActionButton) {
  var logMessage = function (message, color) {
    var log = document.getElementById('info');
    var logLine = document.createElement('div');
    if (color) {
      logLine.style.color = color;
    }
    logLine.innerHTML = message;
    log.appendChild(logLine);
  };

  var clearLog = function () {
    var log = document.getElementById('info');
    log.innerHTML = '';
  };

  var device_tests = '<h3>Press Dump SIM button to get SIM information</h3>' +
    '<div id="dump_sim"></div>' +
    'Expected result: Status box will get updated with SIM info. (i.e. carrierName, countryCode, etc)';

  contentEl.innerHTML = '<div id="info"></div>' + device_tests;

  createActionButton('Dump SIM', function() {
    clearLog();
    window.plugins.sim.getSimInfo(
      function(result) {
        logMessage(JSON.stringify(result));
      },
      function(error) {
        logMessage(JSON.stringify(error));
      }
    );
  }, 'dump_sim');
};