<commit_before><!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>simpla-text</title>
    <script src="../../webcomponentsjs/webcomponents-lite.min.js"></script>
    <script src="../../web-component-tester/browser.js"></script>

    <!-- Test Helpers -->
    <link rel="import" href="../../iron-test-helpers/iron-test-helpers.html">
    <link rel="import" href="./test-setup.html">

    <!-- Import the element to test -->
    <link rel="import" href="../simpla-text.html">

  </head>
  <body>
    <test-fixture id="simple">
      <template>
        <simpla-text editable></simpla-text>
      </template>
    </test-fixture>
    <test-fixture id="forced-inline">
      <template>
        <div>
          <div><simpla-text inline editable></simpla-text></div>
        </div>
      </template>
    </test-fixture>
    <test-fixture id="auto-inline">
      <template>
        <div>
          <span><simpla-text editable></simpla-text></span>
        </div>
      </template>
    </test-fixture>
    <script>
      function checkWorksAsInline(getComponent, description) {
        describe(description || 'formats content as inline', () => {
          let component;

          beforeEach(() => {
            component = getComponent();
          });

          it('should not allow `p` tags', () => {
            component.value = '<p>Hello World</p>';

            return flushEditor(component)
              .then(() => {
                expect(component.value).to.equal('Hello World');
              });
          });

          it('should allow `br` tags', () => {
            component.value = 'Hello<br />World';

            return flushEditor(component)
              .then(() => {
                expect(component.value).to.match(/\<br/);
              });
          });

          it('should be display:inline;', () => {
            expect(window.getComputedStyle(component).display).to.equal('inline');
          });
        });
      }

      function checkWorksAsBlock(getComponent, description) {
        let component;

        beforeEach(() => {
          component = getComponent();
        });

        describe(description || 'formats content as block', () => {
          it('should allow `p` tags', () => {
            component.value = '<p>Hello World</p>';

            return flushEditor(component)
              .then(() => {
                expect(component.value).to.match(/<p/);
              });
          });

          it('should default to empty `p` tag when no content is set', () => {
            component.value = '';

            return flushEditor(component)
              .then(() => {
                expect(component.value).to.match(/<p/);
              });
          });

          it('should be display:block;', () => {
            expect(window.getComputedStyle(component).display).to.equal('block');
          });
        });
      }

      describe('default behavior', () => {
        let component;

        beforeEach(() => {
          component = fixture('simple');
          return flushEditor(component);
        });

        checkWorksAsBlock(() => component, 'should behave as a block');
      });

      describe('inline behavior', () => {
        let component;

        describe('forced inline mode', () => {
          beforeEach(function() {
            component = fixture('forced-inline').querySelector('simpla-text');
            return flushEditor(component);
          });<commit_msg>Simplify block testing during inline tests<commit_after><!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>simpla-text</title>
    <script src="../../webcomponentsjs/webcomponents-lite.min.js"></script>
    <script src="../../web-component-tester/browser.js"></script>

    <!-- Test Helpers -->
    <link rel="import" href="../../iron-test-helpers/iron-test-helpers.html">
    <link rel="import" href="./test-setup.html">

    <!-- Import the element to test -->
    <link rel="import" href="../simpla-text.html">

  </head>
  <body>
    <test-fixture id="simple">
      <template>
        <simpla-text editable></simpla-text>
      </template>
    </test-fixture>
    <test-fixture id="forced-inline">
      <template>
        <div>
          <div><simpla-text inline editable></simpla-text></div>
        </div>
      </template>
    </test-fixture>
    <test-fixture id="auto-inline">
      <template>
        <div>
          <span><simpla-text editable></simpla-text></span>
        </div>
      </template>
    </test-fixture>
    <script>
      function checkWorksAsInline(getComponent, description) {
        describe(description || 'formats content as inline', () => {
          let component;

          beforeEach(() => {
            component = getComponent();
          });

          it('should not allow `p` tags', () => {
            component.value = '<p>Hello World</p>';

            return flushEditor(component)
              .then(() => {
                expect(component.value).to.equal('Hello World');
              });
          });

          it('should allow `br` tags', () => {
            component.value = 'Hello<br />World';

            return flushEditor(component)
              .then(() => {
                expect(component.value).to.match(/\<br/);
              });
          });

          it('should be display:inline;', () => {
            expect(window.getComputedStyle(component).display).to.equal('inline');
          });
        });
      }

      function checkWorksAsBlock(getComponent, description) {
        let component;

        beforeEach(() => {
          component = getComponent();
          return flushEditor(component);
        });

        describe(description || 'formats content as block', () => {
          it('should allow `p` tags', () => {
            component.value = '<p>Hello World</p>';

            return flushEditor(component)
              .then(() => {
                expect(component.value).to.match(/<p/);
              });
          });

          it('should default to empty `p` tag when no content is set', () => {
            component.value = '';

            return flushEditor(component)
              .then(() => {
                expect(component.value).to.match(/<p/);
              });
          });

          it('should be display:block;', () => {
            expect(window.getComputedStyle(component).display).to.equal('block');
          });
        });
      }

      describe('default behavior', () => {
        checkWorksAsBlock(() => fixture('simple'), 'should behave as a block');
      });

      describe('inline behavior', () => {
        let component;

        describe('forced inline mode', () => {
          beforeEach(function() {
            component = fixture('forced-inline').querySelector('simpla-text');
            return flushEditor(component);
          });
{'fraction_non_alphanumeric': 0.17226277372262774, 'fraction_numerical': 0.00029197080291970805, 'mean_word_length': 1.8043389275480965, 'pattern_counts': {'":': 0, '<': 107, '<?xml version=': 0, '>': 138, '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': '2832866', 'n_tokens_mistral': 1891, 'n_tokens_neox': 1814, 'n_words': 338}