<commit_before>import Em from 'ember';
import { test } from 'ember-qunit';
import ArraySlice from 'array-slice';

test('constructor exists', function () {
	ok(ArraySlice, 'ArraySlice is not null or undefined');
	equal(typeof ArraySlice, 'function', 'ArraySlice is function');
});

test('content is initialized', function () {
	var arr = ['a', 'b', 'c'];
	var slice = ArraySlice.create({
		content: arr
	});
	equal(slice.get('arrangedContent.length'), 3);
	equal(slice.get('content.length'), 3);
	equal(slice.get('length'), 3);
	equal(slice.get('arrangedContent').join(''), 'abc');
});

test('offset defaults to zero', function () {
	var slice = ArraySlice.create({
		content: ['a', 'b', 'c']
	});
	equal(slice.get('offset'), 0);
});

test('offset can be initialized', function () {
	var slice = ArraySlice.create({
		content: ['a', 'b', 'c'],
		offset: 2
	});
	equal(slice.get('offset'), 2);
});

test('arranged content matches original content', function () {
	var slice = ArraySlice.create({
		content: ['a', 'b', 'c'],
		offset: 2
	});
	equal(slice.objectAt(0), 'c');
});

test('arranged content length does not exceed limit', function () {
	var slice = ArraySlice.create({
		content: ['a', 'b', 'c'],
		limit: 2
	});
	equal(slice.get('length'), 2);
});

test('offset can be updated', function () {
	var slice = ArraySlice.create({
		content: ['a', 'b', 'c']
	});
	equal(slice.objectAt(0), 'a');
	equal(slice.get('length'), 3);
	slice.set('offset', 1);
	equal(slice.objectAt(0), 'b');
	equal(slice.get('length'), 2);
	slice.set('offset', 2);
	equal(slice.objectAt(0), 'c');
	equal(slice.get('length'), 1);
});

test('content array unshift', function () {
	var arr = ['a', 'b', 'c'];
	var slice = ArraySlice.create({
		content: arr,
		offset: 1
	});
	equal(slice.objectAt(0), 'b');
	arr.unshiftObject('x');
	equal(slice.objectAt(0), 'a');
});
<commit_msg>Updated unit tests<commit_after>/* global QUnit */
import Em from 'ember';
import ArraySlice from 'array-slice';

QUnit.module('ArraySlice');

QUnit.test('constructor exists', function (assert) {
	assert.ok(ArraySlice, 'ArraySlice is not null or undefined');
	assert.equal(typeof ArraySlice, 'function', 'ArraySlice is function');
});

QUnit.test('content is initialized', function (assert) {
	var arr = Em.A(['a', 'b', 'c']);
	var slice = ArraySlice.create({
		content: arr
	});
	assert.equal(slice.get('arrangedContent.length'), 3);
	assert.equal(slice.get('content.length'), 3);
	assert.equal(slice.get('length'), 3);
	assert.deepEqual(slice.toArray(), ['a', 'b', 'c']);
});

QUnit.test('offset defaults to zero', function (assert) {
	var slice = ArraySlice.create({
		content: Em.A(['a', 'b', 'c'])
	});
	assert.equal(slice.get('offset'), 0);
});

QUnit.test('offset can be initialized', function (assert) {
	var slice = ArraySlice.create({
		content: Em.A(['a', 'b', 'c']),
		offset: 2
	});
	assert.equal(slice.get('offset'), 2);
});

QUnit.test('arranged content matches original content', function (assert) {
	var slice = ArraySlice.create({
		content: Em.A(['a', 'b', 'c']),
		offset: 2
	});
	assert.equal(slice.objectAt(0), 'c');
});

QUnit.test('arranged content length does not exceed limit', function (assert) {
	var slice = ArraySlice.create({
		content: Em.A(['a', 'b', 'c']),
		limit: 2
	});
	assert.equal(slice.get('length'), 2);
});

QUnit.test('offset can be updated', function (assert) {
	var slice = ArraySlice.create({
		content: Em.A(['a', 'b', 'c'])
	});
	assert.equal(slice.objectAt(0), 'a');
	assert.equal(slice.get('length'), 3);
	slice.set('offset', 1);
	assert.equal(slice.objectAt(0), 'b');
	assert.equal(slice.get('length'), 2);
	slice.set('offset', 2);
	assert.equal(slice.objectAt(0), 'c');
	assert.equal(slice.get('length'), 1);
});

QUnit.test('content array unshift', function (assert) {
	var arr = Em.A(['a', 'b', 'c']);
	var slice = ArraySlice.create({
		content: arr,
		offset: 1
	});
	assert.equal(slice.objectAt(0), 'b');
	arr.unshiftObject('x');
	assert.equal(slice.objectAt(0), 'a');
});

{'fraction_non_alphanumeric': 0.22473037371457236, 'fraction_numerical': 0.010534236267870579, 'mean_word_length': 5.144838212634823, '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': '4416209', 'n_tokens_mistral': 1452, 'n_tokens_neox': 1399, 'n_words': 342}