Files
cosmos-explorer/src/Explorer/SplashScreen/SplashScreen.test.ts
victor-meng 46ca952955 Add condition for showing quick start carousel (#1278)
* Add condition for showing quick start carousel

* Show coach mark when carousel is closed

* Add condition for showing quick start carousel and other UI changes

* Fix compile error

* Fix issue with coach mark

* Fix test

* Add new sample data, fix link url, fix e2e tests

* Fix e2e tests
2022-05-23 20:52:21 -07:00

37 lines
1.2 KiB
TypeScript

import { DataSamplesUtil } from "../DataSamples/DataSamplesUtil";
import Explorer from "../Explorer";
import { SplashScreen } from "./SplashScreen";
jest.mock("../Explorer");
const createExplorer = () => {
const mock = new Explorer();
return mock as jest.Mocked<Explorer>;
};
describe("SplashScreen", () => {
it("does not allow sample collection creation for non-supported api's", () => {
const explorerStub = createExplorer();
const dataSampleUtil = new DataSamplesUtil(explorerStub);
const createStub = jest
.spyOn(dataSampleUtil, "createGeneratorAsync")
.mockImplementation(() => Promise.reject(undefined));
// Sample is not supported
jest.spyOn(dataSampleUtil, "isSampleContainerCreationSupported").mockImplementation(() => false);
const splashScreen = new SplashScreen({ explorer: explorerStub });
jest.spyOn(splashScreen, "createDataSampleUtil").mockImplementation(() => dataSampleUtil);
const mainButtons = splashScreen.createMainItems();
// Press all buttons and make sure create doesn't get called
mainButtons.forEach((button) => {
try {
button.onClick();
} catch (e) {
// noop
}
});
expect(createStub).not.toHaveBeenCalled();
});
});