-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into empty-shared-folders
- Loading branch information
Showing
2 changed files
with
100 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,124 +1,113 @@ | ||
/*global define,describe,beforeEach,it,jasmine,expect*/ | ||
import HistoricalProvider from './HistoricalProvider'; | ||
|
||
define([ | ||
'./HistoricalProvider' | ||
], function ( | ||
HistoricalProvider | ||
) { | ||
'use strict'; | ||
describe('Historical Provider', function () { | ||
let historicalProvider; | ||
let mockOpenMct; | ||
let mockMetadata; | ||
let options; | ||
let mockDomainObject; | ||
let mockSessionService; | ||
let mockNotification; | ||
let resolveCallback; | ||
let rejectCallback; | ||
|
||
xdescribe('Historical Provider', function () { | ||
let historicalProvider; | ||
let mockOpenMct; | ||
let mockMetadata; | ||
let options; | ||
let mockDomainObject; | ||
let mockSessionService; | ||
let mockNotification; | ||
let resolveCallback; | ||
let rejectCallback; | ||
beforeEach(function () { | ||
options = { | ||
domain: 'scet' | ||
}; | ||
mockOpenMct = {}; | ||
|
||
beforeEach(function () { | ||
options = { | ||
domain: 'scet' | ||
}; | ||
mockOpenMct = {}; | ||
|
||
mockOpenMct.telemetry = jasmine.createSpyObj('telemetryApi', [ | ||
'getMetadata' | ||
]); | ||
mockMetadata = jasmine.createSpyObj('metadata', [ | ||
'value', | ||
'values' | ||
]); | ||
mockMetadata.values.and.returnValue([]); | ||
mockOpenMct.telemetry.getMetadata.and.returnValue(mockMetadata); | ||
mockMetadata.value.and.returnValue({ | ||
'key': 'scet' | ||
}); | ||
mockOpenMct.telemetry = jasmine.createSpyObj('telemetryApi', [ | ||
'getMetadata' | ||
]); | ||
mockMetadata = jasmine.createSpyObj('metadata', [ | ||
'value', | ||
'values' | ||
]); | ||
mockMetadata.values.and.returnValue([]); | ||
mockOpenMct.telemetry.getMetadata.and.returnValue(mockMetadata); | ||
mockMetadata.value.and.returnValue({ | ||
'key': 'scet' | ||
}); | ||
|
||
mockSessionService = jasmine.createSpyObj('sessionService', [ | ||
'getHistoricalSession' | ||
]); | ||
mockOpenMct.$injector = jasmine.createSpyObj('injector', [ | ||
'get' | ||
]); | ||
mockOpenMct.$injector.get.and.returnValue(mockSessionService); | ||
mockOpenMct.notifications = jasmine.createSpyObj('notificationAPI', [ | ||
'alert' | ||
]); | ||
mockNotification = jasmine.createSpyObj('notification', [ | ||
'on', | ||
'off' | ||
]); | ||
mockOpenMct.notifications.alert.and.returnValue(mockNotification); | ||
mockSessionService = jasmine.createSpyObj('SessionService', [ | ||
'getHistoricalSession' | ||
]); | ||
spyOn(HistoricalProvider.prototype, 'getSessionService').and.returnValue(mockSessionService); | ||
|
||
mockOpenMct.notifications = jasmine.createSpyObj('notificationAPI', [ | ||
'alert' | ||
]); | ||
mockNotification = jasmine.createSpyObj('notification', [ | ||
'on', | ||
'off' | ||
]); | ||
mockOpenMct.notifications.alert.and.returnValue(mockNotification); | ||
|
||
historicalProvider = new HistoricalProvider(mockOpenMct); | ||
historicalProvider = new HistoricalProvider(mockOpenMct); | ||
|
||
resolveCallback = rejectCallback = (response) => {}; | ||
}); | ||
resolveCallback = rejectCallback = (response) => {}; | ||
}); | ||
|
||
describe ('min-max requests', function() { | ||
beforeEach(function () { | ||
mockDomainObject = { | ||
identifier: { | ||
namespace: 'test-namesapce', | ||
key: 'test-key' | ||
}, | ||
type: 'vista.channel', | ||
telemetry: { | ||
channelMinMaxUrl: 'some-url' | ||
} | ||
describe ('min-max requests', function() { | ||
beforeEach(function () { | ||
mockDomainObject = { | ||
identifier: { | ||
namespace: 'test-namesapce', | ||
key: 'test-key' | ||
}, | ||
type: 'vista.channel', | ||
telemetry: { | ||
channelMinMaxUrl: 'some-url' | ||
} | ||
options.size = 2; | ||
options.strategy = 'minmax'; | ||
}); | ||
it('show a warning when filters are defined', function () { | ||
options.filters = { | ||
filterName: { | ||
equals: ['someValue'] | ||
} | ||
}; | ||
historicalProvider.request(mockDomainObject, options).then(resolveCallback, rejectCallback); | ||
expect(mockOpenMct.notifications.alert).toHaveBeenCalled(); | ||
}); | ||
|
||
describe('do not show a warning', function () { | ||
it('when filters are undefined', function () { | ||
options.filters = undefined; | ||
historicalProvider.request(mockDomainObject, options).then(resolveCallback, rejectCallback);; | ||
expect(mockOpenMct.notifications.alert).not.toHaveBeenCalled(); | ||
}); | ||
it('when filters are empty', function () { | ||
options.filters = { | ||
somekey: {} | ||
}; | ||
historicalProvider.request(mockDomainObject, options).then(resolveCallback, rejectCallback);; | ||
expect(mockOpenMct.notifications.alert).not.toHaveBeenCalled(); | ||
}); | ||
}) | ||
} | ||
options.size = 2; | ||
options.strategy = 'minmax'; | ||
}); | ||
describe('non min-max requests', function() { | ||
beforeEach(function () { | ||
mockDomainObject = { | ||
identifier: { | ||
namespace: 'test-namesapce', | ||
key: 'test-key' | ||
}, | ||
type: 'vista.channel', | ||
telemetry: { | ||
channelMinMaxUrl: 'some-url' | ||
} | ||
it('show a warning when filters are defined', function () { | ||
options.filters = { | ||
filterName: { | ||
equals: ['someValue'] | ||
} | ||
}; | ||
historicalProvider.request(mockDomainObject, options).then(resolveCallback, rejectCallback); | ||
expect(mockOpenMct.notifications.alert).toHaveBeenCalled(); | ||
}); | ||
|
||
describe('do not show a warning', function () { | ||
it('when filters are undefined', function () { | ||
options.filters = undefined; | ||
historicalProvider.request(mockDomainObject, options).then(resolveCallback, rejectCallback);; | ||
expect(mockOpenMct.notifications.alert).not.toHaveBeenCalled(); | ||
}); | ||
it('Do not show a warning when filters are defined', function () { | ||
it('when filters are empty', function () { | ||
options.filters = { | ||
filterName: 'filterValue' | ||
somekey: {} | ||
}; | ||
historicalProvider.request(mockDomainObject, options); | ||
historicalProvider.request(mockDomainObject, options).then(resolveCallback, rejectCallback);; | ||
expect(mockOpenMct.notifications.alert).not.toHaveBeenCalled(); | ||
}); | ||
}); | ||
}) | ||
}); | ||
describe('non min-max requests', function() { | ||
beforeEach(function () { | ||
mockDomainObject = { | ||
identifier: { | ||
namespace: 'test-namesapce', | ||
key: 'test-key' | ||
}, | ||
type: 'vista.channel', | ||
telemetry: { | ||
channelMinMaxUrl: 'some-url' | ||
} | ||
} | ||
}); | ||
it('Do not show a warning when filters are defined', function () { | ||
options.filters = { | ||
filterName: 'filterValue' | ||
}; | ||
historicalProvider.request(mockDomainObject, options); | ||
expect(mockOpenMct.notifications.alert).not.toHaveBeenCalled(); | ||
}); | ||
}); | ||
}); |