generated from mchirico/nodeTemplateOld
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
121 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,69 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import {FormsModule, NgForm} from '@angular/forms'; | ||
import { NavbarComponent } from './navbar.component'; | ||
import {async, ComponentFixture, TestBed} from '@angular/core/testing'; | ||
import {FormBuilder, FormsModule} from '@angular/forms'; | ||
import {NavbarComponent} from './navbar.component'; | ||
import {BrowserModule} from '@angular/platform-browser'; | ||
import {AppRoutingModule} from '../../app-routing.module'; | ||
import {DebugElement} from '@angular/core'; | ||
import {SearchService} from '../../service/search.service'; | ||
|
||
|
||
describe('NavbarComponent', () => { | ||
let component: NavbarComponent; | ||
let fixture: ComponentFixture<NavbarComponent>; | ||
let el: DebugElement; | ||
|
||
let getQuoteSpy; | ||
let s; | ||
|
||
beforeEach(async(() => { | ||
|
||
const searchServiceStub = jasmine.createSpyObj('SearchService', ['putTerm', 'getTerms']); | ||
|
||
getQuoteSpy = searchServiceStub.getTerms.and.returnValue(['one']); | ||
|
||
TestBed.configureTestingModule({ | ||
declarations: [ NavbarComponent ], | ||
declarations: [NavbarComponent], | ||
providers: [{provide: SearchService, useValue: searchServiceStub}], | ||
imports: [ | ||
BrowserModule, | ||
FormsModule, | ||
AppRoutingModule | ||
], | ||
}) | ||
.compileComponents(); | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(NavbarComponent); | ||
component = fixture.componentInstance; | ||
// from the root injector | ||
|
||
s = TestBed.inject(SearchService); | ||
el = fixture.nativeElement.querySelector('form'); | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
console.log(el); | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
|
||
it('should call service onSubmit', () => { | ||
|
||
const myModel = { | ||
search0: 'sample data' | ||
}; | ||
const fb = new FormBuilder(); | ||
const form = fb.group(myModel); | ||
component.searchForm.form = form; | ||
fixture.detectChanges(); | ||
|
||
component.onSubmit(); | ||
expect(s.putTerm.calls.count()).toBeGreaterThan(0); | ||
expect(s.getTerms.calls.count()).toBeGreaterThan(0); | ||
|
||
}); | ||
|
||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { BackendService } from './backend.service'; | ||
|
||
describe('BackendService', () => { | ||
let service: BackendService; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({}); | ||
service = TestBed.inject(BackendService); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Injectable } from '@angular/core'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class BackendService { | ||
|
||
constructor() { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { SearchService } from './search.service'; | ||
|
||
describe('SearchService', () => { | ||
let service: SearchService; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({}); | ||
service = TestBed.inject(SearchService); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {Injectable} from '@angular/core'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class SearchService { | ||
private searchTerms: string[] = []; | ||
|
||
constructor() { | ||
console.error('0here'); | ||
} | ||
|
||
putTerm(term: string) { | ||
console.error('here...'); | ||
this.searchTerms.push(term); | ||
} | ||
|
||
getTerms() { | ||
return this.searchTerms; | ||
} | ||
} |