All files / nexshop-web-contents/spec/component/resolution-drop-down resolution-view-spec.js

100% Statements 33/33
100% Branches 0/0
100% Functions 12/12
100% Lines 33/33
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 651x 1x 1x 1x   1x     1x 6x     1x       1x 3x   3x 3x     1x 1x 1x     1x 1x   1x   1x   1x   1x     1x 1x       1x 1x 1x       1x 1x 1x   1x     1x 1x   1x      
import React from 'react';
import {expect} from 'chai';
import ResolutionView from "../../../src/component/resolution-drop-down/resolution-view";
import {shallow} from "enzyme";
 
describe('ResolutionViewSpec', () => {
    let wrapper;
 
    beforeEach(() => {
        wrapper = shallow(<ResolutionView menuOpened={false}/>)
    });
 
    describe('resolution exists', () => {
        let title;
        let resolution;
 
        beforeEach(() => {
            wrapper.setProps({resolution: {value: 'QHD', text: '1920x1050', orientation: 'horizontal'}});
 
            title = wrapper.find('.resolution-drop-down-selected__title');
            resolution = wrapper.find('.resolution-drop-down-selected__resolution');
        });
 
        it('shows {value, text} of resolution', () => {
            expect(title.text()).to.equal('QHD');
            expect(resolution.text()).to.equal('1920x1050');
        });
 
        it('gives selected class for given orientation', () => {
            let selectedOrientation = wrapper.find('.resolution-drop-down-selected').childAt(2);
 
            expect(selectedOrientation.hasClass('resolution-drop-down-selected__horizontal')).to.be.true;
 
            wrapper.setProps({resolution: {value: 'QHD', text: '1920x1050', orientation: 'vertical'}});
 
            selectedOrientation = wrapper.find('.resolution-drop-down-selected').childAt(2);
 
            expect(selectedOrientation.hasClass('resolution-drop-down-selected__vertical')).to.be.true;
        });
 
        it('does not show placeholder', () => {
            expect(wrapper.find('.resolution-drop-down__placeholder').exists()).to.be.false;
        });
    });
 
    describe('resolution not exist', () => {
        it('shows "Target Resolution" as placeholder', () => {
            expect(wrapper.find('.resolution-drop-down__placeholder').text()).to.equal('Target Resolution');
        });
    });
 
    describe('menu status', () => {
        it('shows ▼ when menu is closed', () => {
            wrapper.setProps({menuOpened: false});
 
            expect(wrapper.find('.resolution-drop-down__arrow').text()).to.equal('▼');
        });
        
        it('shows ▲ when menu is opened', () => {
            wrapper.setProps({menuOpened: true});
 
            expect(wrapper.find('.resolution-drop-down__arrow').text()).to.equal('▲');
        });
    });
});