Skip to content

Commit

Permalink
Replace for..of with forEach 🥓
Browse files Browse the repository at this point in the history
The transpiled Babel output relies on Symbol.iterator which is not available in IE11.
  • Loading branch information
ZeeJab committed Sep 20, 2019
1 parent 5535e08 commit 529478f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 22 deletions.
41 changes: 23 additions & 18 deletions tests/unit/models/list-section-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import PostNodeBuilder from 'mobiledoc-kit/models/post-node-builder';
import TestHelpers from '../../test-helpers';
import { VALID_ATTRIBUTES, INVALID_ATTRIBUTES } from '../../helpers/sections';

const {module, test} = TestHelpers;
const { module, test } = TestHelpers;

let builder;
module('Unit: List Section', {
Expand All @@ -14,34 +14,39 @@ module('Unit: List Section', {
}
});

for (let attribute of VALID_ATTRIBUTES) {
VALID_ATTRIBUTES.forEach(attribute => {
// eslint-disable-next-line no-loop-func
test(`a section can have attribute "${attribute.key}" with value "${attribute.value}`, (assert) => {
const s1 = builder.createListSection('ol', [], { [attribute.key]: attribute.value });
test(`a section can have attribute "${attribute.key}" with value "${attribute.value}`, assert => {
const attributes = {};
attributes[attribute.key] = attribute.value;

const s1 = builder.createListSection('ol', [], attributes);
assert.deepEqual(
s1.attributes,
{ [attribute.key]: attribute.value },
attributes,
'Attribute set at instantiation'
);
});
}
});

for (let attribute of INVALID_ATTRIBUTES) {
INVALID_ATTRIBUTES.forEach(attribute => {
// eslint-disable-next-line no-loop-func
test(`a section throws when invalid attribute "${attribute.key}" is passed to a marker`, (assert) => {
test(`a section throws when invalid attribute "${attribute.key}" is passed to a marker`, assert => {
const attributes = {};
attributes[attribute.key] = attribute.value;

assert.throws(() => {
builder.createListSection('ul', [], { [attribute.key]: attribute.value });
builder.createListSection('ul', [], attributes);
});
});
}

test('cloning a list section creates the same type of list section', (assert) => {
let item = builder.createListItem([builder.createMarker('abc')]);
let list = builder.createListSection('ol', [item]);
let cloned = list.clone();
test('cloning a list section creates the same type of list section', assert => {
let item = builder.createListItem([builder.createMarker('abc')]);
let list = builder.createListSection('ol', [item]);
let cloned = list.clone();

assert.equal(list.tagName, cloned.tagName);
assert.equal(list.items.length, cloned.items.length);
assert.equal(list.items.head.text, cloned.items.head.text);
assert.equal(list.tagName, cloned.tagName);
assert.equal(list.items.length, cloned.items.length);
assert.equal(list.items.head.text, cloned.items.head.text);
});
});

8 changes: 4 additions & 4 deletions tests/unit/models/markup-section-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test('a section can append a marker', (assert) => {
assert.equal(s1.markers.length, 1);
});

for (let attribute of VALID_ATTRIBUTES) {
VALID_ATTRIBUTES.forEach(attribute => {
// eslint-disable-next-line no-loop-func
test(`a section can have attribute "${attribute.key}" with value "${attribute.value}`, (assert) => {
const s1 = builder.createMarkupSection('P', [], false, { [attribute.key]: attribute.value });
Expand All @@ -33,16 +33,16 @@ for (let attribute of VALID_ATTRIBUTES) {
'Attribute set at instantiation'
);
});
}
});

for (let attribute of INVALID_ATTRIBUTES) {
INVALID_ATTRIBUTES.forEach(attribute => {
// eslint-disable-next-line no-loop-func
test(`a section throws when invalid attribute "${attribute.key}" is passed to a marker`, (assert) => {
assert.throws(() => {
builder.createMarkupSection('P', [], false, attribute);
});
});
}
});

test('#isBlank returns true if the text length is zero for two markers', (assert) => {
const m1 = builder.createMarker('');
Expand Down

0 comments on commit 529478f

Please sign in to comment.