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

index.test.js 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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", "R"])
  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('matches incomplete semver when given more specific version', (t) => {
  46. t.plan(3)
  47. t.equal(android.get("9.0").versionCode, android.P.versionCode)
  48. t.equal(android.get("9.0.0").versionCode, android.P.versionCode)
  49. t.equal(android.get("7.1.1").versionCode, android.N_MR1.versionCode)
  50. })
  51. test('support version ranges', (t) => {
  52. t.plan(7)
  53. let tests = [ "4.4", "4.4.0", "4.4.1", "4.4.2", "4.4.3", "4.4.4" ]
  54. tests.forEach((versionCode) => {
  55. t.equal(android.get(versionCode).versionCode, android.KITKAT.versionCode)
  56. })
  57. t.equal(android.get("4.4.5").versionCode, android.KITKAT_WATCH.versionCode)
  58. })
  59. test('support x-ranges', (t) => {
  60. t.plan(12)
  61. let tests = [
  62. "4.1", "4.1.0", "4.1.1", "4.1.2", "4.1.3", "4.1.4",
  63. "4.1.5", "4.1.6", "4.1.7", "4.1.8", "4.1.9", "4.1.10"
  64. ]
  65. tests.forEach((versionCode) => {
  66. t.equal(android.get(versionCode).versionCode, android.JELLY_BEAN.versionCode)
  67. })
  68. })
  69. test('access version codes object', (t) => {
  70. t.plan(1)
  71. t.ok(android.VERSIONS)
  72. })
  73. test('access specific versions directly', (t) => {
  74. t.plan(30)
  75. t.ok(android.BASE)
  76. t.ok(android.BASE_1_1)
  77. t.ok(android.CUPCAKE)
  78. t.ok(android.DONUT)
  79. t.ok(android.ECLAIR)
  80. t.ok(android.ECLAIR_0_1)
  81. t.ok(android.ECLAIR_MR1)
  82. t.ok(android.FROYO)
  83. t.ok(android.GINGERBREAD)
  84. t.ok(android.GINGERBREAD_MR1)
  85. t.ok(android.HONEYCOMB)
  86. t.ok(android.HONEYCOMB_MR1)
  87. t.ok(android.HONEYCOMB_MR2)
  88. t.ok(android.ICE_CREAM_SANDWICH)
  89. t.ok(android.ICE_CREAM_SANDWICH_MR1)
  90. t.ok(android.JELLY_BEAN)
  91. t.ok(android.JELLY_BEAN_MR1)
  92. t.ok(android.JELLY_BEAN_MR2)
  93. t.ok(android.KITKAT)
  94. t.ok(android.KITKAT_WATCH)
  95. t.ok(android.LOLLIPOP)
  96. t.ok(android.LOLLIPOP_MR1)
  97. t.ok(android.M)
  98. t.ok(android.N)
  99. t.ok(android.N_MR1)
  100. t.ok(android.O)
  101. t.ok(android.O_MR1)
  102. t.ok(android.P)
  103. t.ok(android.Q)
  104. t.ok(android.R)
  105. })