Skip to content

test(schematics): add test-case for attribute selectors data #12728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/lib/schematics/update/test-cases/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ describe('test cases', () => {
* a developers application.
*/
const testCases = [
'v5/ts-class-names'
'v5/attribute-selectors',
'v5/ts-class-names',
];

// Iterates through every test case directory and generates a jasmine test block that will
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {Component} from '@angular/core';
import {By} from '@angular/platform-browser';

const a = By.css('[cdkPortalOutlet]');
const b = By.css('[cdkPortalOutlet]');

// These should not change because we only update string literals that are
// inside of a call expression.
const c = 'cdkPortalHost';
const d = 'portalHost';

@Component({
template: `
<div cdkPortalOutlet="E"></div>
<div [cdkPortalOutlet]="myPortal"></div>
`,
styles: [
'[cdkPortalOutlet] {background: red}',
'div[cdkPortalOutlet] {color: blue}'
]
})
class E {}

@Component({
template: `
<div cdkPortalOutlet="F"></div>
<div [cdkPortalOutlet]="myPortal"></div>
`,
styles: [
'[cdkPortalOutlet] {background: red}',
Copy link
Member Author

@devversion devversion Aug 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While creating this test-case I've started wondering if this actually makes sense.

Even though the cdkPortalOutlet is usually placed on a <ng-template> and such CSS selectors do not make sense, we want to make sure that the rule logic works.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine

'div[cdkPortalOutlet] {color: blue}'
]
})
class F {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {Component} from '@angular/core';
import {By} from '@angular/platform-browser';

const a = By.css('[cdkPortalHost]');
const b = By.css('[portalHost]');

// These should not change because we only update string literals that are
// inside of a call expression.
const c = 'cdkPortalHost';
const d = 'portalHost';

@Component({
template: `
<div cdkPortalHost="E"></div>
<div [cdkPortalHost]="myPortal"></div>
`,
styles: [
'[cdkPortalHost] {background: red}',
'div[cdkPortalHost] {color: blue}'
]
})
class E {}

@Component({
template: `
<div portalHost="F"></div>
<div [portalHost]="myPortal"></div>
`,
styles: [
'[portalHost] {background: red}',
'div[portalHost] {color: blue}'
]
})
class F {}
2 changes: 1 addition & 1 deletion tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
}, "src/+(lib|cdk|material-experimental|cdk-experimental)/**/!(*.spec).ts"],
"require-license-banner": [
true,
"src/+(lib|cdk|material-experimental|cdk-experimental|demo-app)/**/!(*.spec|*.fixture).ts"
"src/+(lib|cdk|material-experimental|cdk-experimental|demo-app)/**/!(*.spec).ts"
],
"missing-rollup-globals": [
true,
Expand Down