Skip to content

Commit

Permalink
[FIX] ui5 use: Corrupt UI5 configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
matz3 committed Jan 11, 2021
1 parent 95a81f9 commit c207e1e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/framework/updateYaml.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,16 @@ function applyChanges(string, changes) {
value: change.value
};
} else if (change.type === "insert") {
let startIndex = positionToIndex(change.parentPosition.end);
if (change.parentPosition.end.column > 1) {
// When end.column is not 1 we expect it to be the end of the line
// so the index needs to be increased by 1 to insert into the next line
startIndex++;
}
const endIndex = startIndex;
return {
startIndex: positionToIndex(change.parentPosition.end) + 1,
endIndex: positionToIndex(change.parentPosition.end) + 1,
startIndex,
endIndex,
value: change.value
};
}
Expand Down
38 changes: 38 additions & 0 deletions test/lib/framework/updateYaml.js
Original file line number Diff line number Diff line change
Expand Up @@ -819,3 +819,41 @@ metadata:
t.is(error.message, "Could not find project with name my-project-3 in YAML: ui5.yaml");
t.is(t.context.fsWriteFileStub.callCount, 0, "fs.writeFile should not be called");
});

test.serial("Should add version property to object", async (t) => {
t.context.fsReadFileStub.yieldsAsync(null, `
metadata:
name: my-project
framework:
name: OpenUI5
libraries:
- name: sap.ui.core
something: else
`);

await updateYaml({
project: {
path: "my-project",
metadata: {"name": "my-project"}
},
data: {
framework: {
version: "1.85.0"
}
}
});

t.is(t.context.fsWriteFileStub.callCount, 1, "fs.writeFile should be called once");
t.deepEqual(t.context.fsWriteFileStub.getCall(0).args[0], path.join("my-project", "ui5.yaml"),
"writeFile should be called with expected path");
t.deepEqual(t.context.fsWriteFileStub.getCall(0).args[1], `
metadata:
name: my-project
framework:
name: OpenUI5
libraries:
- name: sap.ui.core
version: "1.85.0"
something: else
`, "writeFile should be called with expected content");
});

0 comments on commit c207e1e

Please sign in to comment.