-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.spec.ts
41 lines (29 loc) · 1.14 KB
/
database.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import {TestBed, inject} from "@angular/core/testing";
import {HttpModule} from "@angular/http";
import {SelfbitsDatabase} from "../src/services/database";
import {TESTCONFIG, TESTHEADERS, TESTURL} from "./helpers";
import {SELFBITS_CONFIG} from "../src/utils/tokens";
describe('database.ts', ()=>{
beforeEach(()=>{
TestBed.configureTestingModule({
providers:[
SelfbitsDatabase,
{ provide: SELFBITS_CONFIG, useValue:TESTCONFIG}
],
imports:[HttpModule]
})
});
it('should load with config data injected',inject([SelfbitsDatabase],(database:any)=>{
expect(database.config).toEqual(TESTCONFIG);
expect(database.headers).toEqual(TESTHEADERS);
expect(database.dbBaseUrl).toEqual(`${TESTURL}/api/v1/db/m`);
}));
it('databaseSchema() should create new http instance', inject([SelfbitsDatabase],(database:SelfbitsDatabase)=>{
let testDb = database.databaseSchema('test');
expect(typeof testDb.post).toEqual('function');
expect(typeof testDb.get).toEqual('function');
expect(typeof testDb.query).toEqual('function');
expect(typeof testDb.delete).toEqual('function');
expect(typeof testDb.put).toEqual('function');
}))
});