You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

systemtagsSpec.js 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /**
  2. * ownCloud
  3. *
  4. * @author Joas Schilling
  5. * @copyright 2016 Joas Schilling <nickvergessen@owncloud.com>
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  9. * License as published by the Free Software Foundation; either
  10. * version 3 of the License, or any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public
  18. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. */
  21. describe('OC.SystemTags tests', function() {
  22. it('describes non existing tag', function() {
  23. var $return = OC.SystemTags.getDescriptiveTag('23');
  24. expect($return.textContent).toEqual('Non-existing tag #23');
  25. expect($return.classList.contains('non-existing-tag')).toEqual(true);
  26. });
  27. it('describes SystemTagModel', function() {
  28. var tag = new OC.SystemTags.SystemTagModel({
  29. id: 23,
  30. name: 'Twenty Three',
  31. userAssignable: true,
  32. userVisible: true
  33. });
  34. var $return = OC.SystemTags.getDescriptiveTag(tag);
  35. expect($return.textContent).toEqual('Twenty Three');
  36. expect($return.classList.contains('non-existing-tag')).toEqual(false);
  37. });
  38. it('describes JSON tag object', function() {
  39. var $return = OC.SystemTags.getDescriptiveTag({
  40. id: 42,
  41. name: 'Fourty Two',
  42. userAssignable: true,
  43. userVisible: true
  44. });
  45. expect($return.textContent).toEqual('Fourty Two');
  46. expect($return.classList.contains('non-existing-tag')).toEqual(false);
  47. });
  48. it('scope', function() {
  49. function testScope(userVisible, userAssignable, expectedText) {
  50. var $return = OC.SystemTags.getDescriptiveTag({
  51. id: 42,
  52. name: 'Fourty Two',
  53. userAssignable: userAssignable,
  54. userVisible: userVisible
  55. });
  56. expect($return.textContent).toEqual(expectedText);
  57. expect($return.classList.contains('non-existing-tag')).toEqual(false);
  58. }
  59. testScope(true, true, 'Fourty Two');
  60. testScope(false, true, 'Fourty Two (Invisible)');
  61. testScope(false, false, 'Fourty Two (Invisible)');
  62. testScope(true, false, 'Fourty Two (Restricted)');
  63. });
  64. });