Skip to content

Commit

Permalink
[typescript] fix evaluation of angular keyvalue pipe (WEB-51209)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 8913ad5fccf2f066634216cef78cfa4cc1ec9c73
  • Loading branch information
ulitink authored and intellij-monorepo-bot committed May 4, 2022
1 parent 68bd739 commit b7a89a6
Show file tree
Hide file tree
Showing 9 changed files with 17,620 additions and 5 deletions.
22 changes: 17 additions & 5 deletions AngularJS/test/org/angular2/codeInsight/NgForTest.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.angular2.codeInsight;

import com.intellij.codeInsight.completion.CompletionType;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.lang.javascript.BaseJSCompletionTestCase;
import com.intellij.lang.javascript.JSDaemonAnalyzerLightTestCase;
import org.angular2.Angular2CodeInsightFixtureTestCase;
import org.angular2.inspections.Angular2TemplateInspectionsProvider;
import org.angular2.modules.Angular2TestModule;
import org.angularjs.AngularTestUtil;

import java.util.List;
Expand All @@ -13,11 +19,6 @@ protected String getTestDataPath() {
return AngularTestUtil.getBaseTestDataPath(getClass()) + "ngFor";
}

@Override
protected boolean isWriteActionRequired() {
return getTestName(true).contains("Completion");
}

public void testNgFor() {
final List<String> variants = myFixture.getCompletionVariants("NgFor.ts", "ng_for_of.ts", "iterable_differs.ts", "package.json");
assertNotNull(variants);
Expand Down Expand Up @@ -49,4 +50,15 @@ public void testNgForWithinAttributeHTML() {
assertEquals("created_at", variants.get(0));
assertEquals("email", variants.get(1));
}

public void testNgForWithPipe() { // WEB-51209
myFixture.enableInspections(JSDaemonAnalyzerLightTestCase.configureDefaultLocalInspectionTools().toArray(LocalInspectionTool[]::new));
myFixture.configureByFiles("NgForWithPipeHTML.html", "NgForWithPipe.ts", "package.json");
Angular2TestModule.configure(myFixture, false, null, Angular2TestModule.ANGULAR_CORE_13_3_5, Angular2TestModule.ANGULAR_COMMON_13_3_5);
myFixture.checkHighlighting();
myFixture.type('.');
LookupElement[] elements = myFixture.complete(CompletionType.BASIC);
BaseJSCompletionTestCase.assertStartsWith(elements, 2, "key", "value");
assertEquals("string", BaseJSCompletionTestCase.typeText(elements[0]));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {Component} from "@angular/core";

@Component({
selector: 'app-root',
templateUrl: './NgForWithPipeHTML.html',
})
export class AppComponent {
record: Record<string, any> = {"person": {"name": "John", "age": "20"}};
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class="content" role="main">
<div *ngFor="let item of record | keyvalue">
{{item<caret>}}
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"dependencies": {
"@angular/common": "0.0.0",
"@angular/core": "0.0.0"
}
}
2 changes: 2 additions & 0 deletions AngularJS/test/org/angular2/modules/Angular2TestModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ public enum Angular2TestModule {
AGM_CORE_1_0_0_BETA_5("@agm/core", "1.0.0-beta.5"),
ANGULAR_COMMON_4_0_0("@angular/common", "4.0.0"),
ANGULAR_COMMON_8_2_14("@angular/common", "8.2.14"),
ANGULAR_COMMON_13_3_5("@angular/common", "13.3.5"),
ANGULAR_CORE_4_0_0("@angular/core", "4.0.0"),
ANGULAR_CORE_8_2_14("@angular/core", "8.2.14"),
ANGULAR_CORE_9_1_1_MIXED("@angular/core", "9.1.1-mixed"),
ANGULAR_CORE_13_3_5("@angular/core", "13.3.5"),
ANGULAR_FLEX_LAYOUT_13_0_0("@angular/flex-layout", "13.0.0-beta.36"),
ANGULAR_FORMS_4_0_0("@angular/forms", "4.0.0"),
ANGULAR_FORMS_8_2_14("@angular/forms", "8.2.14"),
Expand Down

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b7a89a6

Please sign in to comment.