Skip to content

Commit d633a9e

Browse files
committed
Fix coverage
1 parent c50da5e commit d633a9e

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

src/transform-node.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class Transformer extends Source {
126126
if (node instanceof angular.Interpolation) {
127127
const { expressions } = node;
128128

129-
// istanbul ignore next 3
129+
/* c8 ignore next 3 */
130130
if (expressions.length !== 1) {
131131
throw new Error("Unexpected 'Interpolation'");
132132
}
@@ -373,7 +373,7 @@ class Transformer extends Source {
373373
{ type: 'Identifier', name: 'undefined', ...node.sourceSpan },
374374
{ hasParentParens: isInParentParens },
375375
);
376-
// istanbul ignore next
376+
/* c8 ignore next 4 */
377377
default:
378378
throw new Error(
379379
`Unexpected LiteralPrimitive value type ${typeof value}`,
@@ -432,23 +432,27 @@ class Transformer extends Source {
432432
node instanceof angular.TypeofExpression ||
433433
node instanceof angular.VoidExpression
434434
) {
435-
const expression = this.#transform<babel.Expression>(node.expression);
436-
437435
const operator =
438436
node instanceof angular.PrefixNot
439437
? '!'
440438
: node instanceof angular.TypeofExpression
441439
? 'typeof'
442440
: node instanceof angular.VoidExpression
443441
? 'void'
444-
: undefined;
442+
: /* c8 ignore next */
443+
undefined;
444+
445+
/* c8 ignore next 3 */
446+
if (!operator) {
447+
throw new Error('Unexpected expression.');
448+
}
445449

446450
let { start } = node.sourceSpan;
447451

448452
if (operator === 'typeof' || operator === 'void') {
449453
const index = this.text.lastIndexOf(operator, start);
450454

451-
// istanbul ignore next 7
455+
/* c8 ignore next 7 */
452456
if (index === -1) {
453457
throw new Error(
454458
`Cannot find operator '${operator}' from index ${start} in ${JSON.stringify(
@@ -460,6 +464,8 @@ class Transformer extends Source {
460464
start = index;
461465
}
462466

467+
const expression = this.#transform<babel.Expression>(node.expression);
468+
463469
return this.#create<babel.UnaryExpression>(
464470
{
465471
type: 'UnaryExpression',
@@ -610,7 +616,7 @@ class Transformer extends Source {
610616
);
611617
}
612618

613-
// istanbul ignore next
619+
/* c8 ignore next */
614620
throw new Error(`Unexpected node type '${node.constructor.name}'`);
615621
}
616622
}

src/transform-template-binding.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,14 @@ class Transformer extends NodeTransformer {
168168
});
169169

170170
const lastNode = body.pop()!;
171-
// istanbul ignore else
171+
172172
if (lastNode.type === 'NGMicrosyntaxExpression') {
173173
body.push(updateExpressionAlias(lastNode));
174174
} else if (lastNode.type === 'NGMicrosyntaxKeyedExpression') {
175175
const expression = updateExpressionAlias(lastNode.expression);
176176
body.push(updateSpanEnd({ ...lastNode, expression }, expression.end));
177177
} else {
178+
/* c8 ignore next 2 */
178179
throw new Error(`Unexpected type ${lastNode.type}`);
179180
}
180181
} else {

src/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export function getCharacterLastIndex(
106106
}
107107
}
108108

109+
/* c8 ignore next 4 */
109110
throw new Error(
110111
`Cannot find front char ${pattern} from index ${fromIndex} in ${JSON.stringify(
111112
text,

vitest.config.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ export default defineConfig({
1010
reporter: ['lcov', 'text'],
1111
include: ['src/**/*.ts'],
1212
exclude: ['src/index.ts', 'src/helpers.ts', 'src/types.ts'],
13-
// FIXME
1413
thresholds: {
15-
branches: 95,
16-
functions: 95,
17-
lines: 95,
18-
statements: 95,
14+
branches: 100,
15+
functions: 100,
16+
lines: 100,
17+
statements: 100,
1918
},
2019
},
2120
},

0 commit comments

Comments
 (0)