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

projectApi.spec.js 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. Licensed to the Apache Software Foundation (ASF) under one
  3. or more contributor license agreements. See the NOTICE file
  4. distributed with this work for additional information
  5. regarding copyright ownership. The ASF licenses this file
  6. to you under the Apache License, Version 2.0 (the
  7. "License"); you may not use this file except in compliance
  8. with the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing,
  11. software distributed under the License is distributed on an
  12. "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  13. KIND, either express or implied. See the License for the
  14. specific language governing permissions and limitations
  15. under the License.
  16. */
  17. var Api = require('../bin/template/cordova/Api');
  18. var shell = require('shelljs');
  19. var path = require('path');
  20. var tmpDir = path.join(__dirname, './temp');
  21. describe('can get the Api', function () {
  22. it('should be defined', function () {
  23. expect(Api).toBeDefined();
  24. });
  25. it('should export static createPlatform function', function (done) {
  26. expect(Api.createPlatform).toBeDefined();
  27. expect(typeof Api.createPlatform).toBe('function');
  28. // TODO: make this do something real
  29. var promise = Api.createPlatform(tmpDir);
  30. expect(promise).toBeDefined();
  31. expect(promise.then).toBeDefined();
  32. promise.then(function (res) {
  33. console.log('result = ' + res);
  34. shell.rm('-rf', tmpDir);
  35. done();
  36. },
  37. function (err) {
  38. console.log('spec-error ' + err);
  39. shell.rm('-rf', tmpDir);
  40. done();
  41. });
  42. });
  43. it('should export static updatePlatform function', function () {
  44. expect(Api.updatePlatform).toBeDefined();
  45. expect(typeof Api.updatePlatform).toBe('function');
  46. });
  47. });
  48. describe('project level Api', function () {
  49. var testApi = new Api();
  50. it('can be created', function () {
  51. expect(testApi).toBeDefined();
  52. });
  53. it('has a requirements method', function () {
  54. expect(testApi.requirements).toBeDefined();
  55. expect(typeof testApi.requirements).toBe('function');
  56. });
  57. it('has a clean method', function () {
  58. expect(testApi.clean).toBeDefined();
  59. expect(typeof testApi.clean).toBe('function');
  60. });
  61. it('has a run method', function () {
  62. expect(testApi.run).toBeDefined();
  63. expect(typeof testApi.run).toBe('function');
  64. });
  65. it('has a build method', function () {
  66. expect(testApi.build).toBeDefined();
  67. expect(typeof testApi.build).toBe('function');
  68. });
  69. it('has a removePlugin method', function () {
  70. expect(testApi.removePlugin).toBeDefined();
  71. expect(typeof testApi.removePlugin).toBe('function');
  72. });
  73. it('has a addPlugin method', function () {
  74. expect(testApi.addPlugin).toBeDefined();
  75. expect(typeof testApi.addPlugin).toBe('function');
  76. });
  77. it('has a prepare method', function () {
  78. expect(testApi.prepare).toBeDefined();
  79. expect(typeof testApi.prepare).toBe('function');
  80. });
  81. it('has a getPlatformInfo method', function () {
  82. expect(testApi.getPlatformInfo).toBeDefined();
  83. expect(typeof testApi.getPlatformInfo).toBe('function');
  84. });
  85. });
  86. // Static methods
  87. // Static method: createPlatform
  88. // returns promise fulfilled with Api
  89. // emits error using provided emmitter on error
  90. // Static method: updatePlatform
  91. // returns a promise fulfilled with an Api
  92. // emits error using provided emmitter on error
  93. // Instance methods
  94. // requirements, clean, run, build, removePlugin, addPlugin, prepare, getPlatformInfo