<commit_before>import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

module('Integration | Helper | get-code-snippet', function(hooks) {
  setupRenderingTest(hooks);

  test('it returns snippet', async function(assert) {
    await render(hbs`
      // BEGIN-SNIPPET render-test
      function sample(){
        return 42;
      };
      // END-SNIPPET
      
      {{#let (get-code-snippet "render-test.js") as |snippet|}}
        <div id="source">{{snippet.source}}</div>
        <div id="language">{{snippet.language}}</div>
        <div id="extension">{{snippet.extension}}</div>
      {{/let}}
    `);

    assert.dom('#source').hasText('function sample(){\n  return 42;\n};');
    assert.dom('#language').hasText('javascript'); // language is determined by file extension, so JS ini this case
    assert.dom('#extension').hasText('js');
  });

  test('it returns snippet w/ intented source', async function(assert) {
    await render(hbs`
      // BEGIN-SNIPPET render-test
      function sample(){
        return 42;
      };
      // END-SNIPPET
      
      {{#let (get-code-snippet "render-test.js" unintent=false) as |snippet|}}
        <div id="source">{{snippet.source}}</div>
        <div id="language">{{snippet.language}}</div>
        <div id="extension">{{snippet.extension}}</div>
      {{/let}}
    `);

    assert.dom('#source').hasText('      function sample(){\n        return 42;\n      };');
    assert.dom('#language').hasText('javascript'); // language is determined by file extension, so JS ini this case
    assert.dom('#extension').hasText('js');
  });
});<commit_msg>Replace `let` helper with `with` helper, to fix Ember 2.18 tests<commit_after>import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

module('Integration | Helper | get-code-snippet', function(hooks) {
  setupRenderingTest(hooks);

  test('it returns snippet', async function(assert) {
    await render(hbs`
      // BEGIN-SNIPPET render-test
      function sample(){
        return 42;
      };
      // END-SNIPPET
      
      {{#with (get-code-snippet "render-test.js") as |snippet|}}
        <div id="source">{{snippet.source}}</div>
        <div id="language">{{snippet.language}}</div>
        <div id="extension">{{snippet.extension}}</div>
      {{/with}}
    `);

    assert.dom('#source').hasText('function sample(){\n  return 42;\n};');
    assert.dom('#language').hasText('javascript'); // language is determined by file extension, so JS ini this case
    assert.dom('#extension').hasText('js');
  });

  test('it returns snippet w/ intented source', async function(assert) {
    await render(hbs`
      // BEGIN-SNIPPET render-test
      function sample(){
        return 42;
      };
      // END-SNIPPET
      
      {{#with (get-code-snippet "render-test.js" unintent=false) as |snippet|}}
        <div id="source">{{snippet.source}}</div>
        <div id="language">{{snippet.language}}</div>
        <div id="extension">{{snippet.extension}}</div>
      {{/with}}
    `);

    assert.dom('#source').hasText('      function sample(){\n        return 42;\n      };');
    assert.dom('#language').hasText('javascript'); // language is determined by file extension, so JS ini this case
    assert.dom('#extension').hasText('js');
  });
});
{'fraction_non_alphanumeric': 0.18155866400228377, 'fraction_numerical': 0.005423922352269483, 'mean_word_length': 3.074418604651163, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, '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': '129839', 'n_tokens_mistral': 1101, 'n_tokens_neox': 1060, 'n_words': 236}