|
| 1 | +import * as apiModel from './api/project-list.api-model'; |
| 2 | +import * as viewModel from './project-list.vm'; |
| 3 | +import { mapProjectListFromApiToVm } from './project-list.mappers'; |
| 4 | + |
| 5 | +describe('./pods/project-list', () => { |
| 6 | + it('should return empty array when feeding undefined project list', () => { |
| 7 | + // Arrange |
| 8 | + const projectList = undefined; |
| 9 | + |
| 10 | + // Act |
| 11 | + const result = mapProjectListFromApiToVm(projectList); |
| 12 | + |
| 13 | + // Assert |
| 14 | + expect(result).toEqual([]); |
| 15 | + }); |
| 16 | + |
| 17 | + it('should return empty array when feeding null project list', () => { |
| 18 | + // Arrange |
| 19 | + const projectList = null; |
| 20 | + |
| 21 | + // Act |
| 22 | + const result = mapProjectListFromApiToVm(projectList); |
| 23 | + |
| 24 | + // Assert |
| 25 | + expect(result).toEqual([]); |
| 26 | + }); |
| 27 | + |
| 28 | + it('should return empty array when feeding empty array project list', () => { |
| 29 | + // Arrange |
| 30 | + const projectList = []; |
| 31 | + |
| 32 | + // Act |
| 33 | + const result = mapProjectListFromApiToVm(projectList); |
| 34 | + |
| 35 | + // Assert |
| 36 | + expect(result).toEqual([]); |
| 37 | + }); |
| 38 | + |
| 39 | + it('should return one item with values when passing one item with values', () => { |
| 40 | + // Arrange |
| 41 | + const projectList: apiModel.Project[] = [ |
| 42 | + { |
| 43 | + id: 'test id', |
| 44 | + active: true, |
| 45 | + code: 'test code', |
| 46 | + projectName: 'test project name', |
| 47 | + lastDateIncurred: '02/02/2020', |
| 48 | + creationDate: '05/11/2019', |
| 49 | + }, |
| 50 | + ]; |
| 51 | + |
| 52 | + const expectedResult: viewModel.Project[] = [ |
| 53 | + { |
| 54 | + id: 'test id', |
| 55 | + active: true, |
| 56 | + code: 'test code', |
| 57 | + projectName: 'test project name', |
| 58 | + lastDateIncurred: '02/02/2020', |
| 59 | + creationDate: '05/11/2019', |
| 60 | + }, |
| 61 | + ]; |
| 62 | + |
| 63 | + // Act |
| 64 | + const result = mapProjectListFromApiToVm(projectList); |
| 65 | + |
| 66 | + // Assert |
| 67 | + expect(result).toEqual(expectedResult); |
| 68 | + }); |
| 69 | + |
| 70 | + it('should return two item with values when passing two item with values', () => { |
| 71 | + // Arrange |
| 72 | + const projectList: apiModel.Project[] = [ |
| 73 | + { |
| 74 | + id: 'test id 1', |
| 75 | + active: true, |
| 76 | + code: 'test code', |
| 77 | + projectName: 'test project name 1', |
| 78 | + lastDateIncurred: '02/02/2020', |
| 79 | + creationDate: '05/11/2019', |
| 80 | + }, |
| 81 | + { |
| 82 | + id: 'test id 2', |
| 83 | + active: false, |
| 84 | + code: 'test code', |
| 85 | + projectName: 'test project name 2', |
| 86 | + lastDateIncurred: '02/11/2020', |
| 87 | + creationDate: '05/05/2019', |
| 88 | + }, |
| 89 | + ]; |
| 90 | + |
| 91 | + const expectedResult: viewModel.Project[] = [ |
| 92 | + { |
| 93 | + id: 'test id 1', |
| 94 | + active: true, |
| 95 | + code: 'test code', |
| 96 | + projectName: 'test project name 1', |
| 97 | + lastDateIncurred: '02/02/2020', |
| 98 | + creationDate: '05/11/2019', |
| 99 | + }, |
| 100 | + { |
| 101 | + id: 'test id 2', |
| 102 | + active: false, |
| 103 | + code: 'test code', |
| 104 | + projectName: 'test project name 2', |
| 105 | + lastDateIncurred: '02/11/2020', |
| 106 | + creationDate: '05/05/2019', |
| 107 | + }, |
| 108 | + ]; |
| 109 | + |
| 110 | + // Act |
| 111 | + const result = mapProjectListFromApiToVm(projectList); |
| 112 | + |
| 113 | + // Assert |
| 114 | + expect(result).toEqual(expectedResult); |
| 115 | + }); |
| 116 | +}); |
0 commit comments