Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const mockArray: Array<Book> = [
- {
- id: 1,
- title: 'Harry Potter i Komnata Tajemnic',
- author: 'JK Rowling',
- description: 'Harry Potter and the Chamber of Secrets begins',
- isbn: '978-0-32-004843-2',
- category: Categories.FANTASY,
- publicationDate: new Date(),
- publisher: 'Bloomsbury',
- rentDate: new Date(),
- coverImg: 'https://7.allegroimg.com/original/1244a0/225af28542fd9e52774594e45937',
- availability: true,
- addDate: new Date(),
- renterEmail: '',
- returnDate: new Date(),
- },
- {
- id: 2,
- title: 'Selfish gene',
- author: 'Richard Dawkins',
- description: 'Inheriting the mantle of revolutionary biologist from Darwin, Watson, and Crick',
- isbn: '978-8-53-190188-1',
- category: Categories.SCIENCE,
- publicationDate: new Date(),
- publisher: 'Proszynski',
- rentDate: new Date(),
- coverImg: 'https://images-na.ssl-images-amazon.com/images/I/51Vc-rvnKYL._SX321_BO1,204,203,200_.jpg',
- availability: true,
- addDate: new Date(),
- renterEmail: '',
- returnDate: new Date(),
- },
- {
- id: 3,
- title: 'Solaris',
- author: 'Stanislaw Lem',
- description: 'Solaris is a wonderful book, about a few scientists on a lab hovering over a vast, mysterious ocean on an alien planet.',
- isbn: '978-8-68-456901-3',
- category: Categories.FANTASY,
- publicationDate: new Date(),
- publisher: 'Amanda',
- rentDate: new Date(),
- returnDate: new Date(),
- renterEmail: 'chico@gmail.com',
- coverImg: 'http://s.lubimyczytac.pl/upload/books/133000/133717/352x500.jpg',
- availability: true,
- addDate: new Date(),
- },
- {
- id: 4,
- title: 'Java dla zielonych',
- author: 'Adrian Buller',
- description: 'Do you want to know how to make your tests green? Master many to many?',
- isbn: '978-7-11-521048-7',
- category: Categories.SCIENCE,
- publicationDate: new Date(),
- publisher: 'ABlej',
- rentDate: new Date(),
- returnDate: new Date(),
- coverImg: 'https://images-na.ssl-images-amazon.com/images/I/71r9cLugLKL.jpg',
- availability: true,
- addDate: new Date(),
- renterEmail: 'anka@wp.pl',
- },
- {
- id: 5,
- title: 'Interwencje',
- author: 'Noam Chomsky',
- description: 'Punchy essays attack Americas international role under George W Bush.',
- isbn: '978-0-24-114386-5',
- category: Categories.SCIENCE,
- publicationDate: new Date(),
- publisher: 'ABlej',
- rentDate: new Date(),
- coverImg: 'https://upload.wikimedia.org/wikipedia/en/thumb/5/52/Interventions.jpg/220px-Interventions.jpg',
- availability: true,
- addDate: new Date(),
- renterEmail: '',
- returnDate: new Date(),
- },
- {
- id: 6,
- title: 'Co do grosza',
- author: 'Jeffrey Archer',
- description: 'The conned: an Oxford don, a revered society physician',
- isbn: '978-8-37-180475-5',
- category: Categories.NOVEL,
- publicationDate: new Date(),
- publisher: 'Gentles',
- rentDate: new Date(),
- returnDate: new Date(),
- renterEmail: 'anna@wp.com',
- coverImg: 'https://s.znak.com.pl//files/covers/card/f1/T195254.jpg',
- availability: true,
- addDate: new Date(),
- },
- {
- id: 7,
- title: 'Harry Potter i Czara Ognia',
- author: 'JK Rowling',
- description: 'Harry Potter is midway through his training as a wizard',
- isbn: '978-9-18-887751-2',
- category: Categories.FANTASY,
- publicationDate: new Date(),
- publisher: 'Bloomsbery',
- rentDate: new Date(),
- returnDate: new Date(),
- renterEmail: 'hp@onet.pl',
- coverImg: 'https://images.booksense.com/images/595/139/9780439139595.jpg',
- availability: true,
- addDate: new Date(),
- },
- {
- id: 8,
- title: 'Zbrodnia i kara',
- author: 'Fiodor Dostojewski',
- description: 'Crime and Punishment focuses on the mental anguish and moral dilemmas',
- isbn: '978-8-94-520545-2',
- category: Categories.NOVEL,
- publicationDate: new Date(),
- publisher: 'Kindenberg',
- rentDate: new Date(),
- renterEmail: 'kot@gmail.com',
- coverImg: 'https://images-na.ssl-images-amazon.com/images/I/41cQTFV5hPL.jpg',
- availability: false,
- addDate: new Date(),
- returnDate: new Date(),
- },
- {
- id: 9,
- title: 'Morderstwo na plebanii',
- author: 'Agatha Christie',
- description: 'In St. Mary Mead, no one is more despised than Colonel',
- isbn: '978-9-63-079215-8',
- category: Categories.NOVEL,
- publicationDate: new Date(),
- publisher: 'Collins Crime',
- rentDate: new Date(),
- returnDate: new Date(),
- renterEmail: 'ac@interia.pl',
- coverImg: 'http://s.lubimyczytac.pl/upload/books/269000/269714/422646-352x500.jpg',
- availability: true,
- addDate: new Date(),
- },
- {
- id: 10,
- title: 'Tajemnicza historia w Styles',
- author: 'Agatha Christie',
- description: 'One morning at Styles Court, an Essex country manor',
- isbn: '978-1-72-183293-4',
- category: Categories.NOVEL,
- publicationDate: new Date(),
- publisher: 'Collins Crime',
- rentDate: new Date(),
- returnDate: new Date(),
- renterEmail: 'ac@interia.pl',
- coverImg: 'http://ecsmedia.pl/c/tajemnicza-historia-w-styles-w-iext37523258.jpg',
- availability: true,
- addDate: new Date(),
- },
- {
- id: 11,
- title: 'Więźniowie geografii',
- author: 'Tim Marshall',
- description: 'Ten Maps That Tell You Everything You Need to Know About Global Politics.',
- isbn: '978-8-81-114792-3',
- category: Categories.SCIENCE,
- publicationDate: new Date(),
- publisher: 'Elliot',
- rentDate: new Date(),
- returnDate: new Date(),
- renterEmail: 'pojaj@gmail.com',
- coverImg: 'http://s.lubimyczytac.pl/upload/books/4367000/4367313/554065-352x500.jpg',
- availability: false,
- addDate: new Date(),
- },
- {
- id: 12,
- title: 'Więźniowie geografii',
- author: 'Tim Marshall',
- description: 'Ten Maps That Tell You Everything You Need to Know About Global Politics.',
- isbn: '978-8-81-114792-3',
- category: Categories.SCIENCE,
- publicationDate: new Date(),
- publisher: 'Elliot',
- rentDate: new Date(),
- coverImg: 'http://s.lubimyczytac.pl/upload/books/4367000/4367313/554065-352x500.jpg',
- availability: true,
- addDate: new Date(),
- renterEmail: '',
- returnDate: new Date()
- }
- ];
- let service: BooksService;
- let httpClient: HttpTestingController;
- let injector: TestBed;
- describe('BooksService', () => {
- beforeEach(async () =>
- TestBed.configureTestingModule({
- imports: [HttpClientTestingModule]
- })
- );
- beforeEach(() => {
- injector = getTestBed();
- httpClient = injector.get(HttpTestingController);
- service = TestBed.get(BooksService);
- });
- it('should be created', () => {
- expect(service).toBeTruthy();
- });
- it('should search books', () => {
- const text = 'har';
- let searchedBooks: Array<Book>;
- spyOn(service, 'getBooks').and.returnValue(of(mockArray));
- service.searchBooks(text).subscribe(books => (searchedBooks = books));
- expect(searchedBooks.length).toBe(3);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement