forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainState.unit.test.ts
More file actions
66 lines (63 loc) · 2.21 KB
/
mainState.unit.test.ts
File metadata and controls
66 lines (63 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
import { assert } from 'chai';
import { IDataScienceSettings } from '../../client/common/types';
import {
createEmptyCell,
CursorPos,
DebugState,
extractInputText,
ICellViewModel
} from '../../datascience-ui/interactive-common/mainState';
import { defaultDataScienceSettings } from './helpers';
// tslint:disable: max-func-body-length
suite('DataScience MainState', () => {
function cloneVM(cvm: ICellViewModel, newCode: string, debugging?: boolean): ICellViewModel {
const result = {
...cvm,
cell: {
...cvm.cell,
data: {
...cvm.cell.data,
source: newCode
}
},
inputBlockText: newCode,
runDuringDebug: debugging
};
// Typecast so that the build works. ICell.MetaData doesn't like reassigning
// tslint:disable-next-line: no-any
return (result as any) as ICellViewModel;
}
test('ExtractInputText', () => {
const settings: IDataScienceSettings = defaultDataScienceSettings();
settings.stopOnFirstLineWhileDebugging = true;
const cvm: ICellViewModel = {
cell: createEmptyCell('1', null),
inputBlockCollapseNeeded: false,
inputBlockText: '',
inputBlockOpen: false,
inputBlockShow: false,
editable: false,
focused: false,
selected: false,
scrollCount: 0,
cursorPos: CursorPos.Current,
hasBeenRun: false,
runningByLine: DebugState.Design,
gathering: false
};
assert.equal(extractInputText(cloneVM(cvm, '# %%\na=1'), settings), 'a=1', 'Cell marker not removed');
assert.equal(
extractInputText(cloneVM(cvm, '# %%\nbreakpoint()\na=1'), settings),
'breakpoint()\na=1',
'Cell marker not removed'
);
assert.equal(
extractInputText(cloneVM(cvm, '# %%\nbreakpoint()\na=1', true), settings),
'a=1',
'Cell marker not removed'
);
});
});