Skip to content

Commit

Permalink
Merge f32c302 into 2a619e8
Browse files Browse the repository at this point in the history
  • Loading branch information
eamahanna committed Oct 8, 2020
2 parents 2a619e8 + f32c302 commit 7e8eb6d
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 18 deletions.
2 changes: 1 addition & 1 deletion nbextensions/appCell2/widgets/appCellWidget-fsm.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ define([], function() {
},
actionButton: {
name: 'cancel',
disabled: true
disabled: false
},
elements: {
show: ['parameters-display-group', 'exec-group', 'output-group'],
Expand Down
2 changes: 0 additions & 2 deletions nbextensions/appCell2/widgets/appCellWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -1593,8 +1593,6 @@ define([
// the fact that the user may have opened and closed the tab...
userSelectedTab = false;



cell.execute();
}

Expand Down
2 changes: 1 addition & 1 deletion test/unit/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = function (config) {
failFast: false,
DEFAULT_TIMEOUT_INTERVAL: 20000
},
requireJsShowNoTimestampsError: '^(?!.*(^/narrative/static/))',
requireJsShowNoTimestampsError: '^(?!.*(^/narrative/))',
clearContext: false
},
plugins: [
Expand Down
14 changes: 0 additions & 14 deletions test/unit/spec/narrative_core/kbaseNarrativeAppCell-spec.js

This file was deleted.

150 changes: 150 additions & 0 deletions test/unit/spec/nbextensions/appCell2/widgets/appCellWidget-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
/*global describe, it, expect*/
/*global beforeEach, afterEach*/
/*jslint white: true*/
define([
'jquery',
'../../../../../../../narrative/nbextensions/appCell2/widgets/appCellWidget',
'common/runtime',
'base/js/namespace',
'bluebird'
], function(
$,
AppCell,
Runtime,
Jupyter,
Promise
) {
'use strict';
let mockAppCell, $node;

var workspaceInfo = {
globalread: 'n',
id: 54745,
lockstat: 'unlocked',
metadata: {
cell_count: '1',
narrative_nice_name: 'Test Narrative',
searchtags: 'narrative',
is_temporary: 'false',
narrative: '1'
},
moddate: '2020-10-06T03:30:52+0000',
name: 'testUser:narrative_1601948894239',
object_count: 1,
owner: 'testUser',
user_permission: 'a'
};

var cell = {
cell_type: 'code',
metadata: {
kbase: {
type: 'app',
attributes:{
created: 'Fri, 27 Mar 2020 17:39:10 GMT',
id: '71e12dca-3a12-4dd7-862b-125f4337e723',
info: {
label: 'more...',
url: '/#appcatalog/app/simpleapp/example_method/beta'
},
lastLoaded: 'Tue, 06 Oct 2020 23:28:26 GMT',
status: 'new',
subtitle: 'Perform some kind of method',
title: 'SimpleApp Simple Add'
},
appCell: {
app: {
spec: {
parameters: [{
advanced: 0,
allow_multiple: 0,
default_values: ['0'],
description: 'The first parameter that needs to be entered to drive the method. This might be the first of many.',
disabled: 0,
field_type: 'text',
id: 'base_number',
optional: 1,
short_hint: 'The first parameter',
text_options:{
is_output_name: 0,
placeholder: '',
regex_constraint: [],
valid_ws_types: [],
validate_as: 'int',
ui_class: 'parameter',
ui_name: 'base_number',
}
}]
}
}
},
}
}
};

Jupyter.notebook = {
writable: true
};
Jupyter.narrative = {
readonly: false
};

// Can only test the public functions...
describe('The appCell widget', () => {

beforeEach( () => {
$node = $('<div>');
var bus = Runtime.make().bus();
mockAppCell = AppCell.make({
workspaceInfo: workspaceInfo,
bus: bus,
cell: cell,
});
});

afterEach(() => {
mockAppCell = null;
window.kbaseRuntime = null;
});

it('Should load', () => {
expect(AppCell).not.toBe(null);
});

it('Should return a make function', () => {
expect(AppCell.make).toBeDefined();
});

it('Can be instantiated', () => {
expect(mockAppCell).not.toBe(null);
});

it('Has expected functions when instantiated', () => {
expect(mockAppCell.init).toBeDefined();
expect(mockAppCell.attach).toBeDefined();
expect(mockAppCell.start).toBeDefined();
expect(mockAppCell.stop).toBeDefined();
expect(mockAppCell.detach).toBeDefined();
});

it('has a method start which returns a Promise', async () => {
var startPromise = mockAppCell.start();
expect(startPromise instanceof Promise).toBeTrue();

var result = await startPromise;
expect(result).toBeNull();
});

it('has a method stop which returns a Promise', () => {
var stopPromise = mockAppCell.stop();
expect(stopPromise instanceof Promise).toBeTrue();
});

it('has a method detach which returns a Promise', () => {
var detachPromise = mockAppCell.stop();
expect(detachPromise instanceof Promise).toBeTrue();
});

});

});

0 comments on commit 7e8eb6d

Please sign in to comment.