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 = { ...@@ -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', () => { describe('SCIMTokenToggleArea', () => {
const FIXTURE = 'groups/saml_providers/show.html'; const FIXTURE = 'groups/saml_providers/show.html';
let scimTokenToggleArea; let scimTokenToggleArea;
let generateNewSCIMToken;
preloadFixtures(FIXTURE); preloadFixtures(FIXTURE);
beforeEach(() => { beforeEach(() => {
loadFixtures(FIXTURE); loadFixtures(FIXTURE);
generateNewSCIMToken = jasmine
.createSpy('generateNewSCIMToken')
.and.callFake(() => Promise.resolve(mockData));
spyOnDependency(SCIMTokenToggleArea, 'SCIMTokenService').and.returnValue({
generateNewSCIMToken,
});
scimTokenToggleArea = new SCIMTokenToggleArea( scimTokenToggleArea = new SCIMTokenToggleArea(
'.js-generate-scim-token-container', '.js-generate-scim-token-container',
'.js-scim-token-container', '.js-scim-token-container',
...@@ -67,15 +67,15 @@ describe('SCIMTokenToggleArea', () => { ...@@ -67,15 +67,15 @@ describe('SCIMTokenToggleArea', () => {
describe('resetSCIMToken', () => { describe('resetSCIMToken', () => {
it('does not trigger token generation when the confirm is canceled', () => { 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(); 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 => { 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 scimTokenToggleArea
.resetSCIMToken() .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