Fixes js tests

This commit is contained in:
Shannon
2018-08-09 19:34:32 +10:00
parent d237fd7e26
commit 601c30c39a
9 changed files with 87 additions and 32 deletions

View File

@@ -123,7 +123,8 @@ describe('contentEditingHelper tests', function () {
var allProps = contentEditingHelper.getAllProps(content);
//act
formHelper.handleServerValidation({ "_Properties.bodyText.value": ["Required"] });
//note the null, that's because culture is null
formHelper.handleServerValidation({ "_Properties.bodyText.null.value": ["Required"] });
//assert
expect(serverValidationManager.items.length).toBe(1);
@@ -143,7 +144,8 @@ describe('contentEditingHelper tests', function () {
{
"Name": ["Required"],
"UpdateDate": ["Invalid date"],
"_Properties.bodyText.value": ["Required field"],
//note the null, that's because culture is null
"_Properties.bodyText.null.value": ["Required field"],
"_Properties.textarea": ["Invalid format"]
});
@@ -226,6 +228,7 @@ describe('contentEditingHelper tests', function () {
//act
var changed = contentEditingHelper.reBindChangedProperties(origContent, newContent);
//assert
expect(changed.length).toBe(2);
expect(changed[0].alias).toBe("grid");

View File

@@ -10,24 +10,39 @@ describe('file manager tests', function () {
describe('file management', function () {
it('adding a file adds to the collection', function () {
fileManager.setFiles('testProp', ["testFile"]);
fileManager.setFiles({
propertyAlias: 'testProp',
files: ["testFile"]
});
expect(fileManager.getFiles().length).toBe(1);
});
it('adding a file with the same property id replaces the existing one', function () {
fileManager.setFiles('testProp', ["testFile"]);
fileManager.setFiles('testProp', ["testFile2"]);
fileManager.setFiles({
propertyAlias: 'testProp',
files: ["testFile"]
});
fileManager.setFiles({
propertyAlias: 'testProp',
files: ["testFile2"]
});
expect(fileManager.getFiles().length).toBe(1);
expect(fileManager.getFiles()[0].file).toBe("testFile2");
});
it('clears all files', function () {
fileManager.setFiles('testProp1', ["testFile"]);
fileManager.setFiles('testProp2', ["testFile"]);
fileManager.setFiles({
propertyAlias: 'testProp',
files: ["testFile"]
});
fileManager.setFiles({
propertyAlias: 'testProp2',
files: ["testFile"]
});
expect(fileManager.getFiles().length).toBe(2);
fileManager.clearFiles();
expect(fileManager.getFiles().length).toBe(0);
});
});
});
});