Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-21 15:06:40 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-21 15:06:40 +0300
commit0a6ffb540e569bd7a7c548d59b12bc55d4bf9cf1 (patch)
tree9ff7dd7b21a3f9642a8fbb45c922f71a433faf02 /spec/frontend/vue_shared/components/memory_graph_spec.js
parenta048261403ea7e12992ccffe704f0779235712d7 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/vue_shared/components/memory_graph_spec.js')
-rw-r--r--spec/frontend/vue_shared/components/memory_graph_spec.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/spec/frontend/vue_shared/components/memory_graph_spec.js b/spec/frontend/vue_shared/components/memory_graph_spec.js
new file mode 100644
index 00000000000..93f32f0b278
--- /dev/null
+++ b/spec/frontend/vue_shared/components/memory_graph_spec.js
@@ -0,0 +1,53 @@
+import Vue from 'vue';
+import { shallowMount } from '@vue/test-utils';
+import MemoryGraph from '~/vue_shared/components/memory_graph.vue';
+import { GlSparklineChart } from '@gitlab/ui/dist/charts';
+
+describe('MemoryGraph', () => {
+ const Component = Vue.extend(MemoryGraph);
+ let wrapper;
+ const metrics = [
+ [1573586253.853, '2.87'],
+ [1573586313.853, '2.77734375'],
+ [1573586373.853, '2.77734375'],
+ [1573586433.853, '3.0066964285714284'],
+ ];
+
+ afterEach(() => {
+ wrapper.destroy();
+ });
+
+ beforeEach(() => {
+ wrapper = shallowMount(Component, {
+ propsData: {
+ metrics,
+ width: 100,
+ height: 25,
+ },
+ });
+ });
+
+ describe('chartData', () => {
+ it('should calculate chartData', () => {
+ expect(wrapper.vm.chartData.length).toEqual(metrics.length);
+ });
+
+ it('should format date & MB values', () => {
+ const formattedData = [
+ ['Nov 12 2019 19:17:33', '2.87'],
+ ['Nov 12 2019 19:18:33', '2.78'],
+ ['Nov 12 2019 19:19:33', '2.78'],
+ ['Nov 12 2019 19:20:33', '3.01'],
+ ];
+ expect(wrapper.vm.chartData).toEqual(formattedData);
+ });
+ });
+
+ describe('Render chart', () => {
+ it('should draw container with chart', () => {
+ expect(wrapper.element).toMatchSnapshot();
+ expect(wrapper.find('.memory-graph-container').exists()).toBe(true);
+ expect(wrapper.find(GlSparklineChart).exists()).toBe(true);
+ });
+ });
+});