<commit_before><!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes">

    <title>cookie-consent test</title>

    <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
    <script src="../../web-component-tester/browser.js"></script>

    <link rel="import" href="../cookie-consent.html">
  </head>
  <body>
    <test-fixture id="basic">
      <template>
        <cookie-consent></cookie-consent>
      </template>
    </test-fixture>
    <test-fixture id="usingLocalStorage">
      <template>
        <cookie-consent use-local-storage></cookie-consent>
      </template>
    </test-fixture>
    <test-fixture id="usingSessionStorage">
      <template>
        <cookie-consent use-session-storage></cookie-consent>
      </template>
    </test-fixture>

    <script>
      suite('cookie-consent', function() {
        var consent;
        var server;

        setup(function() {
          // Setup a fake server that responds to any XHR with an EU country
          server = sinon.fakeServer.create();
          server.respondWith('GET', /.*/, [
            200,
            { 'Content-Type': 'application/json' },
            'IT'
          ]);
          // Clear the cookie
          document.cookie = 'acceptCookies=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
          // Clear the local storage
          localStorage.removeItem('acceptCookies');
          // Clear the session storage
          sessionStorage.removeItem('acceptCookies');
        });
        teardown(function() {
          server.restore();
        });

        test('instantiating the element works', function() {
          consent = fixture('basic');
          assert.equal(consent.is, 'cookie-consent');
        });

        test('pending status works', function() {
          consent = fixture('basic');
          server.respond();
          assert.equal(consent.cookiesStatus, 'pending');
        });

        test('accepting the policy works', function() {
          consent = fixture('basic');
          server.respond();
          consent.$$('paper-button').click();
          assert.equal(consent.cookiesStatus, 'accepted');
        });

        test('saving to a cookie works', function() {
          consent = fixture('basic');
          server.respond();
          consent.$$('paper-button').click();
          assert.equal(consent._cookieVal(), 'true');
        });

        test('saving to local storage works', function() {
          consent = fixture('usingLocalStorage');
          server.respond();
          consent.$$('paper-button').click();
          assert.equal(localStorage.getItem('acceptCookies'), 'true');
        });

        test('saving to session storage works', function() {
          consent = fixture('usingSessionStorage');
          server.respond();
          consent.$$('paper-button').click();
          assert.equal(sessionStorage.getItem('acceptCookies'), 'true');
        });
      });
    </script>
  </body>
</html>
<commit_msg>Fixed the mock server not returning a valid JSON string<commit_after><!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes">

    <title>cookie-consent test</title>

    <script src="../../webcomponentsjs/webcomponents-lite.js"></script>
    <script src="../../web-component-tester/browser.js"></script>

    <link rel="import" href="../cookie-consent.html">
  </head>
  <body>
    <test-fixture id="basic">
      <template>
        <cookie-consent></cookie-consent>
      </template>
    </test-fixture>
    <test-fixture id="usingLocalStorage">
      <template>
        <cookie-consent use-local-storage></cookie-consent>
      </template>
    </test-fixture>
    <test-fixture id="usingSessionStorage">
      <template>
        <cookie-consent use-session-storage></cookie-consent>
      </template>
    </test-fixture>

    <script>
      suite('cookie-consent', function() {
        var consent;
        var server;

        setup(function() {
          // Setup a fake server that responds to any XHR with an EU country
          server = sinon.fakeServer.create();
          server.respondWith('GET', /.*/, [
            200,
            { 'Content-Type': 'application/json' },
            '"IT"'
          ]);
          // Clear the cookie
          document.cookie = 'acceptCookies=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;';
          // Clear the local storage
          localStorage.removeItem('acceptCookies');
          // Clear the session storage
          sessionStorage.removeItem('acceptCookies');
        });
        teardown(function() {
          server.restore();
        });

        test('instantiating the element works', function() {
          consent = fixture('basic');
          assert.equal(consent.is, 'cookie-consent');
        });

        test('pending status works', function() {
          consent = fixture('basic');
          server.respond();
          assert.equal(consent.cookiesStatus, 'pending');
        });

        test('accepting the policy works', function() {
          consent = fixture('basic');
          server.respond();
          consent.$$('paper-button').click();
          assert.equal(consent.cookiesStatus, 'accepted');
        });

        test('saving to a cookie works', function() {
          consent = fixture('basic');
          server.respond();
          consent.$$('paper-button').click();
          assert.equal(consent._cookieVal(), 'true');
        });

        test('saving to local storage works', function() {
          consent = fixture('usingLocalStorage');
          server.respond();
          consent.$$('paper-button').click();
          assert.equal(localStorage.getItem('acceptCookies'), 'true');
        });

        test('saving to session storage works', function() {
          consent = fixture('usingSessionStorage');
          server.respond();
          consent.$$('paper-button').click();
          assert.equal(sessionStorage.getItem('acceptCookies'), 'true');
        });
      });
    </script>
  </body>
</html>

{'fraction_non_alphanumeric': 0.1608863198458574, 'fraction_numerical': 0.005780346820809248, 'mean_word_length': 2.227461139896373, 'pattern_counts': {'":': 0, '<': 75, '<?xml version=': 0, '>': 75, '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': '3461286', 'n_tokens_mistral': 1749, 'n_tokens_neox': 1683, 'n_words': 337}