-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
local_storage.cy.ts
52 lines (42 loc) · 1.43 KB
/
local_storage.cy.ts
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
import { findCrossOriginLogs } from '../../../../support/utils'
context('cy.origin local storage', { browser: '!webkit' }, () => {
beforeEach(() => {
cy.visit('/fixtures/primary-origin.html')
cy.get('a[data-cy="cross-origin-secondary-link"]').click()
})
it('.clearLocalStorage()', () => {
cy.origin('http://www.foobar.com:3500', () => {
cy.window().then((win) => {
win.localStorage.setItem('foo', 'bar')
expect(win.localStorage.getItem('foo')).to.equal('bar')
})
cy.clearLocalStorage().should((localStorage) => {
expect(localStorage.length).to.equal(0)
expect(localStorage.getItem('foo')).to.be.null
})
})
})
context('#consoleProps', () => {
let logs: Map<string, any>
beforeEach(() => {
logs = new Map()
cy.on('log:changed', (attrs, log) => {
logs.set(attrs.id, log)
})
})
it('.clearLocalStorage()', () => {
cy.origin('http://www.foobar.com:3500', () => {
cy.window().then((win) => {
win.localStorage.setItem('foo', 'bar')
expect(win.localStorage.getItem('foo')).to.equal('bar')
})
cy.clearLocalStorage()
})
cy.shouldWithTimeout(() => {
const { consoleProps } = findCrossOriginLogs('clearLocalStorage', logs, 'foobar.com')
expect(consoleProps.Command).to.equal('clearLocalStorage')
expect(consoleProps.Yielded).to.be.null
})
})
})
})