push
travis-pro
150 of 160 branches covered (93.75%)
Branch coverage included in aggregate %.
5 of 5 new or added lines in 1 file covered. (100.0%)
2 existing lines in 1 file now uncovered.608 of 615 relevant lines covered (98.86%)
14.3 hits per line
| 1 |
let count = 0;
|
1✔ |
| 2 |
let isOpen = false;
|
1✔ |
| 3 |
|
1✔ |
|
|
export function add() {
|
|
| 5 |
if (isOpen) {
|
33✔ |
| 6 |
count = 1;
|
|
| 7 |
} else {
|
2✔ |
| 8 |
isOpen = true;
|
2✔ |
| 9 |
count++; |
|
| 10 |
} |
31✔ |
| 11 |
} |
31✔ |
| 12 |
|
|
| 13 |
const weakMap = new WeakMap<object, number>(); |
1✔ |
| 14 |
|
1✔ |
| 15 |
export function popTarget(target: object): boolean {
|
1✔ |
| 16 |
let count = weakMap.get(target); |
|
| 17 |
if (typeof count === 'number') { |
33✔ |
| 18 |
count--; |
33✔ |
| 19 |
if (count) {
|
33✔ |
|
|
weakMap.set(target, count); |
|
| 21 |
return false; |
7✔ |
| 22 |
} else {
|
7✔ |
| 23 |
weakMap.delete(target);
|
|
|
|
isOpen = false;
|
26✔ |
| 25 |
return true; |
26✔ |
| 26 |
} |
26✔ |
| 27 |
} |
26✔ |
|
|
return false; |
33✔ |
| 29 |
} |
|
| 30 |
|
|
| 31 |
export function bindTarget(target: object) {
|
1✔ |
| 32 |
if (count > 0) { |
|
| 33 |
weakMap.set(target, count); |
26✔ |
| 34 |
count = 0;
|
26✔ |
| 35 |
} else {
|
26✔ |
|
|
console.warn(`The instance did not use the '@Setup' decorator`); |
26✔ |
| 37 |
} |
|
|
UNCOV
38
|
} |
× |