ng test 관련 소스 수정본. 컴포넌트 관련은 미완료.
This commit is contained in:
@@ -1,14 +1,142 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { AuthenticationProtocolService } from './authentication-protocol.service';
|
||||
import { LogService } from '@ucap/ng-logger';
|
||||
import { ProtocolService } from '@ucap/ng-protocol';
|
||||
import { _MODULE_CONFIG } from '../config/token';
|
||||
import { of } from 'rxjs';
|
||||
import {
|
||||
LoginRequest,
|
||||
SSOMode,
|
||||
SVC_TYPE_LOGIN,
|
||||
SSVC_TYPE_LOGIN_REQ,
|
||||
LogoutRequest,
|
||||
SSVC_TYPE_LOGOUT_RES,
|
||||
SSVC_TYPE_LOGIN_RES
|
||||
} from '@ucap/protocol-authentication';
|
||||
import { DeviceType, LocaleCode } from '@ucap/core';
|
||||
import { ProtocolMessage } from '@ucap/protocol';
|
||||
|
||||
describe('AuthenticationProtocolService', () => {
|
||||
beforeEach(() => TestBed.configureTestingModule({}));
|
||||
const senderSeq = '10045';
|
||||
let service: AuthenticationProtocolService;
|
||||
let protocolServiceSpy: jasmine.SpyObj<ProtocolService>;
|
||||
|
||||
beforeEach(() => {
|
||||
const spyProtocolService = {
|
||||
...jasmine.createSpyObj('ProtocolService', ['connect', 'call']),
|
||||
serverMessage$: of()
|
||||
};
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
providers: [
|
||||
AuthenticationProtocolService,
|
||||
{ provide: _MODULE_CONFIG, useValue: _MODULE_CONFIG },
|
||||
{ provide: ProtocolService, useValue: spyProtocolService },
|
||||
{ provide: LogService, useValue: LogService }
|
||||
]
|
||||
});
|
||||
|
||||
service = TestBed.inject(AuthenticationProtocolService);
|
||||
protocolServiceSpy = TestBed.inject(ProtocolService) as jasmine.SpyObj<
|
||||
ProtocolService
|
||||
>;
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
const service: AuthenticationProtocolService = TestBed.inject(
|
||||
AuthenticationProtocolService
|
||||
);
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
|
||||
it('Test Login', (done) => {
|
||||
protocolServiceSpy.call.and.returnValue(
|
||||
of<ProtocolMessage>({
|
||||
serviceType: SVC_TYPE_LOGIN,
|
||||
subServiceType: SSVC_TYPE_LOGIN_RES,
|
||||
senderSeq,
|
||||
bodyList: [
|
||||
'test03',
|
||||
'9826',
|
||||
'9826테스트3https://dstalk.daesang.com/Extern/StreamProfileUrl.aspx?p_empno=ZZZZZZZ3사업부장하지마GUC10001090882377 01224646@daesang.com식자재사업부A330ZZZZZZZ3Test3Test3manager_enmanager_cn식자재사업부식자재사업부P ',
|
||||
' 2 0',
|
||||
'GUC100',
|
||||
'205',
|
||||
'test03',
|
||||
'1',
|
||||
'',
|
||||
'N',
|
||||
'0',
|
||||
'1',
|
||||
'회의중',
|
||||
'테스트중',
|
||||
'GUC100',
|
||||
'30',
|
||||
'90',
|
||||
'Y',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'0',
|
||||
'Y',
|
||||
'Y',
|
||||
'Y',
|
||||
'Y',
|
||||
'Y',
|
||||
'stubTokenString',
|
||||
'N',
|
||||
'4',
|
||||
'6',
|
||||
' ',
|
||||
'Y',
|
||||
'2'
|
||||
]
|
||||
})
|
||||
);
|
||||
|
||||
const req = {
|
||||
loginId: '',
|
||||
loginPw: '',
|
||||
deviceType: DeviceType.PC,
|
||||
deviceId: '',
|
||||
token: '',
|
||||
localeCode: LocaleCode.Korean,
|
||||
pushId: '',
|
||||
companyCode: '',
|
||||
passwordEncodingType: 0,
|
||||
clientVersion: '',
|
||||
reconnect: false,
|
||||
ip: '',
|
||||
hostName: '',
|
||||
ssoMode: SSOMode.NONE,
|
||||
userSpecificInformation: '',
|
||||
andId: '',
|
||||
andPushRefreshYn: ''
|
||||
} as LoginRequest;
|
||||
// service.login(req)..returnValue();
|
||||
service.login(req).subscribe((res) => {
|
||||
// console.log(res);
|
||||
expect(res).toBeDefined();
|
||||
expect(res.companyCode).toBe('GUC100');
|
||||
expect(res.userInfo.seq).toBeDefined();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('Test Logout', (done) => {
|
||||
protocolServiceSpy.call.and.returnValue(
|
||||
of<ProtocolMessage>({
|
||||
serviceType: SVC_TYPE_LOGIN,
|
||||
subServiceType: SSVC_TYPE_LOGOUT_RES,
|
||||
senderSeq,
|
||||
bodyList: ['99']
|
||||
})
|
||||
);
|
||||
|
||||
const req = {} as LogoutRequest;
|
||||
service.logout(req).subscribe((res) => {
|
||||
// console.log(res);
|
||||
expect(res).toBeDefined();
|
||||
expect(res.reasonCode).toBe(99);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user