tests: mock the insights dependency to avoid failures

This commit is contained in:
Aleksandar Todorov 2020-11-16 14:08:24 +02:00 committed by Alexander Todorov
parent 48fcbda28d
commit bf7d551865

View file

@ -27,6 +27,30 @@ async function verifyCancelButton(cancel) {
);
}
// mock the insights dependency
beforeAll(() => {
global.insights = {
chrome: {
auth: {
getUser: () => {
return {
identity: {
internal: {
org_id: 5
}
}
};
}
}
}
};
});
// restore global mock
afterAll(() => {
global.insights = undefined;
});
describe('Create Image Wizard', () => {
beforeEach(() => {
renderWithReduxRouter(<CreateImageWizard />);
@ -216,7 +240,7 @@ describe('Step Registration', () => {
.click();
const organizationId = screen.getByLabelText('Organization ID');
expect(organizationId).not.toHaveValue();
expect(organizationId).toHaveValue('5');
expect(organizationId).toBeDisabled();
// can't getByLabelText b/c the label contains an extra <span>