From a0038fd3d2d73b1effd088c09f30dff20ac8c184 Mon Sep 17 00:00:00 2001 From: Marcella Maki Date: Fri, 28 Jan 2022 10:26:11 -0500 Subject: [PATCH] switch to 'let wrapper' and 'beforeEach()' --- ...-channel-browser-main-content-grid.spec.js | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/kolibri/plugins/learn/assets/test/views/library-and-channel-browser-main-content-grid.spec.js b/kolibri/plugins/learn/assets/test/views/library-and-channel-browser-main-content-grid.spec.js index d62641a7781..71e9a65287c 100644 --- a/kolibri/plugins/learn/assets/test/views/library-and-channel-browser-main-content-grid.spec.js +++ b/kolibri/plugins/learn/assets/test/views/library-and-channel-browser-main-content-grid.spec.js @@ -2,20 +2,18 @@ import { shallowMount } from '@vue/test-utils'; import LibraryAndChannelBrowserMainContent from '../../src/views/LibraryAndChannelBrowserMainContent'; describe('Library and Channel Browser Main Content', () => { - const wrapper = shallowMount(LibraryAndChannelBrowserMainContent, { - computed: { windowIsLarge: () => true, backRoute: 'test' }, - propsData: { contents: [{ node: 1 }], currentCardViewStyle: 'card' }, + let wrapper; + beforeEach(() => { + wrapper = shallowMount(LibraryAndChannelBrowserMainContent, { + computed: { windowIsSmall: () => false, backRoute: 'test' }, + propsData: { contents: [{ node: 1 }], currentCardViewStyle: 'card' }, + }); }); - it('smoke test', () => { expect(wrapper.exists()).toBe(true); }); describe('When the user has a medium or large screen', () => { describe('When `currentCardViewStyle` is a card', () => { - const wrapper = shallowMount(LibraryAndChannelBrowserMainContent, { - computed: { windowIsSmall: () => false, backRoute: 'test' }, - propsData: { contents: [{ node: 1 }], currentCardViewStyle: 'card' }, - }); it('displays a `CardGrid`, and within the grid, a `HybridLearningContentCard` for each content node', () => { expect(wrapper.find('[data-test="non-mobile-card-grid"]').element).toBeTruthy(); expect(wrapper.find('[data-test="content-card"]').element).toBeTruthy(); @@ -29,9 +27,11 @@ describe('Library and Channel Browser Main Content', () => { }); }); describe('When `currentCardViewStyle` is a list', () => { - const wrapper = shallowMount(LibraryAndChannelBrowserMainContent, { - computed: { windowIsSmall: () => false, backRoute: 'test' }, - propsData: { contents: [{ node: 1 }], currentCardViewStyle: 'list' }, + beforeEach(() => { + wrapper = shallowMount(LibraryAndChannelBrowserMainContent, { + computed: { windowIsSmall: () => false, backRoute: 'test' }, + propsData: { contents: [{ node: 1 }], currentCardViewStyle: 'list' }, + }); }); it('displays a `HybridLearningContentCardListView` for each content node, in a single, full-width column', () => { expect(wrapper.find('[data-test="card-list-view"]').element).toBeTruthy(); @@ -47,9 +47,11 @@ describe('Library and Channel Browser Main Content', () => { }); }); describe('When the user is on a mobile device', () => { - const wrapper = shallowMount(LibraryAndChannelBrowserMainContent, { - computed: { windowIsSmall: () => true, backRoute: 'test' }, - propsData: { contents: [{ node: 1 }] }, + beforeEach(() => { + wrapper = shallowMount(LibraryAndChannelBrowserMainContent, { + computed: { windowIsSmall: () => true, backRoute: 'test' }, + propsData: { contents: [{ node: 1 }] }, + }); }); it('displays a `CardGrid` with a `ResourceCard` for each content node in a single, full-width column', () => { expect(wrapper.find('[data-test="mobile-card-grid"]').element).toBeTruthy();