utils.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. import { isDefault, isSupported, supportedOptions } from '../src/utils';
  6. describe( 'utils', () => {
  7. describe( 'isDefault()', () => {
  8. it( 'should return true for "left" alignment only (LTR)', () => {
  9. const locale = {
  10. contentLanguageDirection: 'ltr'
  11. };
  12. expect( isDefault( 'left', locale ) ).to.be.true;
  13. expect( isDefault( 'right', locale ) ).to.be.false;
  14. expect( isDefault( 'center', locale ) ).to.be.false;
  15. expect( isDefault( 'justify', locale ) ).to.be.false;
  16. } );
  17. it( 'should return true for "right" alignment only (RTL)', () => {
  18. const locale = {
  19. contentLanguageDirection: 'rtl'
  20. };
  21. expect( isDefault( 'left', locale ) ).to.be.false;
  22. expect( isDefault( 'right', locale ) ).to.be.true;
  23. expect( isDefault( 'center', locale ) ).to.be.false;
  24. expect( isDefault( 'justify', locale ) ).to.be.false;
  25. } );
  26. } );
  27. describe( 'isSupported()', () => {
  28. it( 'should return true for supported alignments', () => {
  29. expect( isSupported( 'left' ) ).to.be.true;
  30. expect( isSupported( 'right' ) ).to.be.true;
  31. expect( isSupported( 'center' ) ).to.be.true;
  32. expect( isSupported( 'justify' ) ).to.be.true;
  33. expect( isSupported( '' ) ).to.be.false;
  34. expect( isSupported( 'middle' ) ).to.be.false;
  35. } );
  36. } );
  37. describe( 'supportedOptions', () => {
  38. it( 'should be set', () => {
  39. expect( supportedOptions ).to.deep.equal( [ 'left', 'right', 'center', 'justify' ] );
  40. } );
  41. } );
  42. } );