<commit_before>import Em from 'ember';
import { moduleFor, test } from 'ember-qunit';
import queue from 'ember-flash-messages/queue';

var contains = QUnit.contains;
var isFunction = QUnit.isFunction;
var typeOf = QUnit.typeOf;

var clearQueue = function() {
  Em.run(function() {
    queue.clear();
  });
};

module('Flash messages - Queue', {

  setup: function() {

  },

  teardown: function() {
    Em.run(function() {
      queue.clear();
    });
  }

});



test('Queue construction', function() {

  contains(queue.get('constructor').toString(), 'Array',
    'Queue should be constructed from an array class');

  typeOf(queue, 'instance',
    'Queue should be an instance, not a class');

  typeOf(queue.get('content'), 'array',
    'Queue content should be an array');

  strictEqual(queue.get('length'), 0,
    'Queue content should be an empty array');

  typeOf(queue.get('untimedMessages'), 'array',
    'Queue untimed messages array should be an array');

  strictEqual(queue.get('untimedMessages.length'), 0,
    'Queue untimed messages array should be an empty array');

  typeOf(queue.get('timedMessages'), 'array',
    'Queue timed messages array should be an array');

  strictEqual(queue.get('timedMessages.length'), 0,
    'Queue timed messages array should be an empty array');

});



test('Default properties and methods', function() {

  ok(queue.get('animationDuration'),
    'Queue should have a default animation duration');

  ok(queue.get('interval'),
    'Queue should have a default interval');

  isFunction(queue.clear,
    'The queue should have a public clear() method');

  isFunction(queue.pushMessage,
    'The queue should have a public pushMessage() method');

  isFunction(queue.removeMessage,
    'The queue should have a public removeMessage() method');

});



test('Default properties and methods', function() {

  ok(queue.get('animationDuration'),
    'Queue should have a default animation duration');

  ok(queue.get('interval'),
    'Queue should have a default interval');

  isFunction(queue.clear,
    'The queue should have a public clear() method');

  isFunction(queue.pushMessage,
    'The queue should have a public pushMessage() method');

  isFunction(queue.removeMessage,
    'The queue should have a public removeMessage() method');

});



test('Pushing messages', function() {
  var untimedMessage = {
    content: 'This is the first message',
    duration: 0, // Untimed
    type: 'success'
  };

  queue.pushMessage({
    content: 'This is the first message',
    duration: 3000,
    type: 'success'
  });

  strictEqual(queue.get('length'), 1,
    'Queue content should have one message');

  strictEqual(queue.get('timedMessages.length'), 1,
    'Queue timed messages array should have one message');

  Em.run(function() {
    queue.clear();
  });

  strictEqual(queue.get('length'), 0,
    'Calling clear() should clear the queue content');

  strictEqual(queue.get('length'), 0,
    'Calling clear() should clear the timed messages array');

  queue.pushMessage(untimedMessage);

  strictEqual(queue.get('length'), 1,
    'Queue content should have one message');

  strictEqual(queue.get('untimedMessages.length'), 1,
    'Queue untimed messages array should have one message');

  Em.run(function() {
    queue.clear();
  });

  strictEqual(queue.get('length'), 0,
    'Calling removeMessage() should clear the queue content');

  strictEqual(queue.get('untimedMessages.length'), 0,
    'Calling removeMessage() should clear the untimed messages array');

});<commit_msg>Async queue error in test fixed<commit_after>import Em from 'ember';
import { moduleFor, test } from 'ember-qunit';
import queue from 'ember-flash-messages/queue';

var contains = QUnit.contains;
var isFunction = QUnit.isFunction;
var typeOf = QUnit.typeOf;

module('Flash messages - Queue', {

  setup: function() {

  },

  teardown: function() {
    Em.run(function() {
      queue.clear();
    });
  }

});



test('Queue construction', function() {

  contains(queue.get('constructor').toString(), 'Array',
    'Queue should be constructed from an array class');

  typeOf(queue, 'instance',
    'Queue should be an instance, not a class');

  typeOf(queue.get('content'), 'array',
    'Queue content should be an array');

  strictEqual(queue.get('length'), 0,
    'Queue content should be an empty array');

  typeOf(queue.get('untimedMessages'), 'array',
    'Queue untimed messages array should be an array');

  strictEqual(queue.get('untimedMessages.length'), 0,
    'Queue untimed messages array should be an empty array');

  typeOf(queue.get('timedMessages'), 'array',
    'Queue timed messages array should be an array');

  strictEqual(queue.get('timedMessages.length'), 0,
    'Queue timed messages array should be an empty array');

});



test('Default properties and methods', function() {

  ok(queue.get('animationDuration'),
    'Queue should have a default animation duration');

  ok(queue.get('interval'),
    'Queue should have a default interval');

  isFunction(queue.clear,
    'The queue should have a public clear() method');

  isFunction(queue.pushMessage,
    'The queue should have a public pushMessage() method');

  isFunction(queue.removeMessage,
    'The queue should have a public removeMessage() method');

});



test('Default properties and methods', function() {

  ok(queue.get('animationDuration'),
    'Queue should have a default animation duration');

  ok(queue.get('interval'),
    'Queue should have a default interval');

  isFunction(queue.clear,
    'The queue should have a public clear() method');

  isFunction(queue.pushMessage,
    'The queue should have a public pushMessage() method');

  isFunction(queue.removeMessage,
    'The queue should have a public removeMessage() method');

});



test('Pushing messages', function() {
  var untimedMessage = {
    content: 'This is the first message',
    duration: 0, // Untimed
    type: 'success'
  };

  Em.run(function() {
    queue.pushMessage({
      content: 'This is the first message',
      duration: 3000,
      type: 'success'
    });
  });

  strictEqual(queue.get('length'), 1,
    'Queue content should have one message');

  strictEqual(queue.get('timedMessages.length'), 1,
    'Queue timed messages array should have one message');

  Em.run(function() {
    queue.clear();
  });

  strictEqual(queue.get('length'), 0,
    'Calling clear() should clear the queue content');

  strictEqual(queue.get('length'), 0,
    'Calling clear() should clear the timed messages array');

  Em.run(function() {
    queue.pushMessage(untimedMessage);
  });

  strictEqual(queue.get('length'), 1,
    'Queue content should have one message');

  strictEqual(queue.get('untimedMessages.length'), 1,
    'Queue untimed messages array should have one message');

  Em.run(function() {
    queue.clear();
  });

  strictEqual(queue.get('length'), 0,
    'Calling removeMessage() should clear the queue content');

  strictEqual(queue.get('untimedMessages.length'), 0,
    'Calling removeMessage() should clear the untimed messages array');

});
{'fraction_non_alphanumeric': 0.13724108778357053, 'fraction_numerical': 0.004508947442581373, 'mean_word_length': 4.073624017155111, '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': '6685642', 'n_tokens_mistral': 2131, 'n_tokens_neox': 2004, 'n_words': 638}