Skip to content

Commit

Permalink
fix autofixable problems
Browse files Browse the repository at this point in the history
  • Loading branch information
flotwig committed Feb 1, 2023
1 parent 2dddd92 commit eafaf03
Show file tree
Hide file tree
Showing 143 changed files with 8,714 additions and 8,749 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ declare global {
}
}


Cypress.Commands.add('mount', mount);
Cypress.Commands.add('mount', mount)
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import { take } from 'rxjs/operators'
@Component({
selector: 'app-another-child',
template: `<button (click)="handleClick()">{{ message }}</button>`,
providers: [ChildProvidersService]
providers: [ChildProvidersService],
})
export class AnotherChildProvidersComponent {
message = 'default another child message'

constructor(private readonly service: ChildProvidersService) {}
constructor (private readonly service: ChildProvidersService) {}

handleClick(): void {
handleClick (): void {
this.service.getMessage().pipe(
take(1)
take(1),
).subscribe((message) => this.message = message)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Component, EventEmitter, Output } from "@angular/core";
import { Component, EventEmitter, Output } from '@angular/core'

@Component({
selector: 'app-button-output',
template: `<button (click)="clicked.emit(true)">Click Me</button>`
template: `<button (click)="clicked.emit(true)">Click Me</button>`,
})
export class ButtonOutputComponent {
@Output() clicked: EventEmitter<boolean> = new EventEmitter()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import { take } from 'rxjs/operators'

@Component({
selector: 'app-child-providers',
template: `<button (click)="handleClick()">{{ message }}</button>`
template: `<button (click)="handleClick()">{{ message }}</button>`,
})
export class ChildProvidersComponent {
message = 'default message'

constructor(private readonly service: ChildProvidersService) {}
constructor (private readonly service: ChildProvidersService) {}

handleClick(): void {
handleClick (): void {
this.service.getMessage().pipe(
take(1)
).subscribe(message => this.message = message)
take(1),
).subscribe((message) => this.message = message)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { map } from 'rxjs/operators'

@Injectable()
export class ChildProvidersService {
constructor(private readonly http: HttpClient) {}
constructor (private readonly http: HttpClient) {}

getMessage(): Observable<string> {
getMessage (): Observable<string> {
return this.http.get<{ message: string }>('https://myfakeapiurl.com/api/message').pipe(
map((response) => response.message)
map((response) => response.message),
)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Component, Input } from "@angular/core";
import { Component, Input } from '@angular/core'

@Component({
selector: "child-component",
template: "<h1>{{msg}}</h1>",
selector: 'child-component',
template: '<h1>{{msg}}</h1>',
})
export class ChildComponent {
@Input() msg!: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { Component } from "@angular/core";
import { CounterService } from "./counter.service";
import { Component } from '@angular/core'
import { CounterService } from './counter.service'

@Component({
selector: "counter-component",
selector: 'counter-component',
template: `<button (click)="increment()">
Increment: {{ count$ | async }}
</button>`,
})
export class CounterComponent {
count$ = this.counterService.count$;

constructor(private counterService: CounterService) {}
constructor (private counterService: CounterService) {}

increment() {
this.counterService.increment();
increment () {
this.counterService.increment()
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Injectable } from "@angular/core";
import { BehaviorSubject } from "rxjs";
import { Injectable } from '@angular/core'
import { BehaviorSubject } from 'rxjs'

@Injectable()
export class CounterService {
private count = new BehaviorSubject<number>(0);
public count$ = this.count.asObservable();

public increment() {
this.count.next(this.count.value + 1);
public increment () {
this.count.next(this.count.value + 1)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, Input } from "@angular/core";
import { Component, Input } from '@angular/core'

@Component({
selector: "errors-component",
selector: 'errors-component',
template: `<div>
<button id="sync-error" (click)="syncError()">Sync Error</button>
<button id="async-error" (click)="asyncError()">Sync Error</button>
Expand All @@ -10,11 +10,11 @@ import { Component, Input } from "@angular/core";
export class ErrorsComponent {
@Input() throwError!: boolean;

syncError() {
syncError () {
throw new Error('sync error')
}

asyncError() {
asyncError () {
setTimeout(() => {
throw new Error('async error')
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ import { Component, Input, OnInit, OnChanges, SimpleChanges } from '@angular/cor

@Component({
selector: 'app-lifecycle',
template: `<p>Hi {{ name }}. ngOnInit fired: {{ ngOnInitFired }} and ngOnChanges fired: {{ ngOnChangesFired }} and conditionalName: {{ conditionalName }}</p>`
template: `<p>Hi {{ name }}. ngOnInit fired: {{ ngOnInitFired }} and ngOnChanges fired: {{ ngOnChangesFired }} and conditionalName: {{ conditionalName }}</p>`,
})
export class LifecycleComponent implements OnInit, OnChanges {
@Input() name = ''
ngOnInitFired = false
ngOnChangesFired = false
conditionalName = false

ngOnInit(): void {
ngOnInit (): void {
this.ngOnInitFired = true
}
ngOnChanges(changes: SimpleChanges): void {
this.ngOnChangesFired = true;

ngOnChanges (changes: SimpleChanges): void {
this.ngOnChangesFired = true
if (changes['name'].currentValue === 'CONDITIONAL NAME') {
this.conditionalName = true
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component } from "@angular/core";
import { Component } from '@angular/core'

@Component({
selector: 'app-logo',
template: `<img src="assets/cypress-logo-light.png" />`
template: `<img src="assets/cypress-logo-light.png" />`,
})
export class LogoComponent {}
export class LogoComponent {}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import { ChildComponent } from './child.component'

@NgModule({
declarations: [ParentComponent, ChildComponent],
}) export class ParentChildModule {}
}) export class ParentChildModule {}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Component } from '@angular/core';
import { Component } from '@angular/core'

@Component({
template: `
<app-child-providers></app-child-providers>
<app-another-child></app-another-child>`
<app-another-child></app-another-child>`,
})
export class ParentProvidersComponent {}
export class ParentProvidersComponent {}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Component } from "@angular/core";
import { Component } from '@angular/core'

@Component({
selector: "parent-component",
selector: 'parent-component',
template: '<child-component [msg]="msg"></child-component>',
})
export class ParentComponent {
msg = "Hello World from ParentComponent";
msg = 'Hello World from ParentComponent';
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { Component } from '@angular/core'

@Component({
selector: 'app-projection',
template: `<h3><ng-content></ng-content></h3>`
template: `<h3><ng-content></ng-content></h3>`,
})
export class ProjectionComponent {}
export class ProjectionComponent {}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component } from "@angular/core";
import { Component } from '@angular/core'

@Component({
selector: "with-directives-component",
selector: 'with-directives-component',
template: ` <button (click)="show = !show">Toggle Message</button>
<ul *ngIf="show">
<li *ngFor="let item of items">{{ item }}</li>
Expand All @@ -10,5 +10,5 @@ import { Component } from "@angular/core";
export class WithDirectivesComponent {
show = true;

items = ["breakfast", "lunch", "dinner"];
items = ['breakfast', 'lunch', 'dinner'];
}
3 changes: 1 addition & 2 deletions system-tests/project-fixtures/angular/src/app/errors.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ErrorsComponent } from './components/errors'

describe('Errors', () => {

it('error on mount', () => {
cy.mount(ErrorsComponent, { componentProperties: { throwError: true } })
})
Expand All @@ -20,4 +19,4 @@ describe('Errors', () => {
cy.mount(ErrorsComponent)
cy.get('element-that-does-not-exist')
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('only', () => {

it(ExcludedTestTitle, () => {})
})

describe('describe', () => {
describe.only('should exist on "describe"', () => {
it('succeeds', () => {})
Expand Down Expand Up @@ -48,19 +48,19 @@ describe('only', () => {

context.only('02 - validations', () => {
const verifyNotPresent = (title: string) => {
cy.wrap(Cypress.$(window.top!.document.body)).within(() =>
cy
.contains(title)
.should('not.exist')
)
cy.wrap(Cypress.$(window.top!.document.body)).within(() => {
return cy
.contains(title)
.should('not.exist')
})
}

describe('suite', () => {
it('should not include other test', () => {
verifyNotPresent(ExcludedTestTitle)
})
})

describe('describe', () => {
it('should not include other test', () => {
verifyNotPresent(ExcludedTestTitle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('skip', () => {
it('skipped', () => {})
})
})

describe('describe', () => {
describe.skip('should exist on "describe"', () => {
it('skipped', () => {})
Expand Down Expand Up @@ -37,12 +37,12 @@ describe('skip', () => {

context('02 - validations', () => {
const verifyWasSkipped = (title: string) => {
cy.wrap(Cypress.$(window.top!.document.body)).within(() =>
cy
.contains(title)
.parents('[data-model-state="pending"]') // Find parent row with class indicating test was skipped
.should('be.visible')
)
cy.wrap(Cypress.$(window.top!.document.body)).within(() => {
return cy
.contains(title)
.parents('[data-model-state="pending"]') // Find parent row with class indicating test was skipped
.should('be.visible')
})
}

describe('suite', () => {
Expand Down
16 changes: 10 additions & 6 deletions system-tests/project-fixtures/next/cypress/Errors.cy.jsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
import React from 'react'
import { mount } from "cypress/react"
import { mount } from 'cypress/react'

describe('Errors', () => {

const Errors = (props) => {
if (props.throwError) throw new Error('mount error')

return (
<div>
<button
id="sync-error"
onClick={() => { throw new Error('sync error') }}
onClick={() => {
throw new Error('sync error')
}}
>
Sync Error
</button>
<button
id="async-error"
onClick={() => {
setTimeout(() => { throw new Error('async error') }, 50)
setTimeout(() => {
throw new Error('async error')
}, 50)
}}
>
Async Error
</button>
</div>
);
)
}

it('error on mount', () => {
Expand All @@ -43,4 +47,4 @@ describe('Errors', () => {
mount(<Errors />)
cy.get('element-that-does-not-exist')
})
})
})
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Importing global styles fails with Next.js due to restrictions on style imports.
// We modify the Next Webpack config to allow importing global styles.
import '../../styles/globals.css'
import '../../styles/Home.module.css'
import '../../styles/Home.module.css'
Loading

0 comments on commit eafaf03

Please sign in to comment.