File size: 2,203 Bytes
f5071ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
65
66
67
68
69
70
71
72
/// <reference types="Cypress" />

describe('<Search /> and <Dropdown />', () => {
    beforeEach(() => {
        localStorage.setItem('profileSelected', true)
        cy.visit('/browse')
    })

    context('<Dropdown />', () => {
        beforeEach(() => {
            cy.get('.OptionsContainer .Dropdown > svg')
                .as('dropbox')
        })

        it('finds floating box on hover and fails to find it on hover off', () => {
            cy.get('@dropbox')
                .trigger('mouseover')
                .then(() => {
                    cy.get('.FloatingBox')
                        .should('exist')
                })
                .trigger('mouseleave', 'bottom')
                .then(() => {
                    cy.get('FloatingBox')
                        .should('not.exist')
                })
        })

        it('logs out and removes the local storage token on sign out press', () => {
            cy.get('@dropbox')
                .trigger('mouseover')
                .get('.FloatingBox')
                .find('span')
                .contains('Sign out of Netflix')
                .click()
                .then(() => {
                    expect(localStorage.getItem('profileSelected')).to.not.exist
                    cy.location().should(loc => {
                        expect(loc.pathname).to.eq('/')
                    })
                })
        })
    })

    context('<Search />', () => {
        beforeEach(() => {
            cy.get('.SearchBox')
                .click()
        })
        it('opens search box on click and closes on background click', () => {
            cy.get('.Holder')
                .should('exist')

            cy.get('.NavBar')
                .click('center')
                .find('.Holder')
                .should('not.exist')
        })

        it('cross becomes visible after typing and invisible when input length is 0', () => {
            cy.get('.Holder')
                .children('input')
                .type('Some movie title')

            cy.get('.Holder')
                .children('svg')
                .last()
                .click()
                .should('not.exist')
        })
    })
})