Skip to content

Commit a742c0e

Browse files
author
Myztiq
committed
Updated logic to handle alert notification.
1 parent ff1a6eb commit a742c0e

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

test/unit/services/createAndBuildNewContainerService.unit.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ describe('createAndBuildNewContainer'.bold.underline.blue, function () {
6969
$provide.factory('createNewInstance', createNewInstanceMock.fetch());
7070
$provide.factory('fetchPlan', function ($q) {
7171
mockFetchPlan = sinon.stub().returns($q.when(mockPlan));
72+
mockFetchPlan.cache = {
73+
clear: sinon.stub()
74+
};
7275
return mockFetchPlan;
7376
});
7477
$provide.value('errs', ctx.errs);
@@ -89,6 +92,10 @@ describe('createAndBuildNewContainer'.bold.underline.blue, function () {
8992
}
9093

9194
describe('success', function () {
95+
beforeEach(function () {
96+
$rootScope.$broadcast = sinon.stub();
97+
});
98+
9299
it('should create a server', function () {
93100
setup();
94101
$rootScope.$digest();
@@ -123,9 +130,18 @@ describe('createAndBuildNewContainer'.bold.underline.blue, function () {
123130
sinon.assert.calledOnce(instances.add);
124131
sinon.assert.calledOnce(ctx.eventTracking.triggeredBuild);
125132

133+
mockFetchPlan.reset();
134+
mockFetchPlan.returns($q.when({next: {id: '5678'}}));
126135
createNewInstanceMock.triggerPromise(instance);
127136
$rootScope.$digest();
128137
sinon.assert.calledOnce(ctx.helpCards.refreshAllCards);
138+
sinon.assert.calledOnce(mockFetchPlan.cache.clear);
139+
sinon.assert.calledOnce(mockFetchPlan);
140+
sinon.assert.calledWith($rootScope.$broadcast, 'alert', {
141+
type: 'success',
142+
text: 'Container Created',
143+
newPlan: true
144+
});
129145
});
130146

131147
it('should create a server with isolation', function () {

0 commit comments

Comments
 (0)