Skip to content

Commit

Permalink
fix: adapt unit test and default ui5 version
Browse files Browse the repository at this point in the history
  • Loading branch information
marufrasully committed Jul 19, 2024
1 parent 249bee2 commit 79d1e3b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/context/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { Manifest } from "@sap-ux/project-access";
import { FetchResponse } from "@ui5-language-assistant/logic-utils";

export const DEFAULT_UI5_FRAMEWORK = "SAPUI5";
export const DEFAULT_UI5_VERSION = "1.71.61";
export const DEFAULT_UI5_VERSION = "1.71.69";
export const DEFAULT_UI5_VERSION_BASE = "1.71";
export const UI5_VERSION_S4_PLACEHOLDER = "${sap.ui5.dist.version}";
export const UI5_FRAMEWORK_CDN_BASE_URL = {
Expand Down
14 changes: 14 additions & 0 deletions packages/context/test/unit/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as services from "../../src/services";
import { UI5SemanticModel } from "@ui5-language-assistant/semantic-model-types";
import { getContext, isContext } from "../../src/api";
import type { Context } from "../../src/types";
import * as projectAccess from "@sap-ux/project-access";

describe("context", () => {
afterEach(() => {
Expand All @@ -13,6 +14,7 @@ describe("context", () => {

describe("getContext", () => {
it("get context", async () => {
// arrange
const getManifestDetailsStub = jest
.spyOn(manifest, "getManifestDetails")
.mockResolvedValue({
Expand All @@ -23,6 +25,14 @@ describe("context", () => {
flexEnabled: false,
minUI5Version: undefined,
});
const getManifestStub = jest
.spyOn(manifest, "getUI5Manifest")
.mockResolvedValue({
minUI5Version: ["2.0.0", "1.126.0"],
});
const getMinimumUI5VersionSub = jest
.spyOn(projectAccess, "getMinimumUI5Version")
.mockReturnValue("1.126.0");
const getCustomViewIdStub = jest
.spyOn(manifest, "getCustomViewId")
.mockResolvedValue("customViewId");
Expand All @@ -38,8 +48,12 @@ describe("context", () => {
const getServicesStub = jest
.spyOn(services, "getServices")
.mockResolvedValue({});
// act
const result = await getContext("path/to/xml/file");
// assert
expect(getManifestDetailsStub).toHaveBeenCalled();
expect(getManifestStub).toHaveBeenCalled();
expect(getMinimumUI5VersionSub).toHaveBeenCalled();
expect(getCustomViewIdStub).toHaveBeenCalled();
expect(getYamlDetailsStub).toHaveBeenCalled();
expect(getSemanticModelStub).toHaveBeenCalled();
Expand Down
2 changes: 1 addition & 1 deletion packages/context/test/unit/ui5-model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import { Response } from "node-fetch";
const GET_MODEL_TIMEOUT = 30000;
const FRAMEWORK = "SAPUI5";
const OPEN_FRAMEWORK = "OpenUI5";
const FALLBACK_VERSION = "1.71.61";
const FALLBACK_VERSION = "1.71.69";
const FALLBACK_VERSION_BASE = "1.71";
const UI5_VERSION_S4_PLACEHOLDER = "${sap.ui5.dist.version}";
const NO_CACHE_FOLDER = undefined;
Expand Down
2 changes: 1 addition & 1 deletion test-packages/test-utils/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export function buildUI5Model<T extends Partial<UI5SemanticModel>>(
opts: Partial<UI5SemanticModel>
): UI5SemanticModel & Pick<T, keyof UI5SemanticModel>;

export const DEFAULT_UI5_VERSION = "1.71.67";
export const DEFAULT_UI5_VERSION = "1.71.69";

// TODO: list should be updated continuously!
export type TestModelVersion =
Expand Down
2 changes: 1 addition & 1 deletion test-packages/test-utils/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ export {
} from "./utils/expect";
export { getFallbackPatchVersions } from "./utils/download-ui5-resources";

export const DEFAULT_UI5_VERSION = "1.71.67";
export const DEFAULT_UI5_VERSION = "1.71.69";
4 changes: 2 additions & 2 deletions test-packages/test-utils/src/utils/semantic-model-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const MODEL_CACHE: Record<TestModelVersion, UI5SemanticModel> =
Object.create(null);

const fixes: Record<TestModelVersion, TypeNameFix> = {
"1.71.67": {
"1.71.69": {
array: "any[]",
Array: "any[]",
bloolean: undefined,
Expand Down Expand Up @@ -258,7 +258,7 @@ type LibraryFix = (content: Json) => void;

// Library version -> library name -> fix function
const libraryFixes: Record<TestModelVersion, Record<string, LibraryFix[]>> = {
"1.71.67": {},
"1.71.69": {},
"1.84.41": {},
"1.96.27": {
"sap.ui.mdc": [
Expand Down

0 comments on commit 79d1e3b

Please sign in to comment.