Skip to content

Commit

Permalink
use-case test
Browse files Browse the repository at this point in the history
  • Loading branch information
lifeart committed Apr 1, 2021
1 parent 8278f95 commit 224ea21
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/builtin-addons/core/template-completion-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ export default class TemplateCompletionProvider {
extraCompletions.push({
...item,
...{
label: `${normalizeToAngleBracketComponent(r.root)}$${item.label}`,
label: `${normalizeToAngleBracketComponent(r.name)}$${item.label}`,
},
});
});
Expand Down
99 changes: 97 additions & 2 deletions test/__snapshots__/batman-fixture-based-integration-test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,100 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`With \`batman project\` initialized on server Completion request returns all angle-bracket components with same name from different namespaces 1`] = `
Array [
Object {
"detail": "component",
"kind": 7,
"label": "AnotherAwesomeComponent",
"textEdit": Object {
"newText": "AnotherAwesomeComponent",
"range": Object {
"end": Object {
"character": 1,
"line": 0,
},
"start": Object {
"character": 1,
"line": 0,
},
},
},
},
Object {
"detail": "component",
"kind": 7,
"label": "MyAwesomeComponent",
"textEdit": Object {
"newText": "MyAwesomeComponent",
"range": Object {
"end": Object {
"character": 1,
"line": 0,
},
"start": Object {
"character": 1,
"line": 0,
},
},
},
},
Object {
"detail": "component",
"kind": 7,
"label": "Nested::NestedComponent",
"textEdit": Object {
"newText": "Nested::NestedComponent",
"range": Object {
"end": Object {
"character": 1,
"line": 0,
},
"start": Object {
"character": 1,
"line": 0,
},
},
},
},
Object {
"detail": "component",
"kind": 7,
"label": "Boo$Bar",
"textEdit": Object {
"newText": "Boo$Bar",
"range": Object {
"end": Object {
"character": 1,
"line": 0,
},
"start": Object {
"character": 1,
"line": 0,
},
},
},
},
Object {
"detail": "component",
"kind": 7,
"label": "Foo$Bar",
"textEdit": Object {
"newText": "Foo$Bar",
"range": Object {
"end": Object {
"character": 1,
"line": 0,
},
"start": Object {
"character": 1,
"line": 0,
},
},
},
},
]
`;

exports[`With \`batman project\` initialized on server Completion request returns all angle-bracket in a element expression for in repo addons with batman syntax 1`] = `
Array [
Object {
Expand Down Expand Up @@ -36,7 +131,7 @@ Array [
"line": 0,
},
},
"uri": "/lib/foo/addon/templates/components/bar.hbs",
"uri": "/lib/boo/addon/templates/components/bar.hbs",
},
]
`;
Expand All @@ -54,7 +149,7 @@ Array [
"line": 0,
},
},
"uri": "/lib/foo/app/components/bar.js",
"uri": "/lib/foo/addon/components/bar.js",
},
]
`;
19 changes: 19 additions & 0 deletions test/batman-fixture-based-integration-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,25 @@ describe('With `batman project` initialized on server', () => {

expect(response).toMatchSnapshot();
});

it('returns all angle-bracket components with same name from different namespaces', async () => {
const applicationTemplatePath = path.join(__dirname, 'fixtures', 'batman', 'app', 'templates', 'same-component-name.hbs');
const params = {
textDocument: {
uri: URI.file(applicationTemplatePath).toString(),
},
position: {
line: 0,
character: 1,
},
};

openFile(connection, applicationTemplatePath);

const response = await connection.sendRequest(CompletionRequest.method, params);

expect(response).toMatchSnapshot();
});
});

describe('Definition request', () => {
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/batman/app/templates/same-component-name.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<
Empty file.

0 comments on commit 224ea21

Please # to comment.