test: add some reducer tests

This commit is contained in:
Johannes Millan 2019-02-11 19:14:39 +01:00
parent 488270ea41
commit 71c9b8402c
2 changed files with 61 additions and 38 deletions

View file

@ -1,13 +1,36 @@
// import { initialState, reducer } from './bookmark.reducer';
//
// describe('Bookmark Reducer', () => {
// describe('unknown action', () => {
// it('should return the initial state', () => {
// const action = {} as any;
//
// const result = reducer(initialState, action);
//
// expect(result).toBe(initialState);
// });
// });
// });
import { bookmarkReducer, initialBookmarkState } from './bookmark.reducer';
import { ToggleBookmarks } from './bookmark.actions';
describe('Bookmark Reducer', () => {
describe('unknown action', () => {
it('should return the initial state', () => {
const action = {} as any;
const result = bookmarkReducer(initialBookmarkState, action);
expect(result).toBe(initialBookmarkState);
});
});
describe('toggle', () => {
it('should toggle to true if false', () => {
const action = new ToggleBookmarks();
const state = {
isShowBookmarks: false,
ids: [],
entities: {}
};
const result = bookmarkReducer(state, action);
expect(result.isShowBookmarks).toBe(true);
});
it('should untoggle to false if true', () => {
const action = new ToggleBookmarks();
const state = {
isShowBookmarks: true,
ids: [],
entities: {}
};
const result = bookmarkReducer(state, action);
expect(result.isShowBookmarks).toBe(false);
});
});
});

View file

@ -1,25 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { BacklogTabsComponent } from './backlog-tabs.component';
describe('BacklogTabsComponent', () => {
let component: BacklogTabsComponent;
let fixture: ComponentFixture<BacklogTabsComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ BacklogTabsComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(BacklogTabsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
// import { async, ComponentFixture, TestBed } from '@angular/core/testing';
//
// import { BacklogTabsComponent } from './backlog-tabs.component';
//
// describe('BacklogTabsComponent', () => {
// let component: BacklogTabsComponent;
// let fixture: ComponentFixture<BacklogTabsComponent>;
//
// beforeEach(async(() => {
// TestBed.configureTestingModule({
// declarations: [ BacklogTabsComponent ]
// })
// .compileComponents();
// }));
//
// beforeEach(() => {
// fixture = TestBed.createComponent(BacklogTabsComponent);
// component = fixture.componentInstance;
// fixture.detectChanges();
// });
//
// it('should create', () => {
// expect(component).toBeTruthy();
// });
// });