lorem-ipsum
Version:
Generates passages of lorem ipsum text suitable for use as placeholder copy in web pages, graphics, and more. Works in the browser, NodeJS, and React Native.
35 lines (29 loc) • 903 B
text/typescript
import { getPlatform } from ".";
import { SUPPORTED_PLATFORMS } from "../../constants/platforms";
import { CANNOT_DETERMINE_PLATFORM } from "../constants/errors";
describe("getPlatform", () => {
const cachedPlatform = process.platform;
const setPlatform = (platform?: string) => {
Object.defineProperty(process, "platform", {
value: platform,
});
};
afterEach(() => {
setPlatform(cachedPlatform);
});
test("Should throw an error if it cannot determine the paltform", () => {
setPlatform();
try {
getPlatform();
} catch (error) {
expect(error).toBeDefined();
expect(error.message).toEqual(CANNOT_DETERMINE_PLATFORM);
}
});
test("Should return the platform", () => {
Object.values(SUPPORTED_PLATFORMS).forEach((platform: string) => {
setPlatform(platform);
expect(getPlatform()).toEqual(platform);
});
});
});