|
| 1 | +/* eslint-disable prefer-object-spread/prefer-object-spread */ |
1 | 2 | import Jimp from 'jimp'; |
2 | 3 | import fs from 'fs'; |
3 | 4 | import compareImage from './compareImage'; |
@@ -33,6 +34,7 @@ jest.mock('./utils/logger', () => ({ |
33 | 34 |
|
34 | 35 | const mockConfig = { |
35 | 36 | imageSnapshotPath: './differencify_report', |
| 37 | + imageSnapshotPathProvided: false, |
36 | 38 | saveDifferencifiedImage: true, |
37 | 39 | mismatchThreshold: 0.01, |
38 | 40 | }; |
@@ -74,6 +76,22 @@ describe('Compare Image', () => { |
74 | 76 | expect(result).toEqual({ updated: true }); |
75 | 77 | expect(fs.writeFileSync).toHaveBeenCalledWith('/parent/__image_snapshots__/test.snap.png', Object); |
76 | 78 | }); |
| 79 | + it('respects to imageSnapshotPath when in jest mode', async () => { |
| 80 | + const newGlobalConfig = Object.assign({}, mockConfig, |
| 81 | + { |
| 82 | + imageSnapshotPath: './someImagePath', |
| 83 | + imageSnapshotPathProvided: true, |
| 84 | + }); |
| 85 | + const result = await compareImage(Object, newGlobalConfig, { |
| 86 | + isUpdate: true, |
| 87 | + isJest: true, |
| 88 | + testName: 'test', |
| 89 | + testPath: '/src/test.js', |
| 90 | + imageType: 'png', |
| 91 | + }); |
| 92 | + expect(result).toEqual({ updated: true }); |
| 93 | + expect(fs.writeFileSync).toHaveBeenCalledWith('./someImagePath/test.snap.png', Object); |
| 94 | + }); |
77 | 95 | }); |
78 | 96 |
|
79 | 97 | describe('non-jest mode', () => { |
@@ -210,10 +228,8 @@ describe('Compare Image', () => { |
210 | 228 | write: mockWrite, |
211 | 229 | }, |
212 | 230 | }); |
213 | | - // eslint-disable-next-line prefer-object-spread/prefer-object-spread |
214 | 231 | const result = await compareImage( |
215 | 232 | Object, |
216 | | - // eslint-disable-next-line prefer-object-spread/prefer-object-spread |
217 | 233 | Object.assign({}, mockConfig, { saveDifferencifiedImage: true }), |
218 | 234 | mockTestConfig, |
219 | 235 | ); |
|
0 commit comments