Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. "use strict";
  2. const test = require('tape')
  3. const android = require('..')
  4. test('get specific version by API level', (t) => {
  5. t.plan(1)
  6. t.equal(android.get(24).name, "Nougat")
  7. })
  8. test('getAll versions by API level', (t) => {
  9. t.plan(1)
  10. t.equal(android.getAll(24)[0].name, "Nougat")
  11. })
  12. test('get specific version by predicate', (t) => {
  13. t.plan(2)
  14. let actual = android.get((version) => {
  15. return version.name.indexOf("on") !== -1
  16. })
  17. t.equal(actual.name, "Donut")
  18. actual = android.get((version) => {
  19. return version.ndk > 5 && version.api < 15
  20. })
  21. t.equal(actual.versionCode, "HONEYCOMB_MR1")
  22. })
  23. test('getAll versions by predicate', (t) => {
  24. t.plan(3)
  25. let actual = android.getAll((version) => {
  26. return version.name.indexOf("on") !== -1
  27. }).map((version) => version.name)
  28. t.deepEqual(actual, ["Donut", "Honeycomb", "Honeycomb", "Honeycomb"])
  29. actual = android.getAll((version) => {
  30. return version.ndk > 5 && version.api < 15
  31. }).map((version) => version.versionCode)
  32. t.deepEqual(actual, ["HONEYCOMB_MR1", "HONEYCOMB_MR2", "ICE_CREAM_SANDWICH"])
  33. actual = android.getAll((version) => {
  34. return version.api > 22
  35. }).map((version) => version.versionCode)
  36. t.deepEqual(actual, ["M", "N", "N_MR1", "O", "O_MR1", "P", "Q"])
  37. })
  38. test('get version by semantic version', (t) => {
  39. t.plan(4)
  40. t.equal(android.get("6.0").versionCode, android.M.versionCode)
  41. t.equal(android.get("6.0.0").versionCode, android.M.versionCode)
  42. t.equal(android.get("2.3").versionCode, android.GINGERBREAD.versionCode)
  43. t.equal(android.get("2.3.3").versionCode, android.GINGERBREAD_MR1.versionCode)
  44. })
  45. test('support major version only', (t) => {
  46. t.plan(2)
  47. t.equal(android.get("9.0").versionCode, android.P.versionCode)
  48. t.equal(android.get("9.0.0").versionCode, android.P.versionCode)
  49. })
  50. test('support version ranges', (t) => {
  51. t.plan(7)
  52. let tests = [ "4.4", "4.4.0", "4.4.1", "4.4.2", "4.4.3", "4.4.4" ]
  53. tests.forEach((versionCode) => {
  54. t.equal(android.get(versionCode).versionCode, android.KITKAT.versionCode)
  55. })
  56. t.equal(android.get("4.4.5"), null)
  57. })
  58. test('support x-ranges', (t) => {
  59. t.plan(12)
  60. let tests = [
  61. "4.1", "4.1.0", "4.1.1", "4.1.2", "4.1.3", "4.1.4",
  62. "4.1.5", "4.1.6", "4.1.7", "4.1.8", "4.1.9", "4.1.10"
  63. ]
  64. tests.forEach((versionCode) => {
  65. t.equal(android.get(versionCode).versionCode, android.JELLY_BEAN.versionCode)
  66. })
  67. })
  68. test('access version codes object', (t) => {
  69. t.plan(1)
  70. t.ok(android.VERSIONS)
  71. })
  72. test('access specific versions directly', (t) => {
  73. t.plan(29)
  74. t.ok(android.BASE)
  75. t.ok(android.BASE_1_1)
  76. t.ok(android.CUPCAKE)
  77. t.ok(android.DONUT)
  78. t.ok(android.ECLAIR)
  79. t.ok(android.ECLAIR_0_1)
  80. t.ok(android.ECLAIR_MR1)
  81. t.ok(android.FROYO)
  82. t.ok(android.GINGERBREAD)
  83. t.ok(android.GINGERBREAD_MR1)
  84. t.ok(android.HONEYCOMB)
  85. t.ok(android.HONEYCOMB_MR1)
  86. t.ok(android.HONEYCOMB_MR2)
  87. t.ok(android.ICE_CREAM_SANDWICH)
  88. t.ok(android.ICE_CREAM_SANDWICH_MR1)
  89. t.ok(android.JELLY_BEAN)
  90. t.ok(android.JELLY_BEAN_MR1)
  91. t.ok(android.JELLY_BEAN_MR2)
  92. t.ok(android.KITKAT)
  93. t.ok(android.KITKAT_WATCH)
  94. t.ok(android.LOLLIPOP)
  95. t.ok(android.LOLLIPOP_MR1)
  96. t.ok(android.M)
  97. t.ok(android.N)
  98. t.ok(android.N_MR1)
  99. t.ok(android.O)
  100. t.ok(android.O_MR1)
  101. t.ok(android.P)
  102. t.ok(android.Q)
  103. })