summaryrefslogtreecommitdiff
path: root/spec/frontend/ide/components/terminal/empty_state_spec.js
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 11:18:50 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 11:18:50 +0000
commit8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch)
treea77e7fe7a93de11213032ed4ab1f33a3db51b738 /spec/frontend/ide/components/terminal/empty_state_spec.js
parent00b35af3db1abfe813a778f643dad221aad51fca (diff)
downloadgitlab-ce-8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781.tar.gz
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/frontend/ide/components/terminal/empty_state_spec.js')
-rw-r--r--spec/frontend/ide/components/terminal/empty_state_spec.js107
1 files changed, 107 insertions, 0 deletions
diff --git a/spec/frontend/ide/components/terminal/empty_state_spec.js b/spec/frontend/ide/components/terminal/empty_state_spec.js
new file mode 100644
index 00000000000..a3f2089608d
--- /dev/null
+++ b/spec/frontend/ide/components/terminal/empty_state_spec.js
@@ -0,0 +1,107 @@
+import { shallowMount } from '@vue/test-utils';
+import { GlLoadingIcon } from '@gitlab/ui';
+import { TEST_HOST } from 'spec/test_constants';
+import TerminalEmptyState from '~/ide/components/terminal/empty_state.vue';
+
+const TEST_HELP_PATH = `${TEST_HOST}/help/test`;
+const TEST_PATH = `${TEST_HOST}/home.png`;
+const TEST_HTML_MESSAGE = 'lorem <strong>ipsum</strong>';
+
+describe('IDE TerminalEmptyState', () => {
+ let wrapper;
+
+ const factory = (options = {}) => {
+ wrapper = shallowMount(TerminalEmptyState, {
+ ...options,
+ });
+ };
+
+ afterEach(() => {
+ wrapper.destroy();
+ });
+
+ it('does not show illustration, if no path specified', () => {
+ factory();
+
+ expect(wrapper.find('.svg-content').exists()).toBe(false);
+ });
+
+ it('shows illustration with path', () => {
+ factory({
+ propsData: {
+ illustrationPath: TEST_PATH,
+ },
+ });
+
+ const img = wrapper.find('.svg-content img');
+
+ expect(img.exists()).toBe(true);
+ expect(img.attributes('src')).toEqual(TEST_PATH);
+ });
+
+ it('when loading, shows loading icon', () => {
+ factory({
+ propsData: {
+ isLoading: true,
+ },
+ });
+
+ expect(wrapper.find(GlLoadingIcon).exists()).toBe(true);
+ });
+
+ it('when not loading, does not show loading icon', () => {
+ factory({
+ propsData: {
+ isLoading: false,
+ },
+ });
+
+ expect(wrapper.find(GlLoadingIcon).exists()).toBe(false);
+ });
+
+ describe('when valid', () => {
+ let button;
+
+ beforeEach(() => {
+ factory({
+ propsData: {
+ isLoading: false,
+ isValid: true,
+ helpPath: TEST_HELP_PATH,
+ },
+ });
+
+ button = wrapper.find('button');
+ });
+
+ it('shows button', () => {
+ expect(button.text()).toEqual('Start Web Terminal');
+ expect(button.attributes('disabled')).toBeFalsy();
+ });
+
+ it('emits start when button is clicked', () => {
+ expect(wrapper.emitted().start).toBeFalsy();
+
+ button.trigger('click');
+
+ expect(wrapper.emitted().start).toHaveLength(1);
+ });
+
+ it('shows help path link', () => {
+ expect(wrapper.find('a').attributes('href')).toEqual(TEST_HELP_PATH);
+ });
+ });
+
+ it('when not valid, shows disabled button and message', () => {
+ factory({
+ propsData: {
+ isLoading: false,
+ isValid: false,
+ message: TEST_HTML_MESSAGE,
+ },
+ });
+
+ expect(wrapper.find('button').attributes('disabled')).not.toBe(null);
+ expect(wrapper.find('.bs-callout').element.innerHTML).toEqual(TEST_HTML_MESSAGE);
+ });
+});