sanitize.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* global describe, it */
  6. 'use strict';
  7. const sanitize = require( '../../tasks/dev/utils/sanitize' );
  8. const chai = require( 'chai' );
  9. const expect = chai.expect;
  10. describe( 'utils', () => {
  11. describe( 'sanitize', () => {
  12. describe( 'appendPeriodIfMissing', () => {
  13. it( 'should be defined', () => expect( sanitize.appendPeriodIfMissing ).to.be.a( 'function' ) );
  14. it( 'should trim whitespace/new lines to empty string', () => {
  15. const sanitized = sanitize.appendPeriodIfMissing( '\n\t\r ' );
  16. expect( sanitized ).to.equal( '' );
  17. } );
  18. it( 'should add period at the end if missing ', () => {
  19. const sanitized = sanitize.appendPeriodIfMissing( 'sometext' );
  20. expect( sanitized ).to.equal( 'sometext.' );
  21. } );
  22. it( 'should not add period at the end if present', () => {
  23. const sanitized = sanitize.appendPeriodIfMissing( 'sometext.' );
  24. expect( sanitized ).to.equal( 'sometext.' );
  25. } );
  26. it( 'should leave empty string as is', () => {
  27. const sanitized = sanitize.appendPeriodIfMissing( '' );
  28. expect( sanitized ).to.equal( '' );
  29. } );
  30. } );
  31. } );
  32. } );