( snapshots: SnapshotSummary, globalConfig: Config.GlobalConfig, updateCommand: string, )
| 23 | const SNAPSHOT_UPDATED = chalk.bold.green; |
| 24 | |
| 25 | export default function getSnapshotSummary( |
| 26 | snapshots: SnapshotSummary, |
| 27 | globalConfig: Config.GlobalConfig, |
| 28 | updateCommand: string, |
| 29 | ): Array<string> { |
| 30 | const summary = [SNAPSHOT_SUMMARY('Snapshot Summary')]; |
| 31 | if (snapshots.added) { |
| 32 | summary.push( |
| 33 | `${SNAPSHOT_ADDED( |
| 34 | `${ARROW + pluralize('snapshot', snapshots.added)} written `, |
| 35 | )}from ${pluralize('test suite', snapshots.filesAdded)}.`, |
| 36 | ); |
| 37 | } |
| 38 | |
| 39 | if (snapshots.unmatched) { |
| 40 | summary.push( |
| 41 | `${FAIL_COLOR( |
| 42 | `${ARROW}${pluralize('snapshot', snapshots.unmatched)} failed`, |
| 43 | )} from ${pluralize( |
| 44 | 'test suite', |
| 45 | snapshots.filesUnmatched, |
| 46 | )}. ${SNAPSHOT_NOTE( |
| 47 | `Inspect your code changes or ${updateCommand} to update them.`, |
| 48 | )}`, |
| 49 | ); |
| 50 | } |
| 51 | |
| 52 | if (snapshots.updated) { |
| 53 | summary.push( |
| 54 | `${SNAPSHOT_UPDATED( |
| 55 | `${ARROW + pluralize('snapshot', snapshots.updated)} updated `, |
| 56 | )}from ${pluralize('test suite', snapshots.filesUpdated)}.`, |
| 57 | ); |
| 58 | } |
| 59 | |
| 60 | if (snapshots.filesRemoved) { |
| 61 | if (snapshots.didUpdate) { |
| 62 | summary.push( |
| 63 | `${SNAPSHOT_REMOVED( |
| 64 | `${ARROW}${pluralize( |
| 65 | 'snapshot file', |
| 66 | snapshots.filesRemoved, |
| 67 | )} removed `, |
| 68 | )}from ${pluralize('test suite', snapshots.filesRemoved)}.`, |
| 69 | ); |
| 70 | } else { |
| 71 | summary.push( |
| 72 | `${OBSOLETE_COLOR( |
| 73 | `${ARROW}${pluralize( |
| 74 | 'snapshot file', |
| 75 | snapshots.filesRemoved, |
| 76 | )} obsolete `, |
| 77 | )}from ${pluralize( |
| 78 | 'test suite', |
| 79 | snapshots.filesRemoved, |
| 80 | )}. ${SNAPSHOT_NOTE( |
| 81 | `To remove ${ |
| 82 | snapshots.filesRemoved === 1 ? 'it' : 'them all' |
no test coverage detected