mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-08 17:24:01 -05:00
Fix ModelView tests (#7193)
This commit is contained in:
committed by
Aditya Bist
parent
7ebd1eb053
commit
3ac096b3b1
@@ -204,19 +204,19 @@ suite('ExtHostModelView Validation Tests', () => {
|
||||
let dropdownConfig = rootComponent.itemConfigs[3];
|
||||
|
||||
// Verify that the correct items were added
|
||||
assert.equal(listBoxConfig.componentShape.type, ModelComponentTypes.ListBox);
|
||||
assert.equal(groupLabelConfig.componentShape.type, ModelComponentTypes.Text);
|
||||
assert.equal(inputBoxConfig.componentShape.type, ModelComponentTypes.InputBox);
|
||||
assert.equal(dropdownConfig.componentShape.type, ModelComponentTypes.DropDown);
|
||||
assert.equal(listBoxConfig.componentShape.type, ModelComponentTypes.ListBox, `Unexpected ModelComponentType. Expected ListBox but got ${ModelComponentTypes[listBoxConfig.componentShape.type]}`);
|
||||
assert.equal(groupLabelConfig.componentShape.type, ModelComponentTypes.Text, `Unexpected ModelComponentType. Expected Text but got ${ModelComponentTypes[groupLabelConfig.componentShape.type]}`);
|
||||
assert.equal(inputBoxConfig.componentShape.type, ModelComponentTypes.InputBox, `Unexpected ModelComponentType. Expected InputBox but got ${ModelComponentTypes[inputBoxConfig.componentShape.type]}`);
|
||||
assert.equal(dropdownConfig.componentShape.type, ModelComponentTypes.DropDown, `Unexpected ModelComponentType. Expected DropDown but got ${ModelComponentTypes[dropdownConfig.componentShape.type]}`);
|
||||
|
||||
// Verify that the group title was set up correctly
|
||||
assert.equal(groupLabelConfig.componentShape.properties['value'], groupTitle);
|
||||
assert.equal((groupLabelConfig.config as TitledFormItemLayout).isGroupLabel, true);
|
||||
assert.equal(groupLabelConfig.componentShape.properties['value'], groupTitle, `Unexpected title. Expected ${groupTitle} but got ${groupLabelConfig.componentShape.properties['value']}`);
|
||||
assert.equal((groupLabelConfig.config as TitledFormItemLayout).isGroupLabel, true, `Unexpected value for isGroupLabel. Expected true but got ${(groupLabelConfig.config as TitledFormItemLayout).isGroupLabel}`);
|
||||
|
||||
// Verify that the components' layouts are correct
|
||||
assert.equal((listBoxConfig.config as azdata.FormItemLayout).horizontal, defaultLayout.horizontal);
|
||||
assert.equal((inputBoxConfig.config as azdata.FormItemLayout).horizontal, groupInputLayout.horizontal);
|
||||
assert.equal((dropdownConfig.config as azdata.FormItemLayout).horizontal, defaultLayout.horizontal);
|
||||
assert.equal((listBoxConfig.config as azdata.FormItemLayout).horizontal, defaultLayout.horizontal, `Unexpected layout for listBoxConfig. Expected defaultLayout.horizontal but got ${(listBoxConfig.config as azdata.FormItemLayout).horizontal}`);
|
||||
assert.equal((inputBoxConfig.config as azdata.FormItemLayout).horizontal, groupInputLayout.horizontal, `Unexpected layout for inputBoxConfig. Expected groupInputLayout.horizontal but got ${(inputBoxConfig.config as azdata.FormItemLayout).horizontal}`);
|
||||
assert.equal((dropdownConfig.config as azdata.FormItemLayout).horizontal, defaultLayout.horizontal, `Unexpected layout for dropdownConfig. Expected defaultLayout.horizontal but got ${(dropdownConfig.config as azdata.FormItemLayout).horizontal}`);
|
||||
});
|
||||
|
||||
test('Inserting and removing components from a container should work correctly', () => {
|
||||
@@ -235,19 +235,18 @@ suite('ExtHostModelView Validation Tests', () => {
|
||||
let flex = modelView.modelBuilder.flexContainer().withItems([listBox, inputBox]).component();
|
||||
modelView.initializeModel(flex);
|
||||
|
||||
assert.equal((flex as IWithItemConfig).itemConfigs.length, 2);
|
||||
const itemConfigs: InternalItemConfig[] = (flex as IWithItemConfig).itemConfigs;
|
||||
assert.equal(itemConfigs.length, 2, `Unexpected number of items in list. Expected 2, got ${itemConfigs.length} ${JSON.stringify(itemConfigs)}`);
|
||||
flex.insertItem(dropDown, 1);
|
||||
assert.equal((flex as IWithItemConfig).itemConfigs.length, 3);
|
||||
assert.equal((flex as IWithItemConfig).itemConfigs[1].toIItemConfig().componentShape.type, ModelComponentTypes.DropDown);
|
||||
assert.equal(itemConfigs.length, 3, `Unexpected number of items in list. Expected 3, got ${itemConfigs.length} ${JSON.stringify(itemConfigs)}`);
|
||||
assert.equal(itemConfigs[1].toIItemConfig().componentShape.type, ModelComponentTypes.DropDown, `Unexpected ModelComponentType. Expected DropDown but got ${ModelComponentTypes[itemConfigs[1].toIItemConfig().componentShape.type]}`);
|
||||
flex.removeItem(listBox);
|
||||
assert.equal((flex as IWithItemConfig).itemConfigs.length, 2);
|
||||
assert.equal((flex as IWithItemConfig).itemConfigs[0].toIItemConfig().componentShape.type, ModelComponentTypes.DropDown);
|
||||
assert.equal(itemConfigs.length, 2, `Unexpected number of items in list. Expected 2, got ${itemConfigs.length} ${JSON.stringify(itemConfigs)}`);
|
||||
assert.equal(itemConfigs[0].toIItemConfig().componentShape.type, ModelComponentTypes.DropDown, `Unexpected ModelComponentType. Expected DropDown but got ${ModelComponentTypes[itemConfigs[0].toIItemConfig().componentShape.type]}`);
|
||||
});
|
||||
|
||||
test('Inserting component give negative number fails', () => {
|
||||
// Set up the mock proxy to save the component that gets initialized so that it can be verified
|
||||
let rootComponent: IComponentShape;
|
||||
mockProxy.setup(x => x.$initializeModel(It.isAny(), It.isAny())).callback((handle, componentShape) => rootComponent = componentShape);
|
||||
mockProxy.setup(x => x.$initializeModel(It.isAny(), It.isAny())).callback((handle, componentShape) => { });
|
||||
mockProxy.setup(x => x.$addToContainer(It.isAny(), It.isAny(), It.isAny(), undefined)).returns(() => Promise.resolve());
|
||||
mockProxy.setup(x => x.$addToContainer(It.isAny(), It.isAny(), It.isAny(), It.isAny())).returns(() => Promise.resolve());
|
||||
mockProxy.setup(x => x.$removeFromContainer(It.isAny(), It.isAny(), It.isAny())).returns(() => Promise.resolve());
|
||||
@@ -260,14 +259,13 @@ suite('ExtHostModelView Validation Tests', () => {
|
||||
let flex = modelView.modelBuilder.flexContainer().withItems([listBox, inputBox]).component();
|
||||
modelView.initializeModel(flex);
|
||||
|
||||
assert.equal((flex as IWithItemConfig).itemConfigs.length, 2);
|
||||
assert.throws(() => flex.insertItem(dropDown, -1));
|
||||
const itemConfigs: InternalItemConfig[] = (flex as IWithItemConfig).itemConfigs;
|
||||
assert.equal(itemConfigs.length, 2, `Unexpected number of items in list. Expected 2, got ${itemConfigs.length} ${JSON.stringify(itemConfigs)}`);
|
||||
assert.throws(() => flex.insertItem(dropDown, -1), `Didn't get expected exception when calling insertItem with invalid index -1`);
|
||||
});
|
||||
|
||||
test('Inserting component give wrong number fails', () => {
|
||||
// Set up the mock proxy to save the component that gets initialized so that it can be verified
|
||||
let rootComponent: IComponentShape;
|
||||
mockProxy.setup(x => x.$initializeModel(It.isAny(), It.isAny())).callback((handle, componentShape) => rootComponent = componentShape);
|
||||
mockProxy.setup(x => x.$initializeModel(It.isAny(), It.isAny())).callback((handle, componentShape) => { });
|
||||
mockProxy.setup(x => x.$addToContainer(It.isAny(), It.isAny(), It.isAny(), undefined)).returns(() => Promise.resolve());
|
||||
mockProxy.setup(x => x.$addToContainer(It.isAny(), It.isAny(), It.isAny(), It.isAny())).returns(() => Promise.resolve());
|
||||
mockProxy.setup(x => x.$removeFromContainer(It.isAny(), It.isAny(), It.isAny())).returns(() => Promise.resolve());
|
||||
@@ -280,14 +278,13 @@ suite('ExtHostModelView Validation Tests', () => {
|
||||
let flex = modelView.modelBuilder.flexContainer().withItems([listBox, inputBox]).component();
|
||||
modelView.initializeModel(flex);
|
||||
|
||||
assert.equal((flex as IWithItemConfig).itemConfigs.length, 2);
|
||||
assert.throws(() => flex.insertItem(dropDown, 10));
|
||||
const itemConfigs: InternalItemConfig[] = (flex as IWithItemConfig).itemConfigs;
|
||||
assert.equal(itemConfigs.length, 2, `Unexpected number of items in list. Expected 2, got ${itemConfigs.length} ${JSON.stringify(itemConfigs)}`);
|
||||
assert.throws(() => flex.insertItem(dropDown, 10), `Didn't get expected exception when calling insertItem with invalid index 10`);
|
||||
});
|
||||
|
||||
test('Inserting component give end of the list fails', () => {
|
||||
// Set up the mock proxy to save the component that gets initialized so that it can be verified
|
||||
let rootComponent: IComponentShape;
|
||||
mockProxy.setup(x => x.$initializeModel(It.isAny(), It.isAny())).callback((handle, componentShape) => rootComponent = componentShape);
|
||||
test('Inserting component give end of the list succeeds', () => {
|
||||
mockProxy.setup(x => x.$initializeModel(It.isAny(), It.isAny())).callback((handle, componentShape) => { });
|
||||
mockProxy.setup(x => x.$addToContainer(It.isAny(), It.isAny(), It.isAny(), undefined)).returns(() => Promise.resolve());
|
||||
mockProxy.setup(x => x.$addToContainer(It.isAny(), It.isAny(), It.isAny(), It.isAny())).returns(() => Promise.resolve());
|
||||
mockProxy.setup(x => x.$removeFromContainer(It.isAny(), It.isAny(), It.isAny())).returns(() => Promise.resolve());
|
||||
@@ -300,8 +297,10 @@ suite('ExtHostModelView Validation Tests', () => {
|
||||
let flex = modelView.modelBuilder.flexContainer().withItems([listBox, inputBox]).component();
|
||||
modelView.initializeModel(flex);
|
||||
|
||||
assert.equal((flex as IWithItemConfig).itemConfigs.length, 2);
|
||||
assert.throws(() => flex.insertItem(dropDown, 2));
|
||||
const itemConfigs: InternalItemConfig[] = (flex as IWithItemConfig).itemConfigs;
|
||||
assert.equal(itemConfigs.length, 2, `Unexpected number of items in list. Expected 2, got ${itemConfigs.length} ${JSON.stringify(itemConfigs)}`);
|
||||
flex.insertItem(dropDown, 2);
|
||||
assert.equal(itemConfigs.length, 3, `Unexpected number of items in list. Expected 3, got ${itemConfigs.length} ${JSON.stringify(itemConfigs)}`);
|
||||
});
|
||||
|
||||
test('Removing a component that does not exist does not fail', () => {
|
||||
@@ -319,17 +318,16 @@ suite('ExtHostModelView Validation Tests', () => {
|
||||
let flex = modelView.modelBuilder.flexContainer().withItems([listBox, inputBox]).component();
|
||||
modelView.initializeModel(flex);
|
||||
|
||||
const itemConfigs: InternalItemConfig[] = (flex as IWithItemConfig).itemConfigs;
|
||||
let result = flex.removeItem(dropDown);
|
||||
assert.equal(result, false);
|
||||
assert.equal((flex as IWithItemConfig).itemConfigs.length, 2);
|
||||
assert.equal((flex as IWithItemConfig).itemConfigs[0].toIItemConfig().componentShape.type, ModelComponentTypes.ListBox);
|
||||
assert.equal(itemConfigs.length, 2, `Unexpected number of items in list. Expected 2, got ${itemConfigs.length} ${JSON.stringify(itemConfigs)}`);
|
||||
assert.equal(itemConfigs[0].toIItemConfig().componentShape.type, ModelComponentTypes.ListBox, `Unexpected ModelComponentType. Expected ListBox but got ${ModelComponentTypes[itemConfigs[0].toIItemConfig().componentShape.type]}`);
|
||||
});
|
||||
|
||||
|
||||
test('Inserting and removing component in a form should work correctly', () => {
|
||||
// Set up the mock proxy to save the component that gets initialized so that it can be verified
|
||||
let rootComponent: IComponentShape;
|
||||
mockProxy.setup(x => x.$initializeModel(It.isAny(), It.isAny())).callback((handle, componentShape) => rootComponent = componentShape);
|
||||
mockProxy.setup(x => x.$initializeModel(It.isAny(), It.isAny())).callback((handle, componentShape) => { });
|
||||
mockProxy.setup(x => x.$addToContainer(It.isAny(), It.isAny(), It.isAny(), undefined)).returns(() => Promise.resolve());
|
||||
mockProxy.setup(x => x.$addToContainer(It.isAny(), It.isAny(), It.isAny(), It.isAny())).returns(() => Promise.resolve());
|
||||
mockProxy.setup(x => x.$removeFromContainer(It.isAny(), It.isAny(), It.isAny())).returns(() => Promise.resolve());
|
||||
@@ -364,18 +362,19 @@ suite('ExtHostModelView Validation Tests', () => {
|
||||
let form = formBuilder.component();
|
||||
modelView.initializeModel(formBuilder.component());
|
||||
|
||||
assert.equal((form as IWithItemConfig).itemConfigs.length, 1);
|
||||
const itemConfigs: InternalItemConfig[] = (form as IWithItemConfig).itemConfigs;
|
||||
assert.equal(itemConfigs.length, 1);
|
||||
formBuilder.insertFormItem(inputBoxFormItem, 0);
|
||||
assert.equal((form as IWithItemConfig).itemConfigs.length, 2);
|
||||
assert.equal((form as IWithItemConfig).itemConfigs[0].toIItemConfig().componentShape.type, ModelComponentTypes.InputBox);
|
||||
assert.equal(itemConfigs.length, 2, `Unexpected number of items in list. Expected 2, got ${itemConfigs.length} ${JSON.stringify(itemConfigs)}`);
|
||||
assert.equal(itemConfigs[0].toIItemConfig().componentShape.type, ModelComponentTypes.InputBox, `Unexpected ModelComponentType. Expected InputBox but got ${ModelComponentTypes[itemConfigs[0].toIItemConfig().componentShape.type]}`);
|
||||
formBuilder.insertFormItem(groupItems, 0);
|
||||
assert.equal((form as IWithItemConfig).itemConfigs.length, 5);
|
||||
assert.equal(itemConfigs.length, 5, `Unexpected number of items in list. Expected 5, got ${itemConfigs.length} ${JSON.stringify(itemConfigs)}`);
|
||||
formBuilder.removeFormItem(listBoxFormItem);
|
||||
assert.equal((form as IWithItemConfig).itemConfigs.length, 4);
|
||||
assert.equal(itemConfigs.length, 4, `Unexpected number of items in list. Expected 4, got ${itemConfigs.length} ${JSON.stringify(itemConfigs)}`);
|
||||
formBuilder.removeFormItem(groupItems);
|
||||
assert.equal((form as IWithItemConfig).itemConfigs.length, 1);
|
||||
assert.equal(itemConfigs.length, 1, `Unexpected number of items in list. Expected 1, got ${itemConfigs.length} ${JSON.stringify(itemConfigs)}`);
|
||||
formBuilder.addFormItem(listBoxFormItem);
|
||||
assert.equal((form as IWithItemConfig).itemConfigs.length, 2);
|
||||
assert.equal((form as IWithItemConfig).itemConfigs[1].toIItemConfig().componentShape.type, ModelComponentTypes.ListBox);
|
||||
assert.equal(itemConfigs.length, 2, `Unexpected number of items in list. Expected 2, got ${itemConfigs.length} ${JSON.stringify(itemConfigs)}`);
|
||||
assert.equal(itemConfigs[1].toIItemConfig().componentShape.type, ModelComponentTypes.ListBox, `Unexpected ModelComponentType. Expected ListBox but got ${ModelComponentTypes[itemConfigs[1].toIItemConfig().componentShape.type]}`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -134,107 +134,103 @@ suite('ComponentBase Tests', () => {
|
||||
testComponent.validate();
|
||||
});
|
||||
|
||||
test('Inserting a component to a container adds the component to the right place', done => {
|
||||
test('Inserting a component to a container adds the component to the right place', () => {
|
||||
testContainer.addToContainer(testComponent.descriptor, undefined);
|
||||
assert.equal(testContainer.TestItems.length, 1);
|
||||
assert.equal(testContainer.TestItems.length, 1, `Unexpected number of items. Expected 1 got ${testContainer.TestItems.length} : ${JSON.stringify(testContainer.TestItems)}`);
|
||||
testContainer.addToContainer(testComponent2.descriptor, undefined, 0);
|
||||
assert.equal(testContainer.TestItems.length, 2);
|
||||
assert.equal(testContainer.TestItems.length, 2, `Unexpected number of items. Expected 2 got ${testContainer.TestItems.length} : ${JSON.stringify(testContainer.TestItems)}`);
|
||||
assert.equal(testContainer.TestItems[0].descriptor.id, testComponent2.descriptor.id);
|
||||
done();
|
||||
});
|
||||
|
||||
test('Inserting a component to a container given negative index fails', done => {
|
||||
test('Inserting a component to a container given negative index fails', () => {
|
||||
testContainer.addToContainer(testComponent.descriptor, undefined);
|
||||
assert.equal(testContainer.TestItems.length, 1);
|
||||
assert.equal(testContainer.TestItems.length, 1, `Unexpected number of items. Expected 1 got ${testContainer.TestItems.length} : ${JSON.stringify(testContainer.TestItems)}`);
|
||||
assert.throws(() => testContainer.addToContainer(testComponent2.descriptor, undefined, -1));
|
||||
done();
|
||||
});
|
||||
|
||||
test('Inserting a component to a container given wrong index fails', done => {
|
||||
test('Inserting a component to a container given wrong index fails', () => {
|
||||
testContainer.addToContainer(testComponent.descriptor, undefined);
|
||||
assert.equal(testContainer.TestItems.length, 1);
|
||||
assert.equal(testContainer.TestItems.length, 1, `Unexpected number of items. Expected 1 got ${testContainer.TestItems.length} : ${JSON.stringify(testContainer.TestItems)}`);
|
||||
assert.throws(() => testContainer.addToContainer(testComponent2.descriptor, undefined, 10));
|
||||
done();
|
||||
});
|
||||
|
||||
test('Inserting a component to a container given end of list fails', done => {
|
||||
test('Inserting a component to a container given end of list succeeds', () => {
|
||||
testContainer.addToContainer(testComponent.descriptor, undefined);
|
||||
assert.equal(testContainer.TestItems.length, 1);
|
||||
assert.throws(() => testContainer.addToContainer(testComponent2.descriptor, undefined, 1));
|
||||
done();
|
||||
assert.equal(testContainer.TestItems.length, 1, `Unexpected number of items. Expected 1 got ${testContainer.TestItems.length} : ${JSON.stringify(testContainer.TestItems)}`);
|
||||
testContainer.addToContainer(testComponent2.descriptor, undefined, 1);
|
||||
assert.equal(testContainer.TestItems.length, 2, `Unexpected number of items. Expected 2 got ${testContainer.TestItems.length} : ${JSON.stringify(testContainer.TestItems)}`);
|
||||
});
|
||||
|
||||
test('Removing a component the does not exist does not make change in the items', done => {
|
||||
test('Removing a component the does not exist does not make change in the items', () => {
|
||||
testContainer.addToContainer(testComponent.descriptor, undefined);
|
||||
assert.equal(testContainer.TestItems.length, 1);
|
||||
assert.equal(testContainer.TestItems.length, 1, `Unexpected number of items. Expected 1 got ${testContainer.TestItems.length} : ${JSON.stringify(testContainer.TestItems)}`);
|
||||
testContainer.removeFromContainer(testComponent2.descriptor);
|
||||
assert.equal(testContainer.TestItems.length, 1);
|
||||
done();
|
||||
assert.equal(testContainer.TestItems.length, 1, `Unexpected number of items. Expected 1 got ${testContainer.TestItems.length} : ${JSON.stringify(testContainer.TestItems)}`);
|
||||
});
|
||||
|
||||
test('Removing a component removes it from items', done => {
|
||||
test('Removing a component removes it from items', () => {
|
||||
testContainer.addToContainer(testComponent.descriptor, undefined);
|
||||
testContainer.addToContainer(testComponent2.descriptor, undefined);
|
||||
assert.equal(testContainer.TestItems.length, 2);
|
||||
assert.equal(testContainer.TestItems.length, 2, `Unexpected number of items. Expected 2 got ${testContainer.TestItems.length} : ${JSON.stringify(testContainer.TestItems)}`);
|
||||
testContainer.removeFromContainer(testComponent.descriptor);
|
||||
assert.equal(testContainer.TestItems.length, 1);
|
||||
assert.equal(testContainer.TestItems.length, 1, `Unexpected number of items. Expected 1 got ${testContainer.TestItems.length} : ${JSON.stringify(testContainer.TestItems)}`);
|
||||
assert.equal(testContainer.TestItems[0].descriptor.id, testComponent2.descriptor.id);
|
||||
done();
|
||||
});
|
||||
|
||||
test('Container dost not add same component twice', done => {
|
||||
test('Container dost not add same component twice', () => {
|
||||
testContainer.addToContainer(testComponent.descriptor, undefined);
|
||||
assert.equal(testContainer.TestItems.length, 1);
|
||||
assert.equal(testContainer.TestItems.length, 1, `Unexpected number of items. Expected 1 got ${testContainer.TestItems.length} : ${JSON.stringify(testContainer.TestItems)}`);
|
||||
testContainer.addToContainer(testComponent.descriptor, 0);
|
||||
assert.equal(testContainer.TestItems.length, 1);
|
||||
done();
|
||||
assert.equal(testContainer.TestItems.length, 1, `Unexpected number of items. Expected 1 got ${testContainer.TestItems.length} : ${JSON.stringify(testContainer.TestItems)}`);
|
||||
});
|
||||
|
||||
|
||||
test('Component convert size should add px', done => {
|
||||
let expected = '100px';
|
||||
let actual = testComponent.convertSize(100);
|
||||
test('Component convert size should add px', () => {
|
||||
const expected = '100px';
|
||||
const actual = testComponent.convertSize(100);
|
||||
assert.equal(expected, actual);
|
||||
|
||||
actual = testComponent.convertSize('100px');
|
||||
assert.equal(expected, actual);
|
||||
|
||||
expected = '100%';
|
||||
actual = testComponent.convertSize('100%');
|
||||
assert.equal(expected, actual);
|
||||
done();
|
||||
});
|
||||
|
||||
test('Component convert size should keep value if ends with %', done => {
|
||||
let expected = '100%';
|
||||
let actual = testComponent.convertSize('100%');
|
||||
test('Component convert size should not add px if it already has it', () => {
|
||||
const expected = '100px';
|
||||
const actual = testComponent.convertSize('100px');
|
||||
assert.equal(expected, actual);
|
||||
done();
|
||||
});
|
||||
|
||||
test('Component convert size should return the default value given undefined value %', done => {
|
||||
let expected = '200';
|
||||
let actual = testComponent.convertSize(undefined, '200');
|
||||
test('Component convert size should not add px if it is a percent value', () => {
|
||||
const expected = '100%';
|
||||
const actual = testComponent.convertSize('100%');
|
||||
assert.equal(expected, actual);
|
||||
done();
|
||||
});
|
||||
|
||||
test('Component convert to number should return size without px', done => {
|
||||
let expected = 200;
|
||||
let actual = testComponent.convertSizeToNumber('200px');
|
||||
test('Component convert size should keep value if ends with %', () => {
|
||||
const expected = '100%';
|
||||
const actual = testComponent.convertSize('100%');
|
||||
assert.equal(expected, actual);
|
||||
|
||||
actual = testComponent.convertSizeToNumber('200');
|
||||
assert.equal(expected, actual);
|
||||
done();
|
||||
});
|
||||
|
||||
test('Component convert to number should return 0 given undefined', done => {
|
||||
let expected = 0;
|
||||
let actual = testComponent.convertSizeToNumber(undefined);
|
||||
test('Component convert size should return the default value given undefined value %', () => {
|
||||
const expected = '200';
|
||||
const actual = testComponent.convertSize(undefined, '200');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
done();
|
||||
test('Component convert to number should return size without px', () => {
|
||||
const expected = 200;
|
||||
const actual = testComponent.convertSizeToNumber('200px');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('Component convert to number should return same value if already plain number', () => {
|
||||
const expected = 200;
|
||||
const actual = testComponent.convertSizeToNumber('200');
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
test('Component convert to number should return 0 given undefined', () => {
|
||||
const expected = 0;
|
||||
const actual = testComponent.convertSizeToNumber(undefined);
|
||||
assert.equal(expected, actual);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user