Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 1 | import {TestBed} from "@angular/core/testing"; |
| 2 | import {ObjectToArrayPipe} from "./objectToArray.pipe"; |
| 3 | |
| 4 | |
| 5 | describe('Object To Array Pipe', () => { |
| 6 | let pipe: ObjectToArrayPipe; |
| 7 | |
| 8 | beforeAll(done => (async () => { |
| 9 | TestBed.configureTestingModule({ |
| 10 | |
| 11 | }); |
| 12 | await TestBed.compileComponents(); |
| 13 | pipe = new ObjectToArrayPipe(); |
| 14 | |
| 15 | })().then(done).catch(done.fail)); |
| 16 | |
| 17 | |
| 18 | test('should flat object to array', () => { |
| 19 | let object = { |
| 20 | "a" : { |
| 21 | "name" : "A" |
| 22 | }, |
| 23 | "b" : { |
| 24 | "name" : "B" |
| 25 | }, |
| 26 | "c" : { |
| 27 | "name" : "C" |
| 28 | } |
| 29 | }; |
| 30 | let result = pipe.transform(object); |
| 31 | expect(result[0]).toEqual({"name" : "A"}); |
| 32 | expect(result[1]).toEqual({"name" : "B"}); |
| 33 | expect(result[2]).toEqual({"name" : "C"}); |
| 34 | }); |
| 35 | }); |