<commit_before>var dirname = __dirname.split('/').pop(),
  filename = __filename.split('/').pop().split('.').shift(),
  lib = require('./placeholder'),
  edit = require('./edit');

describe(dirname, function () {
  describe(filename, function () {
    var sandbox;

    beforeEach(function () {
      sandbox = sinon.sandbox.create();
    });

    afterEach(function () {
      sandbox.restore();
    });

    describe('getPlaceholderText', function () {
      var fn = lib[this.title],
        mockName = 'foo.bar';

      it('uses _placeholder string if it exists', function () {
        expect(fn(mockName, {_placeholder: 'Baz'})).to.equal('Baz');
      });

      it('falls back to calling label service', function () {
        expect(fn(mockName, {_placeholder: 'true'})).to.equal('Foo » Bar');
      });
    });

    describe('getPlaceholderHeight', function () {
      var fn = lib[this.title];

      it('gets height of vertical-list', function () {
        expect(fn([{
          fn: 'text',
          required: true
        }, {
          fn: 'vertical-list'
        }])).to.equal('600px');
      });

      it('gets height of component', function () {
        expect(fn([{
          fn: 'component'
        }, {
          fn: 'dragdrop-reorder'
        }])).to.equal('300px');
      });

      it('gets default height', function () {
        expect(fn([{
          fn: 'text',
          required: true
        }, {
          fn: 'soft-maxlength',
          value: 80
        }])).to.equal('auto');
      });
    });

    describe('isFieldEmpty', function () {
      var fn = lib[this.title];

      it('is true if null', function () {
        expect(fn({value: null})).to.equal(true);
      });
      it('is true if empty string', function () {
        expect(fn({value: ''})).to.equal(true);
      });
      it('is true if empty array', function () {
        expect(fn([])).to.equal(true);
      });
      it('is true if empty obj', function () {
        expect(fn({})).to.equal(true);
      });
      it('is true if empty array w/ schema', function () {
        var emptyWithSchema = [];

        emptyWithSchema._schema = {};
        expect(fn(emptyWithSchema)).to.equal(true);
      });
      it('is true if empty obj w/ schema', function () {
        var emptyWithSchema = [];

        emptyWithSchema._schema = {};
        expect(fn(emptyWithSchema)).to.equal(true);
      });

      it('is false if string w/ characters', function () {
        expect(fn({value: '123'})).to.equal(false);
      });
      it('is false if number', function () {
        expect(fn({value: 123})).to.equal(false);
      });
      it('is false if array w/ values', function () {
        expect(fn({value: [1, 2, 3]})).to.equal(false);
      });
    });

    function stubData(data) {
      sandbox.stub(edit, 'getData').returns(Promise.resolve({
        title: data
      }));
    }

    function stubNode() {
      var node = document.createElement('div');

      node.setAttribute('name', 'title');
      return node;
    }

    it('adds if field and blank', function () {
      stubData({value: '', _schema: {
        _has: 'text',
        _placeholder: true
      }});

      return lib('fakeRef', stubNode()).then(function (newNode) {
        expect(newNode.querySelector('.editor-placeholder').style.height).to.equal('auto');
        expect(newNode.querySelector('span.placeholder-label').textContent).to.equal('Title');<commit_msg>updated stubs<commit_after>var dirname = __dirname.split('/').pop(),
  filename = __filename.split('/').pop().split('.').shift(),
  lib = require('./placeholder'),
  edit = require('./edit');

describe(dirname, function () {
  describe(filename, function () {
    var sandbox;

    beforeEach(function () {
      sandbox = sinon.sandbox.create();
    });

    afterEach(function () {
      sandbox.restore();
    });

    describe('getPlaceholderText', function () {
      var fn = lib[this.title],
        mockName = 'foo.bar';

      it('uses _placeholder string if it exists', function () {
        expect(fn(mockName, {_placeholder: 'Baz'})).to.equal('Baz');
      });

      it('falls back to calling label service', function () {
        expect(fn(mockName, {_placeholder: 'true'})).to.equal('Foo » Bar');
      });
    });

    describe('getPlaceholderHeight', function () {
      var fn = lib[this.title];

      it('gets height of vertical-list', function () {
        expect(fn([{
          fn: 'text',
          required: true
        }, {
          fn: 'vertical-list'
        }])).to.equal('600px');
      });

      it('gets height of component', function () {
        expect(fn([{
          fn: 'component'
        }, {
          fn: 'dragdrop-reorder'
        }])).to.equal('300px');
      });

      it('gets default height', function () {
        expect(fn([{
          fn: 'text',
          required: true
        }, {
          fn: 'soft-maxlength',
          value: 80
        }])).to.equal('auto');
      });
    });

    describe('isFieldEmpty', function () {
      var fn = lib[this.title];

      it('is true if null', function () {
        expect(fn({value: null})).to.equal(true);
      });
      it('is true if empty string', function () {
        expect(fn({value: ''})).to.equal(true);
      });
      it('is true if empty array', function () {
        expect(fn([])).to.equal(true);
      });
      it('is true if empty obj', function () {
        expect(fn({})).to.equal(true);
      });
      it('is true if empty array w/ schema', function () {
        var emptyWithSchema = [];

        emptyWithSchema._schema = {};
        expect(fn(emptyWithSchema)).to.equal(true);
      });
      it('is true if empty obj w/ schema', function () {
        var emptyWithSchema = [];

        emptyWithSchema._schema = {};
        expect(fn(emptyWithSchema)).to.equal(true);
      });

      it('is false if string w/ characters', function () {
        expect(fn({value: '123'})).to.equal(false);
      });
      it('is false if number', function () {
        expect(fn({value: 123})).to.equal(false);
      });
      it('is false if array w/ values', function () {
        expect(fn({value: [1, 2, 3]})).to.equal(false);
      });
    });

    function stubData(data) {
      sandbox.stub(edit, 'getData').returns(Promise.resolve({
        title: data
      }));
    }

    function stubNode() {
      var node = document.createElement('div');

      node.setAttribute('editable', 'title');
      return node;
    }

    it('adds if field and blank', function () {
      stubData({value: '', _schema: {
        _has: 'text',
        _placeholder: true
      }});

      return lib('fakeRef', stubNode()).then(function (newNode) {
        expect(newNode.querySelector('.editor-placeholder').style.height).to.equal('auto');
        expect(newNode.querySelector('span.placeholder-label').textContent).to.equal('Title');
{'fraction_non_alphanumeric': 0.18451688009313155, 'fraction_numerical': 0.004947613504074505, 'mean_word_length': 2.2697431018078023, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3717420', 'n_tokens_mistral': 2068, 'n_tokens_neox': 2013, 'n_words': 420}