项目原始demo,不改动
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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 

33 rivejä
821 B

  1. describe( 'coalescy', function () {
  2. beforeEach( function () {
  3. this.coalesce = require( '../index' );
  4. } );
  5. it( 'should return the first non null value', function () {
  6. var result = this.coalesce( null, [] );
  7. expect( result ).to.deep.equal( [] );
  8. result = this.coalesce( null, {} );
  9. expect( result ).to.deep.equal( {} );
  10. result = this.coalesce( null, [], {} );
  11. expect( result ).to.deep.equal( [] );
  12. result = this.coalesce( null, undefined, 0, {} );
  13. expect( result ).to.equal( 0 );
  14. var a = null,
  15. b,
  16. c = 0,
  17. d = 1;
  18. result = this.coalesce( a, b, c, d );
  19. expect( result ).to.equal( 0 );
  20. } );
  21. it( 'should return null when no arguments are passed', function () {
  22. var result = this.coalesce();
  23. expect( result ).to.equal( null );
  24. } );
  25. } );