karte-expo-plugin
Version:
Config plugin for karte-react-native package
61 lines (60 loc) • 2.1 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
const withKarteAndroid_1 = require("../withKarteAndroid");
jest.mock("fs", () => {
return {
existsSync: jest.fn(),
copyFileSync: jest.fn(),
promises: {
readFile: jest.fn(),
},
};
});
jest.mock("path", () => {
return {
resolve: jest.fn(),
};
});
jest.mock("@expo/config-plugins", () => {
return {
...jest.requireActual("@expo/config-plugins"),
withDangerousMod: jest.fn().mockImplementation((config, [_, callback]) => callback({
...config,
modRequest: {
projectRoot: "projectRoot",
},
})),
withGradleProperties: jest.fn(),
};
});
const exp = { name: "foo", slug: "bar" };
describe(withKarteAndroid_1.withKarteAndroid, () => {
it("should not throw if xml path is set", () => {
jest.spyOn(fs_1.default, "existsSync").mockImplementation((_) => {
return true;
});
expect(() => (0, withKarteAndroid_1.withKarteAndroid)(exp, {
karteInfoPlist: "",
karteXml: "karte.xml",
})).not.toThrow();
});
it("should throw if xml path is not set", () => {
jest.spyOn(fs_1.default, "existsSync").mockImplementation((_) => {
return true;
});
expect(() => (0, withKarteAndroid_1.withKarteAndroid)(exp, {})).toThrow(/^Path to karte.xml is not defined. Please specify the `expo.android.karteXml` field in app.json.$/);
});
it("should throw if xml file is not exists", () => {
jest.spyOn(fs_1.default, "existsSync").mockImplementation((_) => {
return false;
});
expect(() => (0, withKarteAndroid_1.withKarteAndroid)(exp, {
karteInfoPlist: "",
karteXml: "karte.xml",
})).toThrow(/karte.xml doesn't exist/);
});
});