<commit_before>import Ember from 'ember';
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';

moduleForComponent( 'sl-translate', 'Integration | Component | sl translate', {
    beforeEach() {
        this.container.lookup( 'service:sl-translate' )
            .setDictionary(
                Ember.Object.create({
                    'SIMPLE_KEY': 'I have been translated',
                    'SINGULAR_KEY': 'View my family',
                    'PLURAL_KEY': 'View my families',
                    'REPLACED_KEY': 'I have replaced {0} and {1}'
                })
            );
    },

    integration: true
});

test( 'Simple Key Translation', function( assert ) {
    assert.expect( 1 );

    this.render( hbs`
        {{sl-translate key="SIMPLE_KEY" }}
    ` );

    assert.equal(
        this.$().text().trim(),
        'I have been translated',
        'Simple Key was translated'
    );
});

test( 'Single/Plural Keys', function( assert ) {
    assert.expect( 2 );

    this.render( hbs`
        {{sl-translate key="SINGULAR_KEY" pluralKey="PLURAL_KEY" pluralCount="1"}}
    ` );

    assert.equal(
        this.$().text().trim(),
        'View my family',
        'Singular Key was correctly returned'
    );

    this.render( hbs`
        {{sl-translate key="SINGULAR_KEY" pluralKey="PLURAL_KEY" pluralCount="3"}}
    ` );

    assert.equal(
        this.$().text().trim(),
        'View my families',
        'Plural Key was correctly returned'
    );
});

test( 'Replaced Values In Keys', function( assert ) {
    assert.expect( 2 );

    this.render( hbs`
        {{sl-translate key="REPLACED_KEY"}}
    ` );

    assert.equal(
        this.$().text().trim(),
        'I have replaced {0} and {1}',
        'Original String was correct'
    );

    this.render( hbs`
        {{sl-translate key="REPLACED_KEY" $0="First" $1="Unicorn"}}
    ` );

    assert.equal(
        this.$().text().trim(),
        'I have replaced First and Unicorn',
        'Replaced String was correct'
    );

});

test( 'Bound Replacement Values In Keys', function( assert ) {
    assert.expect( 1 );

    this.set( 'valueToDisplay', 'the Bound Value' );

    this.render( hbs`
        {{sl-translate key="REPLACED_KEY" $0="First" $1=valueToDisplay}}
    ` );

    assert.equal(
        this.$().text().trim(),
        'I have replaced First and the Bound Value',
        'Using a bound replacement value works'
    );
});

/**
 * Ensure haven't broken any default behavior of Ember, since manipulate properties passed to the component
 * A side effect of this test is the appearance that core Ember functionality is being tested
 */
test( 'Used Alongside Other Properties', function( assert ) {
    assert.expect( 2 );

    this.render( hbs`
        {{sl-translate key="SIMPLE_KEY"}}
    ` );

    assert.equal(
        this.$( 'em' ).length,<commit_msg>Removed assert.expect() calls from tests<commit_after>import Ember from 'ember';
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';

moduleForComponent( 'sl-translate', 'Integration | Component | sl translate', {
    beforeEach() {
        this.container.lookup( 'service:sl-translate' )
            .setDictionary(
                Ember.Object.create({
                    'SIMPLE_KEY': 'I have been translated',
                    'SINGULAR_KEY': 'View my family',
                    'PLURAL_KEY': 'View my families',
                    'REPLACED_KEY': 'I have replaced {0} and {1}'
                })
            );
    },

    integration: true
});

test( 'Simple Key Translation', function( assert ) {

    this.render( hbs`
        {{sl-translate key="SIMPLE_KEY" }}
    ` );

    assert.equal(
        this.$().text().trim(),
        'I have been translated',
        'Simple Key was translated'
    );
});

test( 'Single/Plural Keys', function( assert ) {

    this.render( hbs`
        {{sl-translate key="SINGULAR_KEY" pluralKey="PLURAL_KEY" pluralCount="1"}}
    ` );

    assert.equal(
        this.$().text().trim(),
        'View my family',
        'Singular Key was correctly returned'
    );

    this.render( hbs`
        {{sl-translate key="SINGULAR_KEY" pluralKey="PLURAL_KEY" pluralCount="3"}}
    ` );

    assert.equal(
        this.$().text().trim(),
        'View my families',
        'Plural Key was correctly returned'
    );
});

test( 'Replaced Values In Keys', function( assert ) {

    this.render( hbs`
        {{sl-translate key="REPLACED_KEY"}}
    ` );

    assert.equal(
        this.$().text().trim(),
        'I have replaced {0} and {1}',
        'Original String was correct'
    );

    this.render( hbs`
        {{sl-translate key="REPLACED_KEY" $0="First" $1="Unicorn"}}
    ` );

    assert.equal(
        this.$().text().trim(),
        'I have replaced First and Unicorn',
        'Replaced String was correct'
    );

});

test( 'Bound Replacement Values In Keys', function( assert ) {

    this.set( 'valueToDisplay', 'the Bound Value' );

    this.render( hbs`
        {{sl-translate key="REPLACED_KEY" $0="First" $1=valueToDisplay}}
    ` );

    assert.equal(
        this.$().text().trim(),
        'I have replaced First and the Bound Value',
        'Using a bound replacement value works'
    );
});

/**
 * Ensure haven't broken any default behavior of Ember, since manipulate properties passed to the component
 * A side effect of this test is the appearance that core Ember functionality is being tested
 */
test( 'Used Alongside Other Properties', function( assert ) {

    this.render( hbs`
        {{sl-translate key="SIMPLE_KEY"}}
    ` );

    assert.equal(
        this.$( 'em' ).length,
{'fraction_non_alphanumeric': 0.1467134092900964, 'fraction_numerical': 0.0043821209465381246, 'mean_word_length': 2.336842105263158, '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': '3428303', 'n_tokens_mistral': 1756, 'n_tokens_neox': 1670, 'n_words': 463}