Skip to content

Commit

Permalink
chore: Remove unused functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Quramy committed Mar 15, 2024
1 parent 5136249 commit b775c51
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 34 deletions.
24 changes: 2 additions & 22 deletions src/ts-ast-util/tag-utils.test.ts
@@ -1,7 +1,7 @@
import ts from 'typescript';
import { findAllNodes, findNode } from './utilily-functions';
import { findAllNodes } from './utilily-functions';
import type { TagConfig, StrictTagCondition } from './types';
import { parseTagConfig, getTemplateNodeUnder, isTagged, getTagName } from './tag-utils';
import { parseTagConfig, getTemplateNodeUnder, getTagName } from './tag-utils';

describe(parseTagConfig, () => {
test.each([
Expand Down Expand Up @@ -190,23 +190,3 @@ describe(getTagName, () => {
expect(actual).toBe(undefined);
});
});

describe(isTagged, () => {
it('should return true when the tag condition is matched', () => {
// prettier-ignore
const text = 'function myTag(...args: any[]) { return "" }' + '\n'
+ 'const x = myTag`query { }`';
const s = ts.createSourceFile('input.ts', text, ts.ScriptTarget.Latest, true);
const node = findNode(s, text.length - 3) as ts.Node;
expect(isTagged(node, 'myTag')).toBeTruthy();
});

it('should return true when the tag condition is not matched', () => {
// prettier-ignore
const text = 'function myTag(...args: any[]) { return "" }' + '\n'
+ 'const x = myTag`query { }`';
const s = ts.createSourceFile('input.ts', text, ts.ScriptTarget.Latest, true);
const node = findNode(s, text.length - 3) as ts.Node;
expect(isTagged(node, 'MyTag')).toBeFalsy();
});
});
12 changes: 0 additions & 12 deletions src/ts-ast-util/tag-utils.ts
Expand Up @@ -92,15 +92,3 @@ export function getTagName(
}
return undefined;
}

Check warning on line 94 in src/ts-ast-util/tag-utils.ts

View check run for this annotation

Codecov / codecov/patch

src/ts-ast-util/tag-utils.ts#L94

Added line #L94 was not covered by tests

export function hasTagged(node: ts.Node | undefined, condition: string | undefined, source?: ts.SourceFile) {
if (!node) return;
if (!ts.isTaggedTemplateExpression(node)) return false;
const tagNode = node;
return tagNode.tag.getText(source) === condition;
}

export function isTagged(node: ts.Node | undefined, condition: string | undefined, source?: ts.SourceFile) {
if (!node) return false;
return hasTagged(node.parent, condition, source);
}

0 comments on commit b775c51

Please sign in to comment.