Skip to content
Snippets Groups Projects

Resolve "Continue tests integration"

Merged Tifenn Guillas requested to merge 117-continue-tests-integration into develop
3 files
+ 165
0
Compare changes
  • Side-by-side
  • Inline
Files
3
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
import { provideMockStore, MockStore } from '@ngrx/store/testing';
import { FormsModule } from '@angular/forms';
import { ChangePasswordComponent } from './change-password.component';
import * as fromLogin from '../store/login.reducer';
import * as loginActions from '../store/login.action';
describe('[Search] Container: ChangePasswordComponent', () => {
let component: ChangePasswordComponent;
let fixture: ComponentFixture<ChangePasswordComponent>;
let store: MockStore;
const initialState = {
login: { ...fromLogin.initialState },
};
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ChangePasswordComponent ],
providers: [
provideMockStore({ initialState })
],
imports: [ FormsModule ]
});
fixture = TestBed.createComponent(ChangePasswordComponent);
component = fixture.componentInstance;
store = TestBed.inject(MockStore);
}));
it('should create the component', () => {
expect(component).toBeTruthy();
});
it('#submitted() should dispatch ChangePasswordAction', () => {
component.model.password = 'toto';
component.model.newPassword = 'tutu';
const changePasswordAction = new loginActions.ChangePasswordAction({
password: 'toto',
new_password: 'tutu'
});
const spy = spyOn(store, 'dispatch');
component.submitted();
expect(spy).toHaveBeenCalledTimes(1);
expect(spy).toHaveBeenCalledWith(changePasswordAction);
});
});
Loading