Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should return response', () => {
spyOn(request, 'get').and.returnValue(
Rx.Observable.return({ body: { Projects: { Project: [] } } })
);
const result = scheduler.startScheduler(() => cctrayRequests.projects(settings));
expect(result.messages).toHaveEqualElements(
onNext(200, { Projects: { Project: [] } }),
onCompleted(200)
);
});
it('should not start disabled services', function() {
settings.disabled = true;
controller.start(Rx.Observable.return([settings]));
expect(CustomBuildService.prototype.start).not.toHaveBeenCalled();
});
case 'servicesInitialized':
return servicesInitializedEvents;
case 'passwordExpired':
return passwordExpiredEvents;
default:
return null;
}
});
scheduler = new Rx.TestScheduler();
mockNotification = {
close: jasmine.createSpy(),
onshow: jasmine.createSpy(),
onclick: jasmine.createSpy()
};
spyOn(window, 'Notification').and.returnValue(mockNotification);
spyOn(chromeApi, 'isDashboardActive').and.returnValue(Rx.Observable.return(false));
spyOn(serviceController, 'typeInfoFor').and
.returnValue({ icon: 'src/services/test/icon.png' });
notificationController.init({
timeout: 5000,
scheduler,
configuration: configChanges
});
});
it('should pass request parameters', () => {
requests.jobs.returns(Rx.Observable.empty());
jenkins.getAll(settings);
sinon.assert.calledOnce(requests.jobs);
sinon.assert.calledWith(requests.jobs, { url: settings.url, settings });
});
it('should return sequence if json array present', () => {
spyOn(request, 'get').and.returnValue(Rx.Observable.return({
body: {
repositories: [
{ org: 1 }, { org: 2 }
]
}
}));
const result = scheduler.startScheduler(() => travisRequests.repositories(settings));
expect(result.messages).toHaveEqualElements(
onNext(200, { org: 1 }),
onNext(200, { org: 2 }),
onCompleted(200)
);
});
beforeEach(function() {
settings = {
baseUrl: 'test',
url: 'http://www.example.com/',
name: 'service name',
projects: [],
disabled: false
};
serviceStartResponse = Rx.Observable.return([]);
spyOn(CustomBuildService.prototype, 'start').and.callFake(function() {
this.events.onNext({ eventName: 'serviceStarted' });
return serviceStartResponse;
});
spyOn(CustomBuildService.prototype, 'stop');
controller.registerType(CustomBuildService);
scheduler = new Rx.TestScheduler();
});
request.json.and.callFake(function(options) {
switch (options.url) {
case 'https://api.travis-ci.org/repositories/AdamNowotny/BuildReactor/builds.json':
return Rx.Observable.return(buildsRunningJson);
case 'https://api.travis-ci.org/builds/6305554':
return build1Result;
case 'https://api.travis-ci.org/builds/6305490':
return build2Result;
default:
throw 'Unknown URL ' + options.url;
}
});
spyOn(request, 'get').and.callFake((data) => {
expect(data).toEqual({
url: 'http://example.com/rest/api/latest/project',
query: {
expand: 'projects.project.plans.plan',
'max-result': 1000,
os_authType: 'basic'
},
type: 'json',
username: settings.username,
password: settings.password
});
return Rx.Observable.never();
});
spyOn(request, 'get').and.callFake((data) => {
expect(data).toEqual({
url: 'http://example.com/httpAuth/app/rest/buildTypes',
query: {
fields: 'buildType(id,name,projectName)'
},
type: 'json',
username: settings.username,
password: settings.password
});
return Rx.Observable.never();
});
spyOn(request, 'get').and.callFake((data) => {
expect(data).toEqual({
url: 'http://example.com/json/builders',
type: 'json',
username: settings.username,
password: settings.password
});
return Rx.Observable.never();
});