|
@@ -4,8 +4,8 @@
|
|
import expect = require('expect.js');
|
|
import expect = require('expect.js');
|
|
|
|
|
|
import {
|
|
import {
|
|
- uuid
|
|
|
|
-} from '@jupyterlab/coreutils';
|
|
|
|
|
|
+ UUID
|
|
|
|
+} from '@phosphor/coreutils';
|
|
|
|
|
|
import {
|
|
import {
|
|
JSONObject
|
|
JSONObject
|
|
@@ -25,14 +25,14 @@ describe('config', () => {
|
|
describe('ConfigSection.create()', () => {
|
|
describe('ConfigSection.create()', () => {
|
|
|
|
|
|
it('should load a config', () => {
|
|
it('should load a config', () => {
|
|
- return ConfigSection.create({ name: uuid() }).then(config => {
|
|
|
|
|
|
+ return ConfigSection.create({ name: UUID.uuid4() }).then(config => {
|
|
expect(Object.keys(config.data).length).to.be(0);
|
|
expect(Object.keys(config.data).length).to.be(0);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
|
|
it('should accept server settings', () => {
|
|
it('should accept server settings', () => {
|
|
let serverSettings = makeSettings();
|
|
let serverSettings = makeSettings();
|
|
- return ConfigSection.create({ name: uuid(), serverSettings }).then(config => {
|
|
|
|
|
|
+ return ConfigSection.create({ name: UUID.uuid4(), serverSettings }).then(config => {
|
|
expect(Object.keys(config.data).length).to.be(0);
|
|
expect(Object.keys(config.data).length).to.be(0);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
@@ -40,7 +40,7 @@ describe('config', () => {
|
|
|
|
|
|
it('should fail for an incorrect response', (done) => {
|
|
it('should fail for an incorrect response', (done) => {
|
|
let serverSettings = getRequestHandler(201, { });
|
|
let serverSettings = getRequestHandler(201, { });
|
|
- let configPromise = ConfigSection.create({ name: uuid(), serverSettings });
|
|
|
|
|
|
+ let configPromise = ConfigSection.create({ name: UUID.uuid4(), serverSettings });
|
|
expectFailure(configPromise, done, 'Invalid response: 201 Created');
|
|
expectFailure(configPromise, done, 'Invalid response: 201 Created');
|
|
});
|
|
});
|
|
|
|
|
|
@@ -50,7 +50,7 @@ describe('config', () => {
|
|
|
|
|
|
it('should update a config', () => {
|
|
it('should update a config', () => {
|
|
let config: IConfigSection;
|
|
let config: IConfigSection;
|
|
- return ConfigSection.create({ name: uuid() }).then(c => {
|
|
|
|
|
|
+ return ConfigSection.create({ name: UUID.uuid4() }).then(c => {
|
|
config = c;
|
|
config = c;
|
|
return config.update( { foo: 'baz', spam: 'eggs' });
|
|
return config.update( { foo: 'baz', spam: 'eggs' });
|
|
}).then((data: any) => {
|
|
}).then((data: any) => {
|
|
@@ -64,7 +64,7 @@ describe('config', () => {
|
|
it('should accept server settings', () => {
|
|
it('should accept server settings', () => {
|
|
let config: IConfigSection;
|
|
let config: IConfigSection;
|
|
let serverSettings = makeSettings();
|
|
let serverSettings = makeSettings();
|
|
- return ConfigSection.create({ name: uuid(), serverSettings }).then(c => {
|
|
|
|
|
|
+ return ConfigSection.create({ name: UUID.uuid4(), serverSettings }).then(c => {
|
|
config = c;
|
|
config = c;
|
|
return config.update( { foo: 'baz', spam: 'eggs' });
|
|
return config.update( { foo: 'baz', spam: 'eggs' });
|
|
}).then((data: any) => {
|
|
}).then((data: any) => {
|
|
@@ -76,7 +76,7 @@ describe('config', () => {
|
|
});
|
|
});
|
|
|
|
|
|
it('should fail for an incorrect response', (done) => {
|
|
it('should fail for an incorrect response', (done) => {
|
|
- ConfigSection.create({ name: uuid() }).then(config => {
|
|
|
|
|
|
+ ConfigSection.create({ name: UUID.uuid4() }).then(config => {
|
|
handleRequest(config, 201, { });
|
|
handleRequest(config, 201, { });
|
|
let update = config.update({ foo: 'baz' });
|
|
let update = config.update({ foo: 'baz' });
|
|
expectFailure(update, done, 'Invalid response: 201 Created');
|
|
expectFailure(update, done, 'Invalid response: 201 Created');
|
|
@@ -95,7 +95,7 @@ describe('jupyter.services - ConfigWithDefaults', () => {
|
|
it('should complete properly', () => {
|
|
it('should complete properly', () => {
|
|
let defaults: JSONObject = { spam: 'eggs' };
|
|
let defaults: JSONObject = { spam: 'eggs' };
|
|
let className = 'testclass';
|
|
let className = 'testclass';
|
|
- return ConfigSection.create({ name: uuid() }).then(section => {
|
|
|
|
|
|
+ return ConfigSection.create({ name: UUID.uuid4() }).then(section => {
|
|
let config = new ConfigWithDefaults({ section, defaults, className });
|
|
let config = new ConfigWithDefaults({ section, defaults, className });
|
|
expect(config).to.be.a(ConfigWithDefaults);
|
|
expect(config).to.be.a(ConfigWithDefaults);
|
|
});
|
|
});
|
|
@@ -108,7 +108,7 @@ describe('jupyter.services - ConfigWithDefaults', () => {
|
|
it('should get a new config value', () => {
|
|
it('should get a new config value', () => {
|
|
let defaults: JSONObject = { foo: 'bar' };
|
|
let defaults: JSONObject = { foo: 'bar' };
|
|
let className = 'testclass';
|
|
let className = 'testclass';
|
|
- return ConfigSection.create({ name: uuid() }).then(section => {
|
|
|
|
|
|
+ return ConfigSection.create({ name: UUID.uuid4() }).then(section => {
|
|
let config = new ConfigWithDefaults({ section, defaults, className });
|
|
let config = new ConfigWithDefaults({ section, defaults, className });
|
|
let data = config.get('foo');
|
|
let data = config.get('foo');
|
|
expect(data).to.be('bar');
|
|
expect(data).to.be('bar');
|
|
@@ -118,7 +118,7 @@ describe('jupyter.services - ConfigWithDefaults', () => {
|
|
it('should get a default config value', () => {
|
|
it('should get a default config value', () => {
|
|
let defaults: JSONObject = { spam: 'eggs' };
|
|
let defaults: JSONObject = { spam: 'eggs' };
|
|
let className = 'testclass';
|
|
let className = 'testclass';
|
|
- return ConfigSection.create({ name: uuid() }).then(section => {
|
|
|
|
|
|
+ return ConfigSection.create({ name: UUID.uuid4() }).then(section => {
|
|
let config = new ConfigWithDefaults({ section, defaults, className });
|
|
let config = new ConfigWithDefaults({ section, defaults, className });
|
|
let data = config.get('spam');
|
|
let data = config.get('spam');
|
|
expect(data).to.be('eggs');
|
|
expect(data).to.be('eggs');
|
|
@@ -128,7 +128,7 @@ describe('jupyter.services - ConfigWithDefaults', () => {
|
|
it('should get a default config value with no class', () => {
|
|
it('should get a default config value with no class', () => {
|
|
let defaults: JSONObject = { spam: 'eggs' };
|
|
let defaults: JSONObject = { spam: 'eggs' };
|
|
let className = 'testclass';
|
|
let className = 'testclass';
|
|
- return ConfigSection.create({ name: uuid() }).then(section => {
|
|
|
|
|
|
+ return ConfigSection.create({ name: UUID.uuid4() }).then(section => {
|
|
let config = new ConfigWithDefaults({ section, defaults, className });
|
|
let config = new ConfigWithDefaults({ section, defaults, className });
|
|
let data = config.get('spam');
|
|
let data = config.get('spam');
|
|
expect(data).to.be('eggs');
|
|
expect(data).to.be('eggs');
|
|
@@ -139,7 +139,7 @@ describe('jupyter.services - ConfigWithDefaults', () => {
|
|
let defaults: JSONObject = { foo: true };
|
|
let defaults: JSONObject = { foo: true };
|
|
let className = 'testclass';
|
|
let className = 'testclass';
|
|
let serverSettings = getRequestHandler(200, {foo: false });
|
|
let serverSettings = getRequestHandler(200, {foo: false });
|
|
- return ConfigSection.create({ name: uuid(), serverSettings }).then(section => {
|
|
|
|
|
|
+ return ConfigSection.create({ name: UUID.uuid4(), serverSettings }).then(section => {
|
|
let config = new ConfigWithDefaults({ section, defaults, className });
|
|
let config = new ConfigWithDefaults({ section, defaults, className });
|
|
let data = config.get('foo');
|
|
let data = config.get('foo');
|
|
expect(data).to.not.be.ok();
|
|
expect(data).to.not.be.ok();
|
|
@@ -153,7 +153,7 @@ describe('jupyter.services - ConfigWithDefaults', () => {
|
|
it('should set a value in a class immediately', () => {
|
|
it('should set a value in a class immediately', () => {
|
|
let className = 'testclass';
|
|
let className = 'testclass';
|
|
let section: IConfigSection;
|
|
let section: IConfigSection;
|
|
- return ConfigSection.create({ name: uuid() }).then(s => {
|
|
|
|
|
|
+ return ConfigSection.create({ name: UUID.uuid4() }).then(s => {
|
|
section = s;
|
|
section = s;
|
|
let config = new ConfigWithDefaults({ section, className });
|
|
let config = new ConfigWithDefaults({ section, className });
|
|
return config.set('foo', 'bar');
|
|
return config.set('foo', 'bar');
|
|
@@ -165,7 +165,7 @@ describe('jupyter.services - ConfigWithDefaults', () => {
|
|
|
|
|
|
it('should set a top level value', () => {
|
|
it('should set a top level value', () => {
|
|
let section: IConfigSection;
|
|
let section: IConfigSection;
|
|
- return ConfigSection.create({ name: uuid() }).then(s => {
|
|
|
|
|
|
+ return ConfigSection.create({ name: UUID.uuid4() }).then(s => {
|
|
section = s;
|
|
section = s;
|
|
let config = new ConfigWithDefaults({ section });
|
|
let config = new ConfigWithDefaults({ section });
|
|
let set = config.set('foo', 'bar');
|
|
let set = config.set('foo', 'bar');
|
|
@@ -179,7 +179,7 @@ describe('jupyter.services - ConfigWithDefaults', () => {
|
|
|
|
|
|
it('should fail for an invalid response', (done) => {
|
|
it('should fail for an invalid response', (done) => {
|
|
let serverSettings = getRequestHandler(200, {});
|
|
let serverSettings = getRequestHandler(200, {});
|
|
- ConfigSection.create({ name: uuid(), serverSettings }).then(section => {
|
|
|
|
|
|
+ ConfigSection.create({ name: UUID.uuid4(), serverSettings }).then(section => {
|
|
handleRequest(section, 201, {foo: 'bar'});
|
|
handleRequest(section, 201, {foo: 'bar'});
|
|
let config = new ConfigWithDefaults({ section });
|
|
let config = new ConfigWithDefaults({ section });
|
|
let set = config.set('foo', 'bar');
|
|
let set = config.set('foo', 'bar');
|