iswindow.js 798 B

1234567891011121314151617181920212223242526272829
  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. /* global window */
  6. import isWindow from '../../src/dom/iswindow';
  7. describe( 'isWindow()', () => {
  8. it( 'detects DOM Window in browsers', () => {
  9. expect( isWindow( window ) ).to.be.true;
  10. expect( isWindow( {} ) ).to.be.false;
  11. expect( isWindow( null ) ).to.be.false;
  12. expect( isWindow( undefined ) ).to.be.false;
  13. expect( isWindow( new Date() ) ).to.be.false;
  14. expect( isWindow( 42 ) ).to.be.false;
  15. } );
  16. it( 'detects DOM Window in the Electron environment', () => {
  17. const global = {
  18. get [ Symbol.toStringTag ]() {
  19. return 'global';
  20. }
  21. };
  22. expect( isWindow( global ) ).to.be.true;
  23. } );
  24. } );