Skip to content

Commit

Permalink
Merge c0fdc44 into d9c43c5
Browse files Browse the repository at this point in the history
  • Loading branch information
connectdotz committed Apr 30, 2023
2 parents d9c43c5 + c0fdc44 commit 4823c48
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion jsconfig.json
Expand Up @@ -7,4 +7,4 @@
"allowSyntheticDefaultImports": true
},
"exclude": ["node_modules", "bower_components", "jspm_packages", "tmp", "temp"]
}
}
5 changes: 4 additions & 1 deletion src/TestResults/match-by-context.ts
Expand Up @@ -71,7 +71,10 @@ export const buildSourceContainer = (sourceRoot: ParsedNode): ContainerNode<ItBl
let container = parent;
const attrs = (namedNode: NamedBlock): OptionalAttributes => ({
isGroup: namedNode.lastProperty === 'each' ? 'yes' : 'no',
nonLiteralName: namedNode.nameType !== 'Literal',
// TODO: we could probably remove the checking for 'Literal' after a while. This was probably produced by the older version of the babel-parser
nonLiteralName: !(
namedNode.nameType && ['StringLiteral', 'Literal'].includes(namedNode.nameType)
),
range: {
start: namedNode.start ? adjustLocation(namedNode.start) : UnknownRange.start,
end: namedNode.end ? adjustLocation(namedNode.end) : UnknownRange.end,
Expand Down
16 changes: 16 additions & 0 deletions tests/TestResults/match-by-context.test.ts
Expand Up @@ -148,6 +148,22 @@ describe('buildSourceContainer', () => {
expect(root.childData.map((n) => (n as any).name)).toEqual(['test-1', 'test-2']);
expect(root.childContainers).toHaveLength(0);
});
describe('can properly populate nonLiteralName for source blocks', () => {
it.each`
nameType | nonLiteralName
${null} | ${true}
${''} | ${true}
${'TemplateLiteral'} | ${true}
${'Whatever'} | ${true}
${'Literal'} | ${false}
${'StringLiteral'} | ${false}
`('$nameType => nonLiteralName? $inonLiteralName', ({ nameType, nonLiteralName }) => {
const t1 = helper.makeItBlock('test-1', [1, 0, 5, 0], { nameType });
const sourceRoot = helper.makeRoot([t1]);
const root = match.buildSourceContainer(sourceRoot);
expect(root.childData.map((n) => (n as any).attrs.nonLiteralName)).toEqual([nonLiteralName]);
});
});
});
describe('matchTestAssertions', () => {
const mockError = jest.fn();
Expand Down

0 comments on commit 4823c48

Please sign in to comment.