Sha256: d5dbfa32e895e90d5236d85ade17ea104e453330a1a3a6565b703463da8b5fec

Contents?: true

Size: 1.32 KB

Versions: 3

Compression:

Stored size: 1.32 KB

Contents

import { isPresent } from '..';
import { moduleFor, AbstractTestCase } from 'internal-test-helpers';

moduleFor(
  'isPresent',
  class extends AbstractTestCase {
    ['@test isPresent'](assert) {
      let string = 'string';
      let fn = function() {};
      let object = { length: 0 };

      assert.equal(false, isPresent(), 'for no params');
      assert.equal(false, isPresent(null), 'for null');
      assert.equal(false, isPresent(undefined), 'for undefined');
      assert.equal(false, isPresent(''), 'for an empty String');
      assert.equal(false, isPresent('  '), 'for a whitespace String');
      assert.equal(false, isPresent('\n\t'), 'for another whitespace String');
      assert.equal(true, isPresent('\n\t Hi'), 'for a String with whitespaces');
      assert.equal(true, isPresent(true), 'for true');
      assert.equal(true, isPresent(false), 'for false');
      assert.equal(true, isPresent(string), 'for a String');
      assert.equal(true, isPresent(fn), 'for a Function');
      assert.equal(true, isPresent(0), 'for 0');
      assert.equal(false, isPresent([]), 'for an empty Array');
      assert.equal(true, isPresent({}), 'for an empty Object');
      assert.equal(false, isPresent(object), "for an Object that has zero 'length'");
      assert.equal(true, isPresent([1, 2, 3]), 'for a non-empty array');
    }
  }
);

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
discourse-ember-source-3.6.0.0 dist/es/@ember/-internals/metal/tests/is_present_test.js
discourse-ember-source-3.5.1.1 dist/es/ember-metal/tests/is_present_test.js
discourse-ember-source-3.5.1.0 dist/dist/es/ember-metal/tests/is_present_test.js