(actual, expected, kind)
| 137 | * @returns {string} diff string |
| 138 | */ |
| 139 | const diffItems = (actual, expected, kind) => { |
| 140 | const tooMuch = [...actual]; |
| 141 | const missing = [...expected]; |
| 142 | for (let i = 0; i < missing.length; i++) { |
| 143 | const current = missing[i]; |
| 144 | for (let j = 0; j < tooMuch.length; j++) { |
| 145 | if (check(current, tooMuch[j])) { |
| 146 | tooMuch.splice(j, 1); |
| 147 | missing.splice(i, 1); |
| 148 | i--; |
| 149 | break; |
| 150 | } |
| 151 | } |
| 152 | } |
| 153 | const diff = []; |
| 154 | if (missing.length > 0) { |
| 155 | diff.push(`The following expected ${kind}s are missing: |
| 156 | ${missing.map((item) => `${explain(item)}`).join("\n\n")}`); |
| 157 | } |
| 158 | if (tooMuch.length > 0) { |
| 159 | diff.push(`The following ${kind}s are unexpected: |
| 160 | ${tooMuch.map((item) => `${explain(item)}`).join("\n\n")}`); |
| 161 | } |
| 162 | return diff.join("\n\n"); |
| 163 | }; |
| 164 | |
| 165 | /** |
| 166 | * @param {string} testDirectory test directory |
no test coverage detected