/
multi_domain_connectors.spec.ts
109 lines (86 loc) · 3.22 KB
/
multi_domain_connectors.spec.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import { findCrossOriginLogs } from '../../../../support/utils'
context('cy.origin connectors', () => {
beforeEach(() => {
cy.visit('/fixtures/multi-domain.html')
cy.get('a[data-cy="dom-link"]').click()
})
it('.each()', () => {
cy.origin('http://foobar.com:3500', () => {
cy.get('#by-name>[name="colors"]').each(($element, index) => {
expect($element.prop('type')).to.equal('checkbox')
})
})
})
it('.its()', () => {
cy.origin('http://foobar.com:3500', () => {
cy.get('#by-id>input').its('length').should('eq', 3)
})
})
it('.invoke()', () => {
cy.origin('http://foobar.com:3500', () => {
cy.get('#button').invoke('text').should('eq', 'button')
})
})
it('.spread()', () => {
cy.origin('http://foobar.com:3500', () => {
const arr = ['foo', 'bar', 'baz']
cy.wrap(arr).spread((foo, bar, baz) => {
expect(foo).to.equal('foo')
expect(bar).to.equal('bar')
expect(baz).to.equal('baz')
})
})
})
it('.then()', () => {
cy.origin('http://foobar.com:3500', () => {
cy.get('#by-id>input').then(($list) => {
expect($list).to.have.length(3)
})
})
})
context('#consoleProps', () => {
let logs: Map<string, any>
beforeEach(() => {
logs = new Map()
cy.on('log:changed', (attrs, log) => {
logs.set(attrs.id, log)
})
})
it('.its()', () => {
cy.origin('http://foobar.com:3500', () => {
cy.get('#by-id>input').its('length')
})
cy.shouldWithTimeout(() => {
const { consoleProps, $el, crossOriginLog } = findCrossOriginLogs('its', logs, 'foobar.com')
expect($el.jquery).to.be.ok
expect(crossOriginLog).to.be.true
expect(consoleProps.Command).to.equal('its')
expect(consoleProps.Property).to.equal('.length')
expect(consoleProps.Yielded).to.equal(3)
expect(consoleProps.Subject.length).to.equal(3)
// make sure subject elements are indexed in the correct order
expect(consoleProps.Subject[0]).to.have.property('tagName').that.equals('INPUT')
expect(consoleProps.Subject[0]).to.have.property('id').that.equals('input')
expect(consoleProps.Subject[1]).to.have.property('tagName').that.equals('INPUT')
expect(consoleProps.Subject[1]).to.have.property('id').that.equals('name')
expect(consoleProps.Subject[2]).to.have.property('tagName').that.equals('INPUT')
expect(consoleProps.Subject[2]).to.have.property('id').that.equals('age')
})
})
it('.invoke()', () => {
cy.origin('http://foobar.com:3500', () => {
cy.get('#button').invoke('text')
})
cy.shouldWithTimeout(() => {
const { consoleProps, $el, crossOriginLog } = findCrossOriginLogs('invoke', logs, 'foobar.com')
expect($el.jquery).to.be.ok
expect(crossOriginLog).to.be.true
expect(consoleProps.Command).to.equal('invoke')
expect(consoleProps.Function).to.equal('.text()')
expect(consoleProps.Yielded).to.equal('button')
expect(consoleProps.Subject).to.have.property('tagName').that.equals('BUTTON')
expect(consoleProps.Subject).to.have.property('id').that.equals('button')
})
})
})
})