android.spec.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. var android = require("../lib/android")();
  2. describe("android functions", function() {
  3. it("exists", function() {
  4. expect(android).not.toBeNull();
  5. });
  6. it("generates group items", function() {
  7. var config = {
  8. type: "group",
  9. title: "test group",
  10. items: [
  11. { type: "textfield", key: "child 1" },
  12. { type: "textfield", key: "child 2" }
  13. ]
  14. };
  15. var item = android.mapConfig(config);
  16. console.log(item);
  17. expect(item.tagname).toEqual('PreferenceCategory');
  18. expect(item.children).not.toBeNull();
  19. });
  20. it("maps a texfield control", function() {
  21. var config = {
  22. type: "textfield",
  23. default: "test_value",
  24. key: "test_key"
  25. };
  26. var element = android.mapConfig(config);
  27. expect(element.tagname).toEqual('EditTextPreference');
  28. expect(element.atts).not.toBeNull();
  29. });
  30. it("builds the item array", function() {
  31. var configs = [{
  32. type: "group",
  33. title: "test group",
  34. items: [
  35. { type: "textfield", key: "child 1", title: "child 1" },
  36. { type: "textfield", key: "child 2", title: "child 2" }
  37. ]
  38. }];
  39. var prefsDocuments = android.buildSettings(configs);
  40. console.log(prefsDocuments);
  41. expect(prefsDocuments.preferencesDocument).not.toBeNull();
  42. expect(prefsDocuments.preferencesStringDocument).not.toBeNull();
  43. });
  44. it ("extended radio play", function () {
  45. var configs = [
  46. {
  47. "type":"group",
  48. "title":"Measurement Units",
  49. "key":"measurement_units",
  50. "description":"Define which measurement unit is prefered",
  51. "items":[
  52. {
  53. "type":"radio",
  54. "items":[
  55. {
  56. "value":"kilometers_litres",
  57. "title":"Use kilometers / litres"
  58. },
  59. {
  60. "value":"miles_gallons",
  61. "title":"Use miles / gallons"
  62. }
  63. ],
  64. "default":"kilometers_litres",
  65. "title":"Measurement unit",
  66. "key":"measurement_unit",
  67. "name":"measurementunit"
  68. }
  69. ]
  70. }
  71. ];
  72. var prefsDocuments = android.buildSettings(configs);
  73. console.log(prefsDocuments);
  74. expect(prefsDocuments.preferencesDocument).not.toBeNull();
  75. expect(prefsDocuments.preferencesStringDocument).not.toBeNull();
  76. });
  77. });