<commit_before>/* global container */

import Ember from 'ember';
import moduleForIntl from '../helpers/module-for-intl';
import { runAppend, runDestroy } from '../helpers/run-append';
import FormatMessage from '../../formatters/format-message';
import formatMessageHelper from '../../helpers/format-message';
import intlGet from '../../helpers/intl-get';
import Locale from 'ember-intl/models/locale';

var view;

moduleForIntl('format-message', {
    setup: function (container) {
        window.container = container;
        container.register('formatter:format-message', FormatMessage);
        container.register('helper:format-message', formatMessageHelper, { instantiate: false });
        container.register('helper:intl-get', intlGet, { instantiate: false });

        container.register('locale:en', Locale.extend({
            messages: {
                foo: {
                    bar: "foo bar baz"
                }
            }
        }));
    },
    teardown: function () {
        runDestroy(view);
        window.container = undefined;
    }
});

test('exists', function() {
    expect(1);
    ok(formatMessageHelper);
});

test('message is formatted correctly with argument', function() {
    expect(1);

    view = this.intlBlock('{{format-message "Hello {name}" name="Jason"}}');
    runAppend(view);

    equal(view.$().text(), "Hello Jason");
});

test('should throw if called with out a value', function(assert) {
    expect(1);
    view = this.intlBlock('{{format-message}}');
    assert.throws(runAppend(view), Error, 'raised error when not value is passed to format-message');
});<commit_msg>Removing global container in test, scoping container within the module<commit_after>import Ember from 'ember';
import moduleForIntl from '../helpers/module-for-intl';
import { runAppend, runDestroy } from '../helpers/run-append';
import FormatMessage from '../../formatters/format-message';
import formatMessageHelper from '../../helpers/format-message';
import intlGet from '../../helpers/intl-get';
import Locale from 'ember-intl/models/locale';

var view, container;

moduleForIntl('format-message', {
    setup: function (__container) {
        container = __container;

        container.register('formatter:format-message', FormatMessage);
        container.register('helper:format-message', formatMessageHelper, { instantiate: false });
        container.register('helper:intl-get', intlGet, { instantiate: false });

        container.register('locale:en', Locale.extend({
            messages: {
                foo: {
                    bar: "foo bar baz"
                }
            }
        }));
    },
    teardown: function () {
        runDestroy(view);
        container = undefined;
    }
});

test('exists', function() {
    expect(1);
    ok(formatMessageHelper);
});

test('message is formatted correctly with argument', function() {
    expect(1);

    view = this.intlBlock('{{format-message "Hello {name}" name="Jason"}}');
    runAppend(view);

    equal(view.$().text(), "Hello Jason");
});

test('should throw if called with out a value', function(assert) {
    expect(1);
    view = this.intlBlock('{{format-message}}');
    assert.throws(runAppend(view), Error, 'raised error when not value is passed to format-message');
});
{'fraction_non_alphanumeric': 0.15492528209820067, 'fraction_numerical': 0.0018298261665141812, 'mean_word_length': 3.1361916771752836, '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': '6519885', 'n_tokens_mistral': 911, 'n_tokens_neox': 901, 'n_words': 221}