Commit 002efdd5 authored by Tifenn Guillas's avatar Tifenn Guillas
Browse files

Change test command => DONE, WIP: add services tests

parent 7660f3e8
......@@ -35,7 +35,7 @@ test:
- wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
- apt-get update
- apt-get install -y google-chrome-stable
- ng test
- ng test --no-watch
cache:
paths:
- dist
......
......@@ -39,12 +39,7 @@ stop:
restart: stop start
test:
rm -rf ./coverage
@docker build -t anis-node conf-dev && docker run --init -it --rm --user $(UID):$(GID) \
--name anis-client \
-p 9876:9876 \
-v $(CURDIR):/project -d \
-w /project anis-node ng test --code-coverage
@docker exec -ti anis-client ng test --no-watch
ng-build:
@docker build -t anis-node conf-dev && docker run --init -it --rm --user $(UID):$(GID) \
......
......@@ -81,6 +81,7 @@
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"codeCoverageExclude": ["node_modules/**", ""],
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
......
......@@ -32,6 +32,7 @@ module.exports = function (config) {
flags: ['--no-sandbox'],
}
},
singleRun: true,
autoWatch: true,
singleRun: false
});
};
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { NotFoundPageComponent } from './not-found-page.component';
describe('NotFoundPageComponent', () => {
let component: NotFoundPageComponent;
let fixture: ComponentFixture<NotFoundPageComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ NotFoundPageComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(NotFoundPageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { SearchService } from './search.service';
import { HttpErrorResponse } from '@angular/common/http';
describe('SearchService', () => {
let searchService: SearchService;
let httpClientSpy: { get: jasmine.Spy };
beforeEach(() => {
httpClientSpy = jasmine.createSpyObj('HttpClient', ['get']);
searchService = new SearchService(httpClientSpy as any);
});
it('should return an error when the server returns a 404', () => {
const errorResponse = new HttpErrorResponse({
error: 'test 404 error',
status: 404, statusText: 'Not Found'
});
httpClientSpy.get.and.returnValue(errorResponse);
searchService.retrieveMeta('obs_cat?a=1;2;3').subscribe(
meta => fail('expected an error, not metadata'),
error => expect(error.message).toContain('test 404 error')
);
});
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment