repository_test.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. require('models/repository');
  20. function getModel() {
  21. return App.Repository.createRecord();
  22. }
  23. describe('App.Repository', function () {
  24. var model;
  25. beforeEach(function () {
  26. model = getModel();
  27. });
  28. App.TestAliases.testAsComputedNotEqualProperties(getModel(), 'undo', 'baseUrl', 'latestBaseUrl');
  29. App.TestAliases.testAsComputedAlias(getModel(), 'isSelected', 'operatingSystem.isSelected', 'boolean');
  30. App.TestAliases.testAsComputedAlias(getModel(), 'clearAll', 'baseUrl', 'string'); // string??
  31. describe('#invalidFormatError', function () {
  32. var cases = [
  33. {
  34. baseUrl: 'http://domain-name_0.com/path/subpath?p0=v0&p1=v1@v2.v3#!~hash0,(hash1)+hash2[hash3]/*;hash_4%2F',
  35. invalidFormatError: false,
  36. title: 'valid http url'
  37. },
  38. {
  39. baseUrl: 'https://domain.com/path?p=v',
  40. invalidFormatError: false,
  41. title: 'valid https url'
  42. },
  43. {
  44. baseUrl: 'ftp://domain.com:123',
  45. invalidFormatError: false,
  46. title: 'valid ftp url'
  47. },
  48. {
  49. baseUrl: 'ftp://user_:password0@domain.com',
  50. invalidFormatError: false,
  51. title: 'valid ftp url with authorization'
  52. },
  53. {
  54. baseUrl: 'ftp://user :password/@domain.com',
  55. invalidFormatError: true,
  56. title: 'ftp url with disallowed characters'
  57. },
  58. {
  59. baseUrl: 'http://domain.com:/path',
  60. invalidFormatError: true,
  61. title: 'no port specified when expected'
  62. },
  63. {
  64. baseUrl: 'file://etc/file.repo',
  65. invalidFormatError: false,
  66. title: 'valid Unix file url'
  67. },
  68. {
  69. baseUrl: 'file:///etc/file.repo',
  70. invalidFormatError: false,
  71. title: 'valid Unix file url (3 slashes)'
  72. },
  73. {
  74. baseUrl: 'file://c:/file.repo',
  75. invalidFormatError: false,
  76. title: 'valid Windows file url'
  77. },
  78. {
  79. baseUrl: 'file:///c:/file.repo',
  80. invalidFormatError: false,
  81. title: 'valid Windows file url (3 slashes)'
  82. },
  83. {
  84. baseUrl: 'file://c|/file.repo',
  85. invalidFormatError: false,
  86. title: 'valid Windows file url (| separator)'
  87. },
  88. {
  89. baseUrl: 'file://C:/file.repo',
  90. invalidFormatError: false,
  91. title: 'valid Windows file url (capital drive char)'
  92. },
  93. {
  94. baseUrl: 'file://etc /file.repo',
  95. invalidFormatError: true,
  96. title: 'file url with disallowed characters'
  97. }
  98. ];
  99. cases.forEach(function (item) {
  100. it(item.title, function () {
  101. model.set('baseUrl', item.baseUrl);
  102. expect(model.get('invalidFormatError')).to.equal(item.invalidFormatError);
  103. });
  104. });
  105. });
  106. });