ios.spec.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. var fs = require("../lib/filesystem")(require("q"), require("fs"));
  2. var ios = require("../lib/ios")(fs, require("plist"));
  3. describe("ios functions", function() {
  4. it("exists", function() {
  5. expect(ios).not.toBeNull();
  6. });
  7. it("maps a texfield control", function() {
  8. var config = {
  9. type: "textfield",
  10. default: "test_value",
  11. key: "test_key",
  12. keyboard: "email"
  13. };
  14. var element = ios.mapConfig(config);
  15. expect(element.Key).toEqual(config.key);
  16. expect(element.DefaultValue).toEqual(config.default);
  17. expect(element.KeyboardType).toEqual("EmailAddress");
  18. });
  19. it("builds array of ios preference items", function() {
  20. var configs = [{
  21. type: "textfield",
  22. key: "test_key_1"
  23. },{
  24. type: "textfield",
  25. key: "test_key_1"
  26. }];
  27. var items = ios.buildItems(configs);
  28. expect(items.length).toEqual(2);
  29. });
  30. it("flattens group items", function() {
  31. var configs = [{
  32. type: "group",
  33. items: [
  34. { type: "textfield", key: "child 1" },
  35. { type: "textfield", key: "child 2" }
  36. ]
  37. }];
  38. var items = ios.buildItems(configs);
  39. expect(items.length).toEqual(3);
  40. });
  41. });