From 1fa79760ad2d4bd67f5c5a27f372a7533b9b7c69 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 10 Mar 2020 12:08:16 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- .../javascripts/blob/3d_viewer/mesh_object_spec.js | 32 ---- spec/javascripts/blob/viewer/index_spec.js | 180 --------------------- 2 files changed, 212 deletions(-) delete mode 100644 spec/javascripts/blob/3d_viewer/mesh_object_spec.js delete mode 100644 spec/javascripts/blob/viewer/index_spec.js (limited to 'spec/javascripts') diff --git a/spec/javascripts/blob/3d_viewer/mesh_object_spec.js b/spec/javascripts/blob/3d_viewer/mesh_object_spec.js deleted file mode 100644 index 60be285039f..00000000000 --- a/spec/javascripts/blob/3d_viewer/mesh_object_spec.js +++ /dev/null @@ -1,32 +0,0 @@ -import { BoxGeometry } from 'three/build/three.module'; -import MeshObject from '~/blob/3d_viewer/mesh_object'; - -describe('Mesh object', () => { - it('defaults to non-wireframe material', () => { - const object = new MeshObject(new BoxGeometry(10, 10, 10)); - - expect(object.material.wireframe).toBeFalsy(); - }); - - it('changes to wirefame material', () => { - const object = new MeshObject(new BoxGeometry(10, 10, 10)); - - object.changeMaterial('wireframe'); - - expect(object.material.wireframe).toBeTruthy(); - }); - - it('scales object down', () => { - const object = new MeshObject(new BoxGeometry(10, 10, 10)); - const { radius } = object.geometry.boundingSphere; - - expect(radius).not.toBeGreaterThan(4); - }); - - it('does not scale object down', () => { - const object = new MeshObject(new BoxGeometry(1, 1, 1)); - const { radius } = object.geometry.boundingSphere; - - expect(radius).toBeLessThan(1); - }); -}); diff --git a/spec/javascripts/blob/viewer/index_spec.js b/spec/javascripts/blob/viewer/index_spec.js deleted file mode 100644 index 06c06613887..00000000000 --- a/spec/javascripts/blob/viewer/index_spec.js +++ /dev/null @@ -1,180 +0,0 @@ -/* eslint-disable no-new */ - -import $ from 'jquery'; -import MockAdapter from 'axios-mock-adapter'; -import BlobViewer from '~/blob/viewer/index'; -import axios from '~/lib/utils/axios_utils'; - -describe('Blob viewer', () => { - let blob; - let mock; - - preloadFixtures('snippets/show.html'); - - beforeEach(() => { - mock = new MockAdapter(axios); - - loadFixtures('snippets/show.html'); - $('#modal-upload-blob').remove(); - - blob = new BlobViewer(); - - mock.onGet('http://test.host/snippets/1.json?viewer=rich').reply(200, { - html: '
testing
', - }); - - mock.onGet('http://test.host/snippets/1.json?viewer=simple').reply(200, { - html: '
testing
', - }); - - spyOn(axios, 'get').and.callThrough(); - }); - - afterEach(() => { - mock.restore(); - window.location.hash = ''; - }); - - it('loads source file after switching views', done => { - document.querySelector('.js-blob-viewer-switch-btn[data-viewer="simple"]').click(); - - setTimeout(() => { - expect( - document - .querySelector('.js-blob-viewer-switch-btn[data-viewer="simple"]') - .classList.contains('hidden'), - ).toBeFalsy(); - - done(); - }); - }); - - it('loads source file when line number is in hash', done => { - window.location.hash = '#L1'; - - new BlobViewer(); - - setTimeout(() => { - expect( - document - .querySelector('.js-blob-viewer-switch-btn[data-viewer="simple"]') - .classList.contains('hidden'), - ).toBeFalsy(); - - done(); - }); - }); - - it('doesnt reload file if already loaded', done => { - const asyncClick = () => - new Promise(resolve => { - document.querySelector('.js-blob-viewer-switch-btn[data-viewer="simple"]').click(); - - setTimeout(resolve); - }); - - asyncClick() - .then(() => asyncClick()) - .then(() => { - expect( - document.querySelector('.blob-viewer[data-type="simple"]').getAttribute('data-loaded'), - ).toBe('true'); - - done(); - }) - .catch(() => { - fail(); - done(); - }); - }); - - describe('copy blob button', () => { - let copyButton; - - beforeEach(() => { - copyButton = document.querySelector('.js-copy-blob-source-btn'); - }); - - it('disabled on load', () => { - expect(copyButton.classList.contains('disabled')).toBeTruthy(); - }); - - it('has tooltip when disabled', () => { - expect(copyButton.getAttribute('data-original-title')).toBe( - 'Switch to the source to copy the file contents', - ); - }); - - it('is blurred when clicked and disabled', () => { - spyOn(copyButton, 'blur'); - - copyButton.click(); - - expect(copyButton.blur).toHaveBeenCalled(); - }); - - it('is not blurred when clicked and not disabled', () => { - spyOn(copyButton, 'blur'); - - copyButton.classList.remove('disabled'); - copyButton.click(); - - expect(copyButton.blur).not.toHaveBeenCalled(); - }); - - it('enables after switching to simple view', done => { - document.querySelector('.js-blob-viewer-switch-btn[data-viewer="simple"]').click(); - - setTimeout(() => { - expect(copyButton.classList.contains('disabled')).toBeFalsy(); - - done(); - }); - }); - - it('updates tooltip after switching to simple view', done => { - document.querySelector('.js-blob-viewer-switch-btn[data-viewer="simple"]').click(); - - setTimeout(() => { - expect(copyButton.getAttribute('data-original-title')).toBe('Copy file contents'); - - done(); - }); - }); - }); - - describe('switchToViewer', () => { - it('removes active class from old viewer button', () => { - blob.switchToViewer('simple'); - - expect( - document.querySelector('.js-blob-viewer-switch-btn.active[data-viewer="rich"]'), - ).toBeNull(); - }); - - it('adds active class to new viewer button', () => { - const simpleBtn = document.querySelector('.js-blob-viewer-switch-btn[data-viewer="simple"]'); - - spyOn(simpleBtn, 'blur'); - - blob.switchToViewer('simple'); - - expect(simpleBtn.classList.contains('active')).toBeTruthy(); - - expect(simpleBtn.blur).toHaveBeenCalled(); - }); - - it('sends AJAX request when switching to simple view', () => { - blob.switchToViewer('simple'); - - expect(axios.get).toHaveBeenCalled(); - }); - - it('does not send AJAX request when switching to rich view', () => { - blob.switchToViewer('simple'); - blob.switchToViewer('rich'); - - expect(axios.get.calls.count()).toBe(1); - }); - }); -}); -- cgit v1.2.3