Commit dbd7db1c authored by Martin Wortschack's avatar Martin Wortschack

Merge branch 'vs-migrate-scim-token-to-jest' into 'master'

Migrate ee/spec/javascripts/scim_token/ to Jest

Closes #194305

See merge request gitlab-org/gitlab!26744
parents e7d5d71f 5471d133
......@@ -8,22 +8,22 @@ const mockData = {
},
};
const mockGenerateNewSCIMToken = jest.fn(() => Promise.resolve(mockData));
jest.mock('ee/saml_providers/scim_token_service', () => {
return jest.fn(() => {
return { generateNewSCIMToken: mockGenerateNewSCIMToken };
});
});
describe('SCIMTokenToggleArea', () => {
const FIXTURE = 'groups/saml_providers/show.html';
let scimTokenToggleArea;
let generateNewSCIMToken;
preloadFixtures(FIXTURE);
beforeEach(() => {
loadFixtures(FIXTURE);
generateNewSCIMToken = jasmine
.createSpy('generateNewSCIMToken')
.and.callFake(() => Promise.resolve(mockData));
spyOnDependency(SCIMTokenToggleArea, 'SCIMTokenService').and.returnValue({
generateNewSCIMToken,
});
scimTokenToggleArea = new SCIMTokenToggleArea(
'.js-generate-scim-token-container',
'.js-scim-token-container',
......@@ -67,15 +67,15 @@ describe('SCIMTokenToggleArea', () => {
describe('resetSCIMToken', () => {
it('does not trigger token generation when the confirm is canceled', () => {
spyOn(window, 'confirm').and.returnValue(false);
jest.spyOn(window, 'confirm').mockReturnValue(false);
scimTokenToggleArea.resetSCIMToken();
expect(generateNewSCIMToken).not.toHaveBeenCalled();
expect(mockGenerateNewSCIMToken).not.toHaveBeenCalled();
});
it('populates the scim form with the token data if the confirm is accepted', done => {
spyOn(window, 'confirm').and.returnValue(true);
jest.spyOn(window, 'confirm').mockReturnValue(true);
scimTokenToggleArea
.resetSCIMToken()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment