|
@@ -7,7 +7,7 @@ import { OutputModel } from '@jupyterlab/rendermime';
|
|
|
|
|
|
import { OutputAreaModel } from '@jupyterlab/outputarea';
|
|
|
|
|
|
-import { DEFAULT_OUTPUTS } from '@jupyterlab/testutils';
|
|
|
+import { NBTestUtils } from '@jupyterlab/testutils';
|
|
|
|
|
|
describe('outputarea/model', () => {
|
|
|
let model: OutputAreaModel;
|
|
@@ -29,7 +29,7 @@ describe('outputarea/model', () => {
|
|
|
it('should accept options', () => {
|
|
|
let contentFactory = new OutputAreaModel.ContentFactory();
|
|
|
model = new OutputAreaModel({
|
|
|
- values: DEFAULT_OUTPUTS,
|
|
|
+ values: NBTestUtils.DEFAULT_OUTPUTS,
|
|
|
contentFactory,
|
|
|
trusted: true
|
|
|
});
|
|
@@ -49,7 +49,7 @@ describe('outputarea/model', () => {
|
|
|
expect(args.oldValues.length).to.be(0);
|
|
|
called = true;
|
|
|
});
|
|
|
- model.add(DEFAULT_OUTPUTS[0]);
|
|
|
+ model.add(NBTestUtils.DEFAULT_OUTPUTS[0]);
|
|
|
expect(called).to.be(true);
|
|
|
});
|
|
|
});
|
|
@@ -57,7 +57,7 @@ describe('outputarea/model', () => {
|
|
|
describe('#stateChanged', () => {
|
|
|
it('should be emitted when an item changes', () => {
|
|
|
let called = false;
|
|
|
- model.add(DEFAULT_OUTPUTS[0]);
|
|
|
+ model.add(NBTestUtils.DEFAULT_OUTPUTS[0]);
|
|
|
model.stateChanged.connect((sender, args) => {
|
|
|
expect(sender).to.be(model);
|
|
|
expect(args).to.be(void 0);
|
|
@@ -72,7 +72,7 @@ describe('outputarea/model', () => {
|
|
|
describe('#length', () => {
|
|
|
it('should get the length of the items in the model', () => {
|
|
|
expect(model.length).to.be(0);
|
|
|
- model.add(DEFAULT_OUTPUTS[0]);
|
|
|
+ model.add(NBTestUtils.DEFAULT_OUTPUTS[0]);
|
|
|
expect(model.length).to.be(1);
|
|
|
});
|
|
|
});
|
|
@@ -84,8 +84,8 @@ describe('outputarea/model', () => {
|
|
|
|
|
|
it('should cause all of the cells to `set`', () => {
|
|
|
let called = 0;
|
|
|
- model.add(DEFAULT_OUTPUTS[0]);
|
|
|
- model.add(DEFAULT_OUTPUTS[1]);
|
|
|
+ model.add(NBTestUtils.DEFAULT_OUTPUTS[0]);
|
|
|
+ model.add(NBTestUtils.DEFAULT_OUTPUTS[1]);
|
|
|
model.changed.connect(() => {
|
|
|
called++;
|
|
|
});
|
|
@@ -112,7 +112,7 @@ describe('outputarea/model', () => {
|
|
|
|
|
|
describe('#dispose()', () => {
|
|
|
it('should dispose of the resources used by the model', () => {
|
|
|
- model.add(DEFAULT_OUTPUTS[0]);
|
|
|
+ model.add(NBTestUtils.DEFAULT_OUTPUTS[0]);
|
|
|
model.dispose();
|
|
|
expect(model.isDisposed).to.be(true);
|
|
|
expect(model.length).to.be(0);
|
|
@@ -127,35 +127,35 @@ describe('outputarea/model', () => {
|
|
|
|
|
|
describe('#get()', () => {
|
|
|
it('should get the item at the specified index', () => {
|
|
|
- model.add(DEFAULT_OUTPUTS[0]);
|
|
|
+ model.add(NBTestUtils.DEFAULT_OUTPUTS[0]);
|
|
|
let output = model.get(0);
|
|
|
- expect(output.type).to.be(DEFAULT_OUTPUTS[0].output_type);
|
|
|
+ expect(output.type).to.be(NBTestUtils.DEFAULT_OUTPUTS[0].output_type);
|
|
|
});
|
|
|
|
|
|
it('should return `undefined` if out of range', () => {
|
|
|
- model.add(DEFAULT_OUTPUTS[0]);
|
|
|
+ model.add(NBTestUtils.DEFAULT_OUTPUTS[0]);
|
|
|
expect(model.get(1)).to.be(void 0);
|
|
|
});
|
|
|
});
|
|
|
|
|
|
describe('#add()', () => {
|
|
|
it('should add an output', () => {
|
|
|
- model.add(DEFAULT_OUTPUTS[0]);
|
|
|
+ model.add(NBTestUtils.DEFAULT_OUTPUTS[0]);
|
|
|
expect(model.length).to.be(1);
|
|
|
});
|
|
|
|
|
|
it('should consolidate consecutive stream outputs of the same kind', () => {
|
|
|
- model.add(DEFAULT_OUTPUTS[0]);
|
|
|
- model.add(DEFAULT_OUTPUTS[1]);
|
|
|
+ model.add(NBTestUtils.DEFAULT_OUTPUTS[0]);
|
|
|
+ model.add(NBTestUtils.DEFAULT_OUTPUTS[1]);
|
|
|
expect(model.length).to.be(2);
|
|
|
- model.add(DEFAULT_OUTPUTS[2]);
|
|
|
+ model.add(NBTestUtils.DEFAULT_OUTPUTS[2]);
|
|
|
expect(model.length).to.be(2);
|
|
|
});
|
|
|
});
|
|
|
|
|
|
describe('#clear()', () => {
|
|
|
it('should clear all of the output', () => {
|
|
|
- for (let output of DEFAULT_OUTPUTS) {
|
|
|
+ for (let output of NBTestUtils.DEFAULT_OUTPUTS) {
|
|
|
model.add(output);
|
|
|
}
|
|
|
model.clear();
|
|
@@ -163,10 +163,10 @@ describe('outputarea/model', () => {
|
|
|
});
|
|
|
|
|
|
it('should wait for next add if requested', () => {
|
|
|
- model.add(DEFAULT_OUTPUTS[0]);
|
|
|
+ model.add(NBTestUtils.DEFAULT_OUTPUTS[0]);
|
|
|
model.clear(true);
|
|
|
expect(model.length).to.be(1);
|
|
|
- model.add(DEFAULT_OUTPUTS[1]);
|
|
|
+ model.add(NBTestUtils.DEFAULT_OUTPUTS[1]);
|
|
|
expect(model.length).to.be(1);
|
|
|
});
|
|
|
});
|
|
@@ -174,7 +174,7 @@ describe('outputarea/model', () => {
|
|
|
describe('#fromJSON()', () => {
|
|
|
it('should deserialize the model from JSON', () => {
|
|
|
model.clear();
|
|
|
- model.fromJSON(DEFAULT_OUTPUTS);
|
|
|
+ model.fromJSON(NBTestUtils.DEFAULT_OUTPUTS);
|
|
|
expect(model.toJSON().length).to.be(5);
|
|
|
});
|
|
|
});
|
|
@@ -182,7 +182,7 @@ describe('outputarea/model', () => {
|
|
|
describe('#toJSON()', () => {
|
|
|
it('should serialize the model to JSON', () => {
|
|
|
expect(model.toJSON()).to.eql([]);
|
|
|
- model.fromJSON(DEFAULT_OUTPUTS);
|
|
|
+ model.fromJSON(NBTestUtils.DEFAULT_OUTPUTS);
|
|
|
expect(model.toJSON().length).to.be(5);
|
|
|
});
|
|
|
});
|
|
@@ -192,7 +192,9 @@ describe('outputarea/model', () => {
|
|
|
describe('#createOutputModel()', () => {
|
|
|
it('should create an output model', () => {
|
|
|
let factory = new OutputAreaModel.ContentFactory();
|
|
|
- let model = factory.createOutputModel({ value: DEFAULT_OUTPUTS[0] });
|
|
|
+ let model = factory.createOutputModel({
|
|
|
+ value: NBTestUtils.DEFAULT_OUTPUTS[0]
|
|
|
+ });
|
|
|
expect(model).to.be.an(OutputModel);
|
|
|
});
|
|
|
});
|