configuration_controller_test.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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('controllers/global/configuration_controller');
  20. describe('App.ConfigurationController', function () {
  21. var controller = App.ConfigurationController.create();
  22. describe('#checkTagsChanges()', function () {
  23. var testCases = [
  24. {
  25. title: 'Tags haven\'t been uploaded',
  26. content: {
  27. tags: [],
  28. storedTags: []
  29. },
  30. result: false
  31. },
  32. {
  33. title: 'New tag uploaded',
  34. content: {
  35. tags: [
  36. {
  37. siteName: 'site1',
  38. tagName: 1
  39. }
  40. ],
  41. storedTags: []
  42. },
  43. result: true
  44. },
  45. {
  46. title: 'Existing tag with with new tagName',
  47. content: {
  48. tags: [
  49. {
  50. siteName: 'site1',
  51. tagName: 1
  52. }
  53. ],
  54. storedTags: [
  55. {
  56. siteName: 'site1',
  57. tagName: 2
  58. }
  59. ]
  60. },
  61. result: true
  62. },
  63. {
  64. title: 'Tags with different tagNames',
  65. content: {
  66. tags: [
  67. {
  68. siteName: 'site1',
  69. tagName: 1
  70. }
  71. ],
  72. storedTags: [
  73. {
  74. siteName: 'site2',
  75. tagName: 1
  76. }
  77. ]
  78. },
  79. result: true
  80. },
  81. {
  82. title: 'One new tag uploaded',
  83. content: {
  84. tags: [
  85. {
  86. siteName: 'site2',
  87. tagName: 1
  88. },
  89. {
  90. siteName: 'site1',
  91. tagName: 1
  92. }
  93. ],
  94. storedTags: [
  95. {
  96. siteName: 'site2',
  97. tagName: 1
  98. }
  99. ]
  100. },
  101. result: true
  102. },
  103. {
  104. title: 'Tags haven\'t been changed',
  105. content: {
  106. tags: [
  107. {
  108. siteName: 'site2',
  109. tagName: 1
  110. }
  111. ],
  112. storedTags: [
  113. {
  114. siteName: 'site2',
  115. tagName: 1
  116. }
  117. ]
  118. },
  119. result: false
  120. }
  121. ];
  122. testCases.forEach(function (test) {
  123. it(test.title, function () {
  124. expect(controller.checkTagsChanges(test.content.tags, test.content.storedTags)).to.equal(test.result);
  125. });
  126. });
  127. });
  128. });