Repositorio del curso CCOM4030 el semestre B91 del proyecto kilometro0

manifest.spec.js 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 shell = require('shelljs');
  18. var fs = require('fs');
  19. var path = require('path');
  20. var util = require('util');
  21. var cordova_bin = path.join(__dirname, '../bin');// is this the same on all platforms?
  22. var tmpDir = path.join(__dirname, '../temp');
  23. var createScriptPath = path.join(cordova_bin, 'create');
  24. function createAndBuild (projectname, projectid) {
  25. var return_code = 0;
  26. var command;
  27. // remove existing folder
  28. shell.rm('-rf', tmpDir);
  29. shell.mkdir(tmpDir);
  30. // create the project
  31. command = util.format('"%s" "%s/%s" "%s" "%s"', createScriptPath, tmpDir, projectname, projectid, projectname);
  32. return_code = shell.exec(command).code;
  33. expect(return_code).toBe(0);
  34. var platWwwPath = path.join(tmpDir, projectname, 'platform_www');
  35. var manifestPath = path.join(platWwwPath, 'manifest.json');
  36. expect(fs.existsSync(manifestPath)).toBe(true);
  37. var manifestObj = require(manifestPath);
  38. expect(manifestObj.name).toBe(projectname);
  39. // start_url
  40. expect(manifestObj.start_url).toBe('index.html');
  41. // display
  42. expect(manifestObj.display).toBe('standalone');
  43. // description
  44. expect(manifestObj.description).toBeDefined();
  45. // background_color
  46. expect(manifestObj.background_color).toBeDefined();
  47. // theme_color
  48. expect(manifestObj.theme_color).toBeDefined();
  49. // scope
  50. expect(manifestObj.scope).toBeDefined();
  51. // orientation
  52. expect(manifestObj.orientation).toBeDefined();
  53. // icons
  54. expect(manifestObj.icons).toBeDefined();
  55. expect(Array.isArray(manifestObj.icons)).toBe(true);
  56. expect(manifestObj.icons.length).toBeDefined();
  57. expect(manifestObj.icons.length).toBeGreaterThan(0);
  58. // related_applications[{platform:'web'},{platform:'play',url:...}] ?
  59. // clean-up
  60. shell.rm('-rf', tmpDir);
  61. }
  62. describe('create', function () {
  63. it('create project with manifest.json', function () {
  64. var projectname = 'testcreate';
  65. var projectid = 'com.test.app1';
  66. createAndBuild(projectname, projectid);
  67. });
  68. });