Extract tests related to jsonaryutils.js
authorFrank Bessou <frank.bessou@logilab.fr>
Fri, 30 Jun 2017 15:43:49 +0200
changeset 242 db082354de16
parent 241 e8544e97e811
child 243 8ed13b832c31
Extract tests related to jsonaryutils.js
src/jsonaryutils.spec.js
test/index.js
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jsonaryutils.spec.js	Fri Jun 30 15:43:49 2017 +0200
@@ -0,0 +1,30 @@
+/* global Jsonary */
+
+import {expect} from 'chai';
+
+// Ensure that the Jsonary's extensions are loaded
+import './jsonaryutils';
+
+describe('Jsonary Extensions', () => {
+    describe('mapItems', () => {
+        it('should map items ', () => {
+            const wrappedArray = Jsonary.create(['one', 2, 4]);
+
+            const mapped = wrappedArray.mapItems((currentItem, index) => currentItem.value() + index);
+
+            expect(mapped).to.deep.equal(['one0', 3, 6]);
+        });
+    });
+
+    describe('mapProperties', () => {
+        it('should map items ', () => {
+            const wrappedObject = Jsonary.create({a: 1, b: "two", c: {d: 3}});
+
+            const mapped = wrappedObject.mapProperties((property, key) =>
+                ({[key]: property.value()})
+            );
+
+            expect(mapped).to.deep.equal([{a: 1}, {b: "two"}, {c: {d: 3}}]);
+        });
+    });
+});
--- a/test/index.js	Fri Jun 30 17:06:25 2017 +0200
+++ b/test/index.js	Fri Jun 30 15:43:49 2017 +0200
@@ -1,5 +1,3 @@
-/* global Jsonary*/
-
 import chai from 'chai';
 import chaiAsPromised from 'chai-as-promised';
 import {shallow, render} from 'enzyme';
@@ -264,30 +262,6 @@
 
 });
 
-describe('Jsonary Extensions', () => {
-    describe('mapItems', () => {
-        it('should map items ', () => {
-            const wrappedArray = Jsonary.create(['one', 2, 4]);
-
-            const mapped = wrappedArray.mapItems((currentItem, index) => currentItem.value() + index);
-
-            expect(mapped).to.deep.equal(['one0', 3, 6]);
-        });
-    });
-
-    describe('mapProperties', () => {
-        it('should map items ', () => {
-            const wrappedObject = Jsonary.create({a: 1, b: "two", c: {d: 3}});
-
-            const mapped = wrappedObject.mapProperties((property, key) =>
-                ({[key]: property.value()})
-            );
-
-            expect(mapped).to.deep.equal([{a: 1}, {b: "two"}, {c: {d: 3}}]);
-        });
-    });
-});
-
 describe('Resource', () => {
     it('should select "ResourceCreationForm" when action is "add"', () => {
         const params = {