Skip to content

Commit

Permalink
chore(core/api): Update plugin.registry.spec.ts and SpelService.spec.…
Browse files Browse the repository at this point in the history
…ts tests for new http backend
  • Loading branch information
christopherthielen authored and mergify[bot] committed Dec 3, 2020
1 parent c4e775f commit d3327e5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
5 changes: 2 additions & 3 deletions app/scripts/modules/core/src/plugins/plugin.registry.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IStageTypeConfig } from 'core/domain';
import { IDeckPlugin } from './deck.plugin';
import { API } from '../api';
import { RequestBuilder } from '../api';
import { IPluginMetaData, PluginRegistry } from './plugin.registry';
import { Registry } from 'core/registry';
import { mock } from 'angular';
Expand Down Expand Up @@ -42,8 +42,7 @@ describe('PluginRegistry', () => {
);

it('loadPluginManifestFromGate() should fetch from gate /plugins/deck/plugin-manifest.json', async () => {
const spy = jasmine.createSpy('get', () => Promise.resolve([])).and.callThrough();
spyOn(API as any, 'getFn').and.callFake(() => spy);
const spy = spyOn(RequestBuilder.defaultBackend, 'get').and.callFake(() => Promise.resolve([]));
await pluginRegistry.loadPluginManifestFromGate();
expect(spy).toHaveBeenCalled();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { API } from 'core/api';
import { RequestBuilder } from 'core/api';
import { SpelService } from './SpelService';

describe('SpelService', () => {
it('extracts "result" from the payload', async (done) => {
const spy = jasmine.createSpy('get', () => new Promise((resolve) => resolve({ result: 'data' }))).and.callThrough();
spyOn(API as any, 'getFn').and.callFake(() => spy);

const spy = spyOn(RequestBuilder.defaultBackend, 'get').and.callFake(() => Promise.resolve({ result: 'data' }));
const result = await SpelService.evaluateExpression('expression', null, null);
expect(spy).toHaveBeenCalledTimes(1);
expect(result).toBe('data');
Expand All @@ -32,11 +30,9 @@ describe('SpelService', () => {
const errorDetail = serverExpressionEvaluationFailure.detail['bad expression'][0];

// If expressions fail to evaluate, the server still returns 200 OK
const spy = jasmine
.createSpy('get', () => new Promise((resolve) => resolve(serverExpressionEvaluationFailure)))
.and.callThrough();

spyOn(API as any, 'getFn').and.callFake(() => spy);
const spy = spyOn(RequestBuilder.defaultBackend, 'get').and.callFake(() => {
return Promise.resolve(serverExpressionEvaluationFailure);
});

let rejection = null;
try {
Expand Down

0 comments on commit d3327e5

Please sign in to comment.