First draft of outputProcessor tests (#11368)

* First draft of outputProcessor tests

* add return type for a function

* pr feedback

* comments and Spellings, getRandom ==> getRandomElement

* pr feedback

* pr feedback
This commit is contained in:
Arvind Ranasaria
2020-07-22 12:27:23 -07:00
committed by GitHub
parent 8da27190a2
commit d086b5b01e
2 changed files with 166 additions and 3 deletions

View File

@@ -41,10 +41,10 @@ export function getData(output: nb.ICellOutput): JSONObject {
} else if (nbformat.isError(output)) {
let traceback = output.traceback ? output.traceback.join('\n') : undefined;
bundle['application/vnd.jupyter.stderr'] = undefined;
if (traceback && traceback !== '') {
if (traceback) {
bundle['application/vnd.jupyter.stderr'] = traceback;
} else if (output.evalue) {
bundle['application/vnd.jupyter.stderr'] = output.ename && output.ename !== '' ? `${output.ename}: ${output.evalue}` : `${output.evalue}`;
bundle['application/vnd.jupyter.stderr'] = output.ename ? `${output.ename}: ${output.evalue}` : `${output.evalue}`;
}
}
return convertBundle(bundle);
@@ -78,7 +78,7 @@ export function getBundleOptions(options: IOutputModelOptions): MimeModel.IOptio
*/
export function extract(value: JSONObject, key: string): {} {
let item = value[key];
if (isPrimitive(item)) {
if (item === undefined || item === null || isPrimitive(item)) {
return item;
}
return JSON.parse(JSON.stringify(item));