debian-mirror-gitlab/spec/frontend/ide/stores/modules/terminal/messages_spec.js
2021-03-11 19:13:27 +05:30

40 lines
1.3 KiB
JavaScript

import { escape } from 'lodash';
import { TEST_HOST } from 'spec/test_constants';
import * as messages from '~/ide/stores/modules/terminal/messages';
import httpStatus from '~/lib/utils/http_status';
import { sprintf } from '~/locale';
const TEST_HELP_URL = `${TEST_HOST}/help`;
describe('IDE store terminal messages', () => {
describe('configCheckError', () => {
it('returns job error, with status UNPROCESSABLE_ENTITY', () => {
const result = messages.configCheckError(httpStatus.UNPROCESSABLE_ENTITY, TEST_HELP_URL);
expect(result).toBe(
sprintf(
messages.ERROR_CONFIG,
{
codeStart: `<code>`,
codeEnd: `</code>`,
helpStart: `<a href="${escape(TEST_HELP_URL)}" target="_blank">`,
helpEnd: '</a>',
},
false,
),
);
});
it('returns permission error, with status FORBIDDEN', () => {
const result = messages.configCheckError(httpStatus.FORBIDDEN, TEST_HELP_URL);
expect(result).toBe(messages.ERROR_PERMISSION);
});
it('returns unexpected error, with unexpected status', () => {
const result = messages.configCheckError(httpStatus.NOT_FOUND, TEST_HELP_URL);
expect(result).toBe(messages.UNEXPECTED_ERROR_CONFIG);
});
});
});