refactor: move contact servicesto services folder
This commit is contained in:
@@ -3,7 +3,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ContactListTable } from './contact-list-table';
|
||||
import { STRINGS_INJECTOR } from '../../app.config';
|
||||
import { strings } from '../../strings';
|
||||
import { ContactService } from '../../pages/main/contact.service';
|
||||
import { ContactService } from '../../services/contact.service';
|
||||
import { ContactDTO } from '../../models/ContactDTO';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Component, inject, input } from '@angular/core';
|
||||
import { STRINGS_INJECTOR } from '../../app.config';
|
||||
import { ContactDTO } from '../../models/ContactDTO';
|
||||
import { ContactActionsBar } from '../contact-actions-bar/contact-actions-bar';
|
||||
import { ContactService } from '../../pages/main/contact.service';
|
||||
import { ContactService } from '../../services/contact.service';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ContactList } from './contact-list';
|
||||
import { ContactService } from '../../pages/main/contact.service';
|
||||
import { ContactService } from '../../services/contact.service';
|
||||
import { of } from 'rxjs';
|
||||
import { STRINGS_INJECTOR } from '../../app.config';
|
||||
import { strings } from '../../strings';
|
||||
|
||||
@@ -1,21 +1,27 @@
|
||||
import { Component, inject, OnInit } from '@angular/core';
|
||||
import { STRINGS_INJECTOR } from '../../app.config';
|
||||
import { UpperfirstPipe } from "../../pipes/upperfirst-pipe";
|
||||
import { ContactSearchBar } from "../contact-search-bar/contact-search-bar";
|
||||
import { ContactListTable } from "../contact-list-table/contact-list-table";
|
||||
import { ContactService } from '../../pages/main/contact.service';
|
||||
import { UpperfirstPipe } from '../../pipes/upperfirst-pipe';
|
||||
import { ContactSearchBar } from '../contact-search-bar/contact-search-bar';
|
||||
import { ContactListTable } from '../contact-list-table/contact-list-table';
|
||||
import { ContactService } from '../../services/contact.service';
|
||||
import { AsyncPipe } from '@angular/common';
|
||||
import { Counter } from "../counter/counter";
|
||||
import { ContactsFilterPipe } from "../../pipes/contacts-filter-pipe";
|
||||
import { Counter } from '../counter/counter';
|
||||
import { ContactsFilterPipe } from '../../pipes/contacts-filter-pipe';
|
||||
|
||||
@Component({
|
||||
selector: 'app-contact-list',
|
||||
imports: [AsyncPipe, UpperfirstPipe, ContactSearchBar, ContactListTable, Counter, ContactsFilterPipe],
|
||||
imports: [
|
||||
AsyncPipe,
|
||||
UpperfirstPipe,
|
||||
ContactSearchBar,
|
||||
ContactListTable,
|
||||
Counter,
|
||||
ContactsFilterPipe,
|
||||
],
|
||||
templateUrl: './contact-list.html',
|
||||
styleUrl: './contact-list.scss',
|
||||
})
|
||||
export class ContactList implements OnInit {
|
||||
|
||||
private readonly contactService = inject(ContactService);
|
||||
protected readonly strings = inject(STRINGS_INJECTOR);
|
||||
protected contacts$ = this.contactService.contacts$;
|
||||
@@ -24,5 +30,4 @@ export class ContactList implements OnInit{
|
||||
ngOnInit(): void {
|
||||
this.contactService.getAll().subscribe();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { inject } from '@angular/core';
|
||||
import { ResolveFn, Router } from '@angular/router';
|
||||
import { ContactService } from '../main/contact.service';
|
||||
import { ContactService } from '../../services/contact.service';
|
||||
import { ContactDTO } from '../../models/ContactDTO';
|
||||
import { catchError, map, Observable, of } from 'rxjs';
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Edit } from './edit';
|
||||
import { STRINGS_INJECTOR } from '../../app.config';
|
||||
import { strings } from '../../strings';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { ContactService } from '../main/contact.service';
|
||||
import { ContactService } from '../../services/contact.service';
|
||||
import { of } from 'rxjs';
|
||||
import { ContactDTO } from '../../models/ContactDTO';
|
||||
import { By } from '@angular/platform-browser';
|
||||
|
||||
@@ -11,7 +11,7 @@ import { map, Observable, take, tap } from 'rxjs';
|
||||
import { ContactDTO } from '../../models/ContactDTO';
|
||||
import { FormGroupContact } from '../../utils/form-group-contact';
|
||||
import { AsyncPipe } from '@angular/common';
|
||||
import { ContactService } from '../main/contact.service';
|
||||
import { ContactService } from '../../services/contact.service';
|
||||
import { ContactFormValue } from '../../types/ContactFormValue.type';
|
||||
|
||||
@Component({
|
||||
|
||||
@@ -3,7 +3,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { Main } from './main';
|
||||
import { STRINGS_INJECTOR } from '../../app.config';
|
||||
import { strings } from '../../strings';
|
||||
import { ContactService } from './contact.service';
|
||||
import { ContactService } from '../../services/contact.service';
|
||||
import { ContactList } from '../../components/contact-list/contact-list';
|
||||
import { of } from 'rxjs';
|
||||
import { ContactDTO } from '../../models/ContactDTO';
|
||||
@@ -22,7 +22,7 @@ describe('Main', () => {
|
||||
imports: [Main],
|
||||
providers: [
|
||||
{ provide: STRINGS_INJECTOR, useValue: strings },
|
||||
{ provide: ContactService, useValue: contactService }
|
||||
{ provide: ContactService, useValue: contactService },
|
||||
],
|
||||
}).compileComponents();
|
||||
fixture = TestBed.createComponent(Main);
|
||||
@@ -37,8 +37,10 @@ describe('Main', () => {
|
||||
it('should call save on contact event', () => {
|
||||
contactService.save.and.returnValue(of([]));
|
||||
const saveSpy = spyOn(component, 'save').and.callThrough();
|
||||
const CONTACT_MOCK = new ContactDTO()
|
||||
const contactForm: ContactForm = fixture.debugElement.query(By.css('app-contact-form')).componentInstance;
|
||||
const CONTACT_MOCK = new ContactDTO();
|
||||
const contactForm: ContactForm = fixture.debugElement.query(
|
||||
By.css('app-contact-form')
|
||||
).componentInstance;
|
||||
contactForm.contact.emit(CONTACT_MOCK);
|
||||
expect(saveSpy).toHaveBeenCalledOnceWith(CONTACT_MOCK);
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Component, inject } from '@angular/core';
|
||||
import { Card } from '../../components/card/card';
|
||||
import { ContactForm } from '../../components/contact-form/contact-form';
|
||||
import { ContactList } from '../../components/contact-list/contact-list';
|
||||
import { ContactService } from './contact.service';
|
||||
import { ContactService } from '../../services/contact.service';
|
||||
import { ContactDTO } from '../../models/ContactDTO';
|
||||
import { FormHeader } from '../../components/form-header/form-header';
|
||||
import { STRINGS_INJECTOR } from '../../app.config';
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { Response } from '../../models/Response';
|
||||
import { Response } from '../models/Response';
|
||||
import { ContactService } from './contact.service';
|
||||
import { provideHttpClient } from '@angular/common/http';
|
||||
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
|
||||
import { environment } from '../../../environments/environment';
|
||||
import { ContactDTO } from '../../models/ContactDTO';
|
||||
import { environment } from '../../environments/environment';
|
||||
import { ContactDTO } from '../models/ContactDTO';
|
||||
|
||||
describe('ContactService', () => {
|
||||
let service: ContactService;
|
||||
@@ -1,8 +1,8 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { inject, Injectable } from '@angular/core';
|
||||
import { environment } from '../../../environments/environment';
|
||||
import { ContactDTO } from '../../models/ContactDTO';
|
||||
import { Response } from '../../models/Response';
|
||||
import { environment } from '../../environments/environment';
|
||||
import { ContactDTO } from '../models/ContactDTO';
|
||||
import { Response } from '../models/Response';
|
||||
import { BehaviorSubject, map, switchMap, tap } from 'rxjs';
|
||||
|
||||
@Injectable({
|
||||
Reference in New Issue
Block a user