Skip to content

Instantly share code, notes, and snippets.

💭
💻 🐵

Catalin Ciubotaru FunnyGhost

💭
💻 🐵
Block or report user

Report or block FunnyGhost

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View passing-test.js
it('should add the values', () => {
const result = addValues(2, 4);
expect(result).toBe(6);
});
let addValues = (value1, value2) {
return value1 + value2;
}
View show-all-movies-test.js
it('show all the favorite movies', () => {
const movieElements = fixture.debugElement.queryAll(By.css('.movie'));
expect(movieElements.length).toBe(favoriteMoviesToUse.length);
});
View favorite-movies.component.spec.ts
describe('Render', () => {
beforeEach(() => {
fixture.detectChanges();
});
it('should have a title', () => {
const titleElements = fixture.debugElement.queryAll(By.css('h1'));
expect(titleElements.length).toBe(1);
expect(titleElements[0].nativeElement.innerHTML).toBe('Favorite movies');
View favorite-movies.component.html
<div class="movie" *ngFor="let movie of favoriteMovies">
{{ movie.title }}
</div>
View favorite-movies.component.spec.ts
const favoriteMoviesToUse: Movie[] = [
{ title: 'Interstellar' } as Movie,
{ title: 'The big Lebowski' } as Movie,
{ title: 'Borat' } as Movie
];
describe('FavoriteMoviesComponent', () => {
let component: FavoriteMoviesComponent;
let fixture: ComponentFixture<FavoriteMoviesComponent>;
let favoriteMovieService: FavoriteMoviesService;
View favorite-movies.component.ts
@Component({
selector: 'app-favorite-movies',
templateUrl: './favorite-movies.component.html',
styleUrls: ['./favorite-movies.component.scss']
})
export class FavoriteMoviesComponent implements OnInit {
favoriteMovies$: Observable<Movie[]>;
error: string;
constructor(private favoriteMovieService: FavoriteMoviesService) {}
View favorite-movies.component.html
<h1>Favorite movies</h1>
<ng-container *ngIf="(favoriteMovies$ | async); let favoriteMovies">
<div class="movie" *ngFor="let movie of favoriteMovies">
{{ movie.title }}
</div>
</ng-container>
<div class="error" *ngIf="error">
{{ error }}
View favorite-movies.component.ts
export class FavoriteMoviesComponent implements OnInit {
favoriteMovies$: Observable<Movie[]>;
constructor(private favoriteMovieService: FavoriteMoviesService) {}
ngOnInit() {
this.favoriteMovies$ = this.favoriteMovieService.getFavoriteMovies();
}
}
View favorite-movies.component.html
<ng-container *ngIf="(favoriteMovies$ | async); let favoriteMovies">
<div class="movie" *ngFor="let movie of favoriteMovies">
{{ movie.title }}
</div>
</ng-container>
You can’t perform that action at this time.