summaryrefslogtreecommitdiff
path: root/spec/javascripts/vue_shared/components/table_pagination_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/javascripts/vue_shared/components/table_pagination_spec.js')
-rw-r--r--spec/javascripts/vue_shared/components/table_pagination_spec.js52
1 files changed, 20 insertions, 32 deletions
diff --git a/spec/javascripts/vue_shared/components/table_pagination_spec.js b/spec/javascripts/vue_shared/components/table_pagination_spec.js
index 9cb067921a7..a5c3870b3ac 100644
--- a/spec/javascripts/vue_shared/components/table_pagination_spec.js
+++ b/spec/javascripts/vue_shared/components/table_pagination_spec.js
@@ -1,8 +1,10 @@
-require('~/lib/utils/common_utils');
-require('~/vue_shared/components/table_pagination');
+import Vue from 'vue';
+import paginationComp from '~/vue_shared/components/table_pagination';
+import '~/lib/utils/common_utils';
describe('Pagination component', () => {
let component;
+ let PaginationComponent;
const changeChanges = {
one: '',
@@ -12,11 +14,12 @@ describe('Pagination component', () => {
changeChanges.one = one;
};
- it('should render and start at page 1', () => {
- setFixtures('<div class="test-pagination-container"></div>');
+ beforeEach(() => {
+ PaginationComponent = Vue.extend(paginationComp);
+ });
- component = new window.gl.VueGlPagination({
- el: document.querySelector('.test-pagination-container'),
+ it('should render and start at page 1', () => {
+ component = new PaginationComponent({
propsData: {
pageInfo: {
totalPages: 10,
@@ -25,7 +28,7 @@ describe('Pagination component', () => {
},
change,
},
- });
+ }).$mount();
expect(component.$el.classList).toContain('gl-pagination');
@@ -35,10 +38,7 @@ describe('Pagination component', () => {
});
it('should go to the previous page', () => {
- setFixtures('<div class="test-pagination-container"></div>');
-
- component = new window.gl.VueGlPagination({
- el: document.querySelector('.test-pagination-container'),
+ component = new PaginationComponent({
propsData: {
pageInfo: {
totalPages: 10,
@@ -47,7 +47,7 @@ describe('Pagination component', () => {
},
change,
},
- });
+ }).$mount();
component.changePage({ target: { innerText: 'Prev' } });
@@ -55,10 +55,7 @@ describe('Pagination component', () => {
});
it('should go to the next page', () => {
- setFixtures('<div class="test-pagination-container"></div>');
-
- component = new window.gl.VueGlPagination({
- el: document.querySelector('.test-pagination-container'),
+ component = new PaginationComponent({
propsData: {
pageInfo: {
totalPages: 10,
@@ -67,7 +64,7 @@ describe('Pagination component', () => {
},
change,
},
- });
+ }).$mount();
component.changePage({ target: { innerText: 'Next' } });
@@ -75,10 +72,7 @@ describe('Pagination component', () => {
});
it('should go to the last page', () => {
- setFixtures('<div class="test-pagination-container"></div>');
-
- component = new window.gl.VueGlPagination({
- el: document.querySelector('.test-pagination-container'),
+ component = new PaginationComponent({
propsData: {
pageInfo: {
totalPages: 10,
@@ -87,7 +81,7 @@ describe('Pagination component', () => {
},
change,
},
- });
+ }).$mount();
component.changePage({ target: { innerText: 'Last >>' } });
@@ -95,10 +89,7 @@ describe('Pagination component', () => {
});
it('should go to the first page', () => {
- setFixtures('<div class="test-pagination-container"></div>');
-
- component = new window.gl.VueGlPagination({
- el: document.querySelector('.test-pagination-container'),
+ component = new PaginationComponent({
propsData: {
pageInfo: {
totalPages: 10,
@@ -107,7 +98,7 @@ describe('Pagination component', () => {
},
change,
},
- });
+ }).$mount();
component.changePage({ target: { innerText: '<< First' } });
@@ -115,10 +106,7 @@ describe('Pagination component', () => {
});
it('should do nothing', () => {
- setFixtures('<div class="test-pagination-container"></div>');
-
- component = new window.gl.VueGlPagination({
- el: document.querySelector('.test-pagination-container'),
+ component = new PaginationComponent({
propsData: {
pageInfo: {
totalPages: 10,
@@ -127,7 +115,7 @@ describe('Pagination component', () => {
},
change,
},
- });
+ }).$mount();
component.changePage({ target: { innerText: '...' } });