|
1 | 1 | /* eslint-env mocha */ |
2 | 2 | import expect from "expect" |
3 | 3 | import { fromJS } from "immutable" |
4 | | -import { mapToList, validateNumber, validateInteger, validateParam, validateFile } from "core/utils" |
| 4 | +import { mapToList, validateNumber, validateInteger, validateParam, validateFile, fromJSOrdered } from "core/utils" |
5 | 5 | import win from "core/window" |
6 | 6 |
|
7 | | -describe("utils", function(){ |
| 7 | +describe("utils", function() { |
8 | 8 |
|
9 | 9 | describe("mapToList", function(){ |
10 | 10 |
|
@@ -544,4 +544,31 @@ describe("utils", function(){ |
544 | 544 | expect( result ).toEqual( [] ) |
545 | 545 | }) |
546 | 546 | }) |
| 547 | + |
| 548 | + describe("fromJSOrdered", () => { |
| 549 | + it("should create an OrderedMap from an object", () => { |
| 550 | + const param = { |
| 551 | + value: "test" |
| 552 | + } |
| 553 | + |
| 554 | + const result = fromJSOrdered(param).toJS() |
| 555 | + expect( result ).toEqual( { value: "test" } ) |
| 556 | + }) |
| 557 | + |
| 558 | + it("should not use an object's length property for Map size", () => { |
| 559 | + const param = { |
| 560 | + length: 5 |
| 561 | + } |
| 562 | + |
| 563 | + const result = fromJSOrdered(param).toJS() |
| 564 | + expect( result ).toEqual( { length: 5 } ) |
| 565 | + }) |
| 566 | + |
| 567 | + it("should create an OrderedMap from an array", () => { |
| 568 | + const param = [1, 1, 2, 3, 5, 8] |
| 569 | + |
| 570 | + const result = fromJSOrdered(param).toJS() |
| 571 | + expect( result ).toEqual( [1, 1, 2, 3, 5, 8] ) |
| 572 | + }) |
| 573 | + }) |
547 | 574 | }) |
0 commit comments