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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. // shell.echo(command);
  33. return_code = shell.exec(command).code;
  34. expect(return_code).toBe(0);
  35. var tempCordovaScriptsPath = path.join(tmpDir, projectname, 'cordova');
  36. console.log('tempCordovaScriptsPath = ' + tempCordovaScriptsPath);
  37. // created project has scripts in the cordova folder
  38. // build, clean, log, run, version
  39. expect(fs.existsSync(path.join(tempCordovaScriptsPath, 'build'))).toBe(true);
  40. expect(fs.existsSync(path.join(tempCordovaScriptsPath, 'clean'))).toBe(true);
  41. expect(fs.existsSync(path.join(tempCordovaScriptsPath, 'log'))).toBe(true);
  42. expect(fs.existsSync(path.join(tempCordovaScriptsPath, 'run'))).toBe(true);
  43. expect(fs.existsSync(path.join(tempCordovaScriptsPath, 'version'))).toBe(true);
  44. // // build the project
  45. command = util.format('"%s/cordova/build"', path.join(tmpDir, projectname));
  46. // shell.echo(command);
  47. return_code = shell.exec(command, { silent: true }).code;
  48. expect(return_code).toBe(0);
  49. // clean-up
  50. shell.rm('-rf', tmpDir);
  51. }
  52. describe('create', function () {
  53. it('has a create script in bin/cordova', function () {
  54. expect(fs.existsSync(createScriptPath)).toBe(true);
  55. });
  56. it('create project with ascii name, no spaces', function () {
  57. var projectname = 'testcreate';
  58. var projectid = 'com.test.app1';
  59. createAndBuild(projectname, projectid);
  60. });
  61. it('create project with ascii name, and spaces', function () {
  62. var projectname = 'test create';
  63. var projectid = 'com.test.app2';
  64. createAndBuild(projectname, projectid);
  65. });
  66. it('create project with unicode name, no spaces', function () {
  67. var projectname = '応応応応用用用用';
  68. var projectid = 'com.test.app3';
  69. createAndBuild(projectname, projectid);
  70. });
  71. it('create project with unicode name, and spaces', function () {
  72. var projectname = '応応応応 用用用用';
  73. var projectid = 'com.test.app4';
  74. createAndBuild(projectname, projectid);
  75. });
  76. it('create project with ascii+unicode name, no spaces', function () {
  77. var projectname = '応応応応hello用用用用';
  78. var projectid = 'com.test.app5';
  79. createAndBuild(projectname, projectid);
  80. });
  81. it('create project with ascii+unicode name, and spaces', function () {
  82. var projectname = '応応応応 hello 用用用用';
  83. var projectid = 'com.test.app6';
  84. createAndBuild(projectname, projectid);
  85. });
  86. });