zeppelin/zeppelin-web/test/spec/controllers/notebook.js
hyonzin 4f6a0e34ff [ZEPPELIN-1549] Change NotebookID variable name to NoteID
### What is this PR for?
This PR fixes wrong written NotebookID to NoteID.

### What type of PR is it?
[Improvement]

### What is the Jira issue?
https://issues.apache.org/jira/browse/ZEPPELIN-1549

### Questions:
* Does the licenses files need update? No.
* Is there breaking changes for older versions? No.
* Does this needs documentation? No

Author: hyonzin <[email protected]>
Author: 정현진 <[email protected]>
Author: Mina Lee <[email protected]>

Closes #1518 from hyonzin/ZEPPELIN-1549 and squashes the following commits:

2c5d461 [hyonzin] fix pullNoteID to pullNoteId
f843abd [hyonzin] Fix missed line
22aecb3 [hyonzin] Merge branch 'master' of https://github.com/apache/zeppelin into ZEPPELIN-1549
ac03666 [정현진] Merge pull request #1 from minahlee/ZEPPELIN-1549
8b3fffd [Mina Lee] Change notebook to note and fix indentation
000605f [hyonzin] Change clonedNotebookId to clonedNoteId
496695c [hyonzin] Change noteID to noteId
1e87463 [hyonzin] Remove tab indent
5647d37 [hyonzin] Rebase and solve conflicts
09bacd8 [hyonzin] Fix more lines unchanged
070bc2d [hyonzin] fix more in ZeppelinRestApiTest.java
24822a3 [hyonzin] Fix more code not changed (notebookIndex to noteSearchService)
4b4e1e8 [hyonzin] Fix detail (function's name) & Change some placeholder
429203d [hyonzin] Fix details & convention to camel
5fa270d [hyonzin] pull upstream master & fix some details
294bea5 [hyonzin] Fix some wrong written term: Notebook -> Note
cc0d315 [hyonzin] Change NotebookID variable name to NoteID
2016-10-25 14:51:07 +09:00

103 lines
3.2 KiB
JavaScript

'use strict';
describe('Controller: NotebookCtrl', function() {
beforeEach(module('zeppelinWebApp'));
var scope;
var websocketMsgSrvMock = {
getNote: function() {},
listRevisionHistory: function() {},
getInterpreterBindings: function() {}
};
var baseUrlSrvMock = {
getRestApiBase: function() {
return 'http://localhost:8080';
}
};
var noteMock = {
id: 1,
name: 'my note',
config: {},
};
beforeEach(inject(function($controller, $rootScope) {
scope = $rootScope.$new();
$controller('NotebookCtrl', {
$scope: scope,
websocketMsgSrv: websocketMsgSrvMock,
baseUrlSrv: baseUrlSrvMock
});
}));
beforeEach(function() {
scope.note = noteMock;
});
var functions = ['getCronOptionNameFromValue', 'removeNote', 'runNote', 'saveNote', 'toggleAllEditor',
'showAllEditor', 'hideAllEditor', 'toggleAllTable', 'hideAllTable', 'showAllTable', 'isNoteRunning',
'killSaveTimer', 'startSaveTimer', 'setLookAndFeel', 'setCronScheduler', 'setConfig', 'sendNewName',
'openSetting', 'closeSetting', 'saveSetting', 'toggleSetting'];
functions.forEach(function(fn) {
it('check for scope functions to be defined : ' + fn, function() {
expect(scope[fn]).toBeDefined();
});
});
it('should set default value of "editorToggled" to false', function() {
expect(scope.editorToggled).toEqual(false);
});
it('should set "showSetting" to true when openSetting() is called', function() {
scope.openSetting();
expect(scope.showSetting).toEqual(true);
});
it('should set "showSetting" to false when closeSetting() is called', function() {
scope.closeSetting();
expect(scope.showSetting).toEqual(false);
});
it('should return the correct value for getCronOptionNameFromValue()', function() {
var none = scope.getCronOptionNameFromValue();
var oneMin = scope.getCronOptionNameFromValue('0 0/1 * * * ?');
var fiveMin = scope.getCronOptionNameFromValue('0 0/5 * * * ?');
var oneHour = scope.getCronOptionNameFromValue('0 0 0/1 * * ?');
var threeHours = scope.getCronOptionNameFromValue('0 0 0/3 * * ?');
var sixHours = scope.getCronOptionNameFromValue('0 0 0/6 * * ?');
var twelveHours = scope.getCronOptionNameFromValue('0 0 0/12 * * ?');
var oneDay = scope.getCronOptionNameFromValue('0 0 0 * * ?');
expect(none).toEqual('');
expect(oneMin).toEqual('1m');
expect(fiveMin).toEqual('5m');
expect(oneHour).toEqual('1h');
expect(threeHours).toEqual('3h');
expect(sixHours).toEqual('6h');
expect(twelveHours).toEqual('12h');
expect(oneDay).toEqual('1d');
});
it('should have "isNoteDirty" as null by default', function() {
expect(scope.isNoteDirty).toEqual(null);
});
it('should first call killSaveTimer() when calling startSaveTimer()', function() {
expect(scope.saveTimer).toEqual(null);
spyOn(scope, 'killSaveTimer');
scope.startSaveTimer();
expect(scope.killSaveTimer).toHaveBeenCalled();
});
it('should set "saveTimer" when saveTimer() and killSaveTimer() are called', function() {
expect(scope.saveTimer).toEqual(null);
scope.startSaveTimer();
expect(scope.saveTimer).toBeTruthy();
scope.killSaveTimer();
expect(scope.saveTimer).toEqual(null);
});
});