bukazu-portal-react 3.3.3 → 3.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/build/index.css +1 -1
  2. package/build/portal.es.js +19931 -20259
  3. package/build/portal.umd.js +80 -82
  4. package/package.json +9 -7
  5. package/.env.development +0 -1
  6. package/.eslintrc +0 -25
  7. package/.github/dependabot.yml +0 -11
  8. package/.github/workflows/node.js.yml +0 -31
  9. package/.github/workflows/npm-publish.yml +0 -33
  10. package/.nvmrc +0 -1
  11. package/.prettierrc +0 -6
  12. package/.vscode/settings.json +0 -24
  13. package/CHANGELOG.MD +0 -93
  14. package/babel.config.json +0 -6
  15. package/calendar.html +0 -16
  16. package/coverage/clover.xml +0 -28
  17. package/coverage/coverage-final.json +0 -2
  18. package/coverage/lcov-report/base.css +0 -224
  19. package/coverage/lcov-report/block-navigation.js +0 -87
  20. package/coverage/lcov-report/favicon.png +0 -0
  21. package/coverage/lcov-report/helper.ts.html +0 -142
  22. package/coverage/lcov-report/index.html +0 -116
  23. package/coverage/lcov-report/prettify.css +0 -1
  24. package/coverage/lcov-report/prettify.js +0 -2
  25. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  26. package/coverage/lcov-report/sorter.js +0 -196
  27. package/coverage/lcov.info +0 -36
  28. package/cypress/e2e/.examples/actions.spec.js +0 -299
  29. package/cypress/e2e/.examples/aliasing.spec.js +0 -39
  30. package/cypress/e2e/.examples/assertions.spec.js +0 -177
  31. package/cypress/e2e/.examples/connectors.spec.js +0 -97
  32. package/cypress/e2e/.examples/cookies.spec.js +0 -77
  33. package/cypress/e2e/.examples/cypress_api.spec.js +0 -202
  34. package/cypress/e2e/.examples/files.spec.js +0 -89
  35. package/cypress/e2e/.examples/local_storage.spec.js +0 -52
  36. package/cypress/e2e/.examples/location.spec.js +0 -32
  37. package/cypress/e2e/.examples/misc.spec.js +0 -104
  38. package/cypress/e2e/.examples/navigation.spec.js +0 -56
  39. package/cypress/e2e/.examples/network_requests.spec.js +0 -163
  40. package/cypress/e2e/.examples/querying.spec.js +0 -114
  41. package/cypress/e2e/.examples/spies_stubs_clocks.spec.js +0 -205
  42. package/cypress/e2e/.examples/traversal.spec.js +0 -121
  43. package/cypress/e2e/.examples/utilities.spec.js +0 -110
  44. package/cypress/e2e/.examples/viewport.spec.js +0 -59
  45. package/cypress/e2e/.examples/waiting.spec.js +0 -31
  46. package/cypress/e2e/.examples/window.spec.js +0 -22
  47. package/cypress/e2e/booking.spec.js +0 -81
  48. package/cypress/e2e/calendar.spec.js +0 -21
  49. package/cypress/e2e/search.spec.js +0 -25
  50. package/cypress/fixtures/example.json +0 -5
  51. package/cypress/plugins/index.js +0 -16
  52. package/cypress/support/commands.js +0 -25
  53. package/cypress/support/commands.ts +0 -37
  54. package/cypress/support/component-index.html +0 -12
  55. package/cypress/support/component.ts +0 -39
  56. package/cypress/support/e2e.js +0 -20
  57. package/cypress.config.ts +0 -15
  58. package/dev.tsx +0 -44
  59. package/index.html +0 -15
  60. package/invalid-calendar.html +0 -16
  61. package/jest.config.js +0 -195
  62. package/postcss.config.js +0 -17
  63. package/reviews.html +0 -16
  64. package/src/_lib/SearchQueries.ts +0 -145
  65. package/src/_lib/Tracking.ts +0 -51
  66. package/src/_lib/countries/de.json +0 -998
  67. package/src/_lib/countries/en.json +0 -998
  68. package/src/_lib/countries/es.json +0 -998
  69. package/src/_lib/countries/fr.json +0 -998
  70. package/src/_lib/countries/it.json +0 -998
  71. package/src/_lib/countries/nl.json +0 -998
  72. package/src/_lib/countries.ts +0 -15
  73. package/src/_lib/date_helper.ts +0 -27
  74. package/src/_lib/queries.ts +0 -244
  75. package/src/components/App.tsx +0 -108
  76. package/src/components/AppContext.ts +0 -14
  77. package/src/components/CalendarPage/BookingForm.tsx +0 -49
  78. package/src/components/CalendarPage/Calendar.tsx +0 -49
  79. package/src/components/CalendarPage/CalendarPage.tsx +0 -43
  80. package/src/components/CalendarPage/CalendarParts/CalendarContext.tsx +0 -89
  81. package/src/components/CalendarPage/CalendarParts/CalendarHeader.tsx +0 -72
  82. package/src/components/CalendarPage/CalendarParts/DayClasses.ts +0 -113
  83. package/src/components/CalendarPage/CalendarParts/GenerateCalendar.tsx +0 -72
  84. package/src/components/CalendarPage/CalendarParts/Legend.tsx +0 -33
  85. package/src/components/CalendarPage/CalendarParts/MonthHeader.tsx +0 -15
  86. package/src/components/CalendarPage/CalendarParts/Months.tsx +0 -37
  87. package/src/components/CalendarPage/CalendarParts/RenderCells.tsx +0 -97
  88. package/src/components/CalendarPage/CalendarParts/SingleMonth.tsx +0 -72
  89. package/src/components/CalendarPage/CalendarParts/StartBooking.tsx +0 -17
  90. package/src/components/CalendarPage/CalendarParts/WeekDays.tsx +0 -27
  91. package/src/components/CalendarPage/FormCreator.tsx +0 -230
  92. package/src/components/CalendarPage/FormItems/Date.tsx +0 -61
  93. package/src/components/CalendarPage/FormItems/NumberSelect.tsx +0 -39
  94. package/src/components/CalendarPage/FormItems/Select.tsx +0 -38
  95. package/src/components/CalendarPage/FormItems/index.ts +0 -4
  96. package/src/components/CalendarPage/PriceField/Price.tsx +0 -58
  97. package/src/components/CalendarPage/PriceField/Queries.ts +0 -23
  98. package/src/components/CalendarPage/PriceField/index.tsx +0 -129
  99. package/src/components/CalendarPage/Summary/CostRow.tsx +0 -58
  100. package/src/components/CalendarPage/Summary/CostSection.tsx +0 -15
  101. package/src/components/CalendarPage/Summary/CostSummary.tsx +0 -61
  102. package/src/components/CalendarPage/Summary/Description.tsx +0 -27
  103. package/src/components/CalendarPage/Summary/InsurancesAndRequired.tsx +0 -68
  104. package/src/components/CalendarPage/Summary/Object.tsx +0 -59
  105. package/src/components/CalendarPage/Summary/OnSite.tsx +0 -36
  106. package/src/components/CalendarPage/Summary/OptionalNotOnSite.tsx +0 -43
  107. package/src/components/CalendarPage/Summary/OptionalOnSite.tsx +0 -39
  108. package/src/components/CalendarPage/Summary/Queries.ts +0 -31
  109. package/src/components/CalendarPage/Summary/RentAndDiscount.tsx +0 -30
  110. package/src/components/CalendarPage/Summary/Totals.tsx +0 -89
  111. package/src/components/CalendarPage/Summary/cost_types.d.ts +0 -31
  112. package/src/components/CalendarPage/Summary/index.tsx +0 -24
  113. package/src/components/CalendarPage/calender_types.d.ts +0 -16
  114. package/src/components/CalendarPage/formParts/AssistanceMessage.tsx +0 -60
  115. package/src/components/CalendarPage/formParts/BookingHelpers.tsx +0 -47
  116. package/src/components/CalendarPage/formParts/BookingOrOption.tsx +0 -35
  117. package/src/components/CalendarPage/formParts/CancelInsuranceText.tsx +0 -69
  118. package/src/components/CalendarPage/formParts/DefaultBookingFields.ts +0 -105
  119. package/src/components/CalendarPage/formParts/DiscountCode.tsx +0 -62
  120. package/src/components/CalendarPage/formParts/Guests.tsx +0 -77
  121. package/src/components/CalendarPage/formParts/OptionalBookingFields.tsx +0 -148
  122. package/src/components/CalendarPage/formParts/OptionalCosts.tsx +0 -103
  123. package/src/components/CalendarPage/formParts/SuccessMessage.tsx +0 -31
  124. package/src/components/CalendarPage/formParts/Validations.tsx +0 -64
  125. package/src/components/CalendarPage/formParts/discount.tsx +0 -69
  126. package/src/components/CalendarPage/formParts/form_types.d.ts +0 -38
  127. package/src/components/CalendarPage/formParts/insurances.tsx +0 -62
  128. package/src/components/CalendarPage/formParts/radioButtons.tsx +0 -66
  129. package/src/components/Error/ApiError.tsx +0 -33
  130. package/src/components/Error/IntegrationError.tsx +0 -62
  131. package/src/components/Error/index.ts +0 -4
  132. package/src/components/ErrorBoundary.tsx +0 -34
  133. package/src/components/Modal/index.tsx +0 -46
  134. package/src/components/ReviewsPage/Queries.ts +0 -26
  135. package/src/components/ReviewsPage/ReviewsPage.tsx +0 -45
  136. package/src/components/ReviewsPage/Score.tsx +0 -29
  137. package/src/components/ReviewsPage/SingleReview.tsx +0 -38
  138. package/src/components/ReviewsPage/note.tsx +0 -17
  139. package/src/components/SafeBooking.tsx +0 -96
  140. package/src/components/SearchPage/Field.tsx +0 -75
  141. package/src/components/SearchPage/Filters.tsx +0 -91
  142. package/src/components/SearchPage/Paginator.tsx +0 -63
  143. package/src/components/SearchPage/Results.tsx +0 -129
  144. package/src/components/SearchPage/SearchPage.tsx +0 -115
  145. package/src/components/SearchPage/SingleResult.tsx +0 -93
  146. package/src/components/SearchPage/filters/Categories.tsx +0 -57
  147. package/src/components/SearchPage/filters/DateFilter.tsx +0 -34
  148. package/src/components/SearchPage/filters/List.tsx +0 -80
  149. package/src/components/SearchPage/filters/NumberFilter.tsx +0 -37
  150. package/src/components/SearchPage/filters/Radio.tsx +0 -46
  151. package/src/components/SearchPage/filters/Select.tsx +0 -85
  152. package/src/components/SearchPage/filters/__tests__/helper.spec.js +0 -13
  153. package/src/components/SearchPage/filters/filter_types.d.ts +0 -25
  154. package/src/components/SearchPage/filters/helper.ts +0 -19
  155. package/src/components/icons/ArrowLeft.svg.tsx +0 -20
  156. package/src/components/icons/ArrowRight.svg.tsx +0 -16
  157. package/src/components/icons/Reload.svg.tsx +0 -23
  158. package/src/components/icons/info.svg.tsx +0 -24
  159. package/src/components/icons/loading.svg.tsx +0 -98
  160. package/src/custom.d.ts +0 -10
  161. package/src/index.tsx +0 -104
  162. package/src/locales/de.json +0 -137
  163. package/src/locales/en.json +0 -137
  164. package/src/locales/es.json +0 -132
  165. package/src/locales/fr.json +0 -132
  166. package/src/locales/it.json +0 -128
  167. package/src/locales/nl.json +0 -138
  168. package/src/styles/calendar.css +0 -317
  169. package/src/styles/datepicker.css +0 -6
  170. package/src/styles/field.css +0 -105
  171. package/src/styles/filters.css +0 -92
  172. package/src/styles/form.css +0 -219
  173. package/src/styles/main.css +0 -80
  174. package/src/styles/modal.css +0 -79
  175. package/src/styles/pagination.css +0 -92
  176. package/src/styles/price-overview.css +0 -111
  177. package/src/styles/result.css +0 -142
  178. package/src/styles/results.css +0 -50
  179. package/src/styles/reviews.css +0 -90
  180. package/src/styles/success.css +0 -9
  181. package/src/types.d.ts +0 -91
  182. package/tmp/cache/vite/last-build-production.json +0 -7
  183. package/tsconfig.json +0 -17
  184. package/vite.config.ts +0 -31
@@ -1,163 +0,0 @@
1
- /// <reference types="cypress" />
2
-
3
- context('Network Requests', () => {
4
- beforeEach(() => {
5
- cy.visit('https://example.cypress.io/commands/network-requests')
6
- })
7
-
8
- // Manage HTTP requests in your app
9
-
10
- it('cy.request() - make an XHR request', () => {
11
- // https://on.cypress.io/request
12
- cy.request('https://jsonplaceholder.cypress.io/comments')
13
- .should((response) => {
14
- expect(response.status).to.eq(200)
15
- // the server sometimes gets an extra comment posted from another machine
16
- // which gets returned as 1 extra object
17
- expect(response.body).to.have.property('length').and.be.oneOf([500, 501])
18
- expect(response).to.have.property('headers')
19
- expect(response).to.have.property('duration')
20
- })
21
- })
22
-
23
- it('cy.request() - verify response using BDD syntax', () => {
24
- cy.request('https://jsonplaceholder.cypress.io/comments')
25
- .then((response) => {
26
- // https://on.cypress.io/assertions
27
- expect(response).property('status').to.equal(200)
28
- expect(response).property('body').to.have.property('length').and.be.oneOf([500, 501])
29
- expect(response).to.include.keys('headers', 'duration')
30
- })
31
- })
32
-
33
- it('cy.request() with query parameters', () => {
34
- // will execute request
35
- // https://jsonplaceholder.cypress.io/comments?postId=1&id=3
36
- cy.request({
37
- url: 'https://jsonplaceholder.cypress.io/comments',
38
- qs: {
39
- postId: 1,
40
- id: 3,
41
- },
42
- })
43
- .its('body')
44
- .should('be.an', 'array')
45
- .and('have.length', 1)
46
- .its('0') // yields first element of the array
47
- .should('contain', {
48
- postId: 1,
49
- id: 3,
50
- })
51
- })
52
-
53
- it('cy.request() - pass result to the second request', () => {
54
- // first, let's find out the userId of the first user we have
55
- cy.request('https://jsonplaceholder.cypress.io/users?_limit=1')
56
- .its('body') // yields the response object
57
- .its('0') // yields the first element of the returned list
58
- // the above two commands its('body').its('0')
59
- // can be written as its('body.0')
60
- // if you do not care about TypeScript checks
61
- .then((user) => {
62
- expect(user).property('id').to.be.a('number')
63
- // make a new post on behalf of the user
64
- cy.request('POST', 'https://jsonplaceholder.cypress.io/posts', {
65
- userId: user.id,
66
- title: 'Cypress Test Runner',
67
- body: 'Fast, easy and reliable testing for anything that runs in a browser.',
68
- })
69
- })
70
- // note that the value here is the returned value of the 2nd request
71
- // which is the new post object
72
- .then((response) => {
73
- expect(response).property('status').to.equal(201) // new entity created
74
- expect(response).property('body').to.contain({
75
- title: 'Cypress Test Runner',
76
- })
77
-
78
- // we don't know the exact post id - only that it will be > 100
79
- // since JSONPlaceholder has built-in 100 posts
80
- expect(response.body).property('id').to.be.a('number')
81
- .and.to.be.gt(100)
82
-
83
- // we don't know the user id here - since it was in above closure
84
- // so in this test just confirm that the property is there
85
- expect(response.body).property('userId').to.be.a('number')
86
- })
87
- })
88
-
89
- it('cy.request() - save response in the shared test context', () => {
90
- // https://on.cypress.io/variables-and-aliases
91
- cy.request('https://jsonplaceholder.cypress.io/users?_limit=1')
92
- .its('body').its('0') // yields the first element of the returned list
93
- .as('user') // saves the object in the test context
94
- .then(function () {
95
- // NOTE 👀
96
- // By the time this callback runs the "as('user')" command
97
- // has saved the user object in the test context.
98
- // To access the test context we need to use
99
- // the "function () { ... }" callback form,
100
- // otherwise "this" points at a wrong or undefined object!
101
- cy.request('POST', 'https://jsonplaceholder.cypress.io/posts', {
102
- userId: this.user.id,
103
- title: 'Cypress Test Runner',
104
- body: 'Fast, easy and reliable testing for anything that runs in a browser.',
105
- })
106
- .its('body').as('post') // save the new post from the response
107
- })
108
- .then(function () {
109
- // When this callback runs, both "cy.request" API commands have finished
110
- // and the test context has "user" and "post" objects set.
111
- // Let's verify them.
112
- expect(this.post, 'post has the right user id').property('userId').to.equal(this.user.id)
113
- })
114
- })
115
-
116
- it('cy.intercept() - route responses to matching requests', () => {
117
- // https://on.cypress.io/intercept
118
-
119
- let message = 'whoa, this comment does not exist'
120
-
121
- // Listen to GET to comments/1
122
- cy.intercept('GET', '**/comments/*').as('getComment')
123
-
124
- // we have code that gets a comment when
125
- // the button is clicked in scripts.js
126
- cy.get('.network-btn').click()
127
-
128
- // https://on.cypress.io/wait
129
- cy.wait('@getComment').its('response.statusCode').should('be.oneOf', [200, 304])
130
-
131
- // Listen to POST to comments
132
- cy.intercept('POST', '**/comments').as('postComment')
133
-
134
- // we have code that posts a comment when
135
- // the button is clicked in scripts.js
136
- cy.get('.network-post').click()
137
- cy.wait('@postComment').should(({ request, response }) => {
138
- expect(request.body).to.include('email')
139
- expect(request.headers).to.have.property('content-type')
140
- expect(response && response.body).to.have.property('name', 'Using POST in cy.intercept()')
141
- })
142
-
143
- // Stub a response to PUT comments/ ****
144
- cy.intercept({
145
- method: 'PUT',
146
- url: '**/comments/*',
147
- }, {
148
- statusCode: 404,
149
- body: { error: message },
150
- headers: { 'access-control-allow-origin': '*' },
151
- delayMs: 500,
152
- }).as('putComment')
153
-
154
- // we have code that puts a comment when
155
- // the button is clicked in scripts.js
156
- cy.get('.network-put').click()
157
-
158
- cy.wait('@putComment')
159
-
160
- // our 404 statusCode logic in scripts.js executed
161
- cy.get('.network-put-comment').should('contain', message)
162
- })
163
- })
@@ -1,114 +0,0 @@
1
- /// <reference types="cypress" />
2
-
3
- context('Querying', () => {
4
- beforeEach(() => {
5
- cy.visit('https://example.cypress.io/commands/querying')
6
- })
7
-
8
- // The most commonly used query is 'cy.get()', you can
9
- // think of this like the '$' in jQuery
10
-
11
- it('cy.get() - query DOM elements', () => {
12
- // https://on.cypress.io/get
13
-
14
- cy.get('#query-btn').should('contain', 'Button')
15
-
16
- cy.get('.query-btn').should('contain', 'Button')
17
-
18
- cy.get('#querying .well>button:first').should('contain', 'Button')
19
- // ↲
20
- // Use CSS selectors just like jQuery
21
-
22
- cy.get('[data-test-id="test-example"]').should('have.class', 'example')
23
-
24
- // 'cy.get()' yields jQuery object, you can get its attribute
25
- // by invoking `.attr()` method
26
- cy.get('[data-test-id="test-example"]')
27
- .invoke('attr', 'data-test-id')
28
- .should('equal', 'test-example')
29
-
30
- // or you can get element's CSS property
31
- cy.get('[data-test-id="test-example"]')
32
- .invoke('css', 'position')
33
- .should('equal', 'static')
34
-
35
- // or use assertions directly during 'cy.get()'
36
- // https://on.cypress.io/assertions
37
- cy.get('[data-test-id="test-example"]')
38
- .should('have.attr', 'data-test-id', 'test-example')
39
- .and('have.css', 'position', 'static')
40
- })
41
-
42
- it('cy.contains() - query DOM elements with matching content', () => {
43
- // https://on.cypress.io/contains
44
- cy.get('.query-list')
45
- .contains('bananas')
46
- .should('have.class', 'third')
47
-
48
- // we can pass a regexp to `.contains()`
49
- cy.get('.query-list')
50
- .contains(/^b\w+/)
51
- .should('have.class', 'third')
52
-
53
- cy.get('.query-list')
54
- .contains('apples')
55
- .should('have.class', 'first')
56
-
57
- // passing a selector to contains will
58
- // yield the selector containing the text
59
- cy.get('#querying')
60
- .contains('ul', 'oranges')
61
- .should('have.class', 'query-list')
62
-
63
- cy.get('.query-button')
64
- .contains('Save Form')
65
- .should('have.class', 'btn')
66
- })
67
-
68
- it('.within() - query DOM elements within a specific element', () => {
69
- // https://on.cypress.io/within
70
- cy.get('.query-form').within(() => {
71
- cy.get('input:first').should('have.attr', 'placeholder', 'Email')
72
- cy.get('input:last').should('have.attr', 'placeholder', 'Password')
73
- })
74
- })
75
-
76
- it('cy.root() - query the root DOM element', () => {
77
- // https://on.cypress.io/root
78
-
79
- // By default, root is the document
80
- cy.root().should('match', 'html')
81
-
82
- cy.get('.query-ul').within(() => {
83
- // In this within, the root is now the ul DOM element
84
- cy.root().should('have.class', 'query-ul')
85
- })
86
- })
87
-
88
- it('best practices - selecting elements', () => {
89
- // https://on.cypress.io/best-practices#Selecting-Elements
90
- cy.get('[data-cy=best-practices-selecting-elements]').within(() => {
91
- // Worst - too generic, no context
92
- cy.get('button').click()
93
-
94
- // Bad. Coupled to styling. Highly subject to change.
95
- cy.get('.btn.btn-large').click()
96
-
97
- // Average. Coupled to the `name` attribute which has HTML semantics.
98
- cy.get('[name=submission]').click()
99
-
100
- // Better. But still coupled to styling or JS event listeners.
101
- cy.get('#main').click()
102
-
103
- // Slightly better. Uses an ID but also ensures the element
104
- // has an ARIA role attribute
105
- cy.get('#main[role=button]').click()
106
-
107
- // Much better. But still coupled to text content that may change.
108
- cy.contains('Submit').click()
109
-
110
- // Best. Insulated from all changes.
111
- cy.get('[data-cy=submit]').click()
112
- })
113
- })
114
- })
@@ -1,205 +0,0 @@
1
- /// <reference types="cypress" />
2
- // remove no check once Cypress.sinon is typed
3
- // https://github.com/cypress-io/cypress/issues/6720
4
-
5
- context('Spies, Stubs, and Clock', () => {
6
- it('cy.spy() - wrap a method in a spy', () => {
7
- // https://on.cypress.io/spy
8
- cy.visit('https://example.cypress.io/commands/spies-stubs-clocks')
9
-
10
- const obj = {
11
- foo () {},
12
- }
13
-
14
- const spy = cy.spy(obj, 'foo').as('anyArgs')
15
-
16
- obj.foo()
17
-
18
- expect(spy).to.be.called
19
- })
20
-
21
- it('cy.spy() retries until assertions pass', () => {
22
- cy.visit('https://example.cypress.io/commands/spies-stubs-clocks')
23
-
24
- const obj = {
25
- /**
26
- * Prints the argument passed
27
- * @param x {any}
28
- */
29
- foo (x) {
30
- console.log('obj.foo called with', x)
31
- },
32
- }
33
-
34
- cy.spy(obj, 'foo').as('foo')
35
-
36
- setTimeout(() => {
37
- obj.foo('first')
38
- }, 500)
39
-
40
- setTimeout(() => {
41
- obj.foo('second')
42
- }, 2500)
43
-
44
- cy.get('@foo').should('have.been.calledTwice')
45
- })
46
-
47
- it('cy.stub() - create a stub and/or replace a function with stub', () => {
48
- // https://on.cypress.io/stub
49
- cy.visit('https://example.cypress.io/commands/spies-stubs-clocks')
50
-
51
- const obj = {
52
- /**
53
- * prints both arguments to the console
54
- * @param a {string}
55
- * @param b {string}
56
- */
57
- foo (a, b) {
58
- console.log('a', a, 'b', b)
59
- },
60
- }
61
-
62
- const stub = cy.stub(obj, 'foo').as('foo')
63
-
64
- obj.foo('foo', 'bar')
65
-
66
- expect(stub).to.be.called
67
- })
68
-
69
- it('cy.clock() - control time in the browser', () => {
70
- // https://on.cypress.io/clock
71
-
72
- // create the date in UTC so its always the same
73
- // no matter what local timezone the browser is running in
74
- const now = new Date(Date.UTC(2017, 2, 14)).getTime()
75
-
76
- cy.clock(now)
77
- cy.visit('https://example.cypress.io/commands/spies-stubs-clocks')
78
- cy.get('#clock-div').click()
79
- .should('have.text', '1489449600')
80
- })
81
-
82
- it('cy.tick() - move time in the browser', () => {
83
- // https://on.cypress.io/tick
84
-
85
- // create the date in UTC so its always the same
86
- // no matter what local timezone the browser is running in
87
- const now = new Date(Date.UTC(2017, 2, 14)).getTime()
88
-
89
- cy.clock(now)
90
- cy.visit('https://example.cypress.io/commands/spies-stubs-clocks')
91
- cy.get('#tick-div').click()
92
- .should('have.text', '1489449600')
93
-
94
- cy.tick(10000) // 10 seconds passed
95
- cy.get('#tick-div').click()
96
- .should('have.text', '1489449610')
97
- })
98
-
99
- it('cy.stub() matches depending on arguments', () => {
100
- // see all possible matchers at
101
- // https://sinonjs.org/releases/latest/matchers/
102
- const greeter = {
103
- /**
104
- * Greets a person
105
- * @param {string} name
106
- */
107
- greet (name) {
108
- return `Hello, ${name}!`
109
- },
110
- }
111
-
112
- cy.stub(greeter, 'greet')
113
- .callThrough() // if you want non-matched calls to call the real method
114
- .withArgs(Cypress.sinon.match.string).returns('Hi')
115
- .withArgs(Cypress.sinon.match.number).throws(new Error('Invalid name'))
116
-
117
- expect(greeter.greet('World')).to.equal('Hi')
118
- // @ts-ignore
119
- expect(() => greeter.greet(42)).to.throw('Invalid name')
120
- expect(greeter.greet).to.have.been.calledTwice
121
-
122
- // non-matched calls goes the actual method
123
- // @ts-ignore
124
- expect(greeter.greet()).to.equal('Hello, undefined!')
125
- })
126
-
127
- it('matches call arguments using Sinon matchers', () => {
128
- // see all possible matchers at
129
- // https://sinonjs.org/releases/latest/matchers/
130
- const calculator = {
131
- /**
132
- * returns the sum of two arguments
133
- * @param a {number}
134
- * @param b {number}
135
- */
136
- add (a, b) {
137
- return a + b
138
- },
139
- }
140
-
141
- const spy = cy.spy(calculator, 'add').as('add')
142
-
143
- expect(calculator.add(2, 3)).to.equal(5)
144
-
145
- // if we want to assert the exact values used during the call
146
- expect(spy).to.be.calledWith(2, 3)
147
-
148
- // let's confirm "add" method was called with two numbers
149
- expect(spy).to.be.calledWith(Cypress.sinon.match.number, Cypress.sinon.match.number)
150
-
151
- // alternatively, provide the value to match
152
- expect(spy).to.be.calledWith(Cypress.sinon.match(2), Cypress.sinon.match(3))
153
-
154
- // match any value
155
- expect(spy).to.be.calledWith(Cypress.sinon.match.any, 3)
156
-
157
- // match any value from a list
158
- expect(spy).to.be.calledWith(Cypress.sinon.match.in([1, 2, 3]), 3)
159
-
160
- /**
161
- * Returns true if the given number is event
162
- * @param {number} x
163
- */
164
- const isEven = (x) => x % 2 === 0
165
-
166
- // expect the value to pass a custom predicate function
167
- // the second argument to "sinon.match(predicate, message)" is
168
- // shown if the predicate does not pass and assertion fails
169
- expect(spy).to.be.calledWith(Cypress.sinon.match(isEven, 'isEven'), 3)
170
-
171
- /**
172
- * Returns a function that checks if a given number is larger than the limit
173
- * @param {number} limit
174
- * @returns {(x: number) => boolean}
175
- */
176
- const isGreaterThan = (limit) => (x) => x > limit
177
-
178
- /**
179
- * Returns a function that checks if a given number is less than the limit
180
- * @param {number} limit
181
- * @returns {(x: number) => boolean}
182
- */
183
- const isLessThan = (limit) => (x) => x < limit
184
-
185
- // you can combine several matchers using "and", "or"
186
- expect(spy).to.be.calledWith(
187
- Cypress.sinon.match.number,
188
- Cypress.sinon.match(isGreaterThan(2), '> 2').and(Cypress.sinon.match(isLessThan(4), '< 4')),
189
- )
190
-
191
- expect(spy).to.be.calledWith(
192
- Cypress.sinon.match.number,
193
- Cypress.sinon.match(isGreaterThan(200), '> 200').or(Cypress.sinon.match(3)),
194
- )
195
-
196
- // matchers can be used from BDD assertions
197
- cy.get('@add').should('have.been.calledWith',
198
- Cypress.sinon.match.number, Cypress.sinon.match(3))
199
-
200
- // you can alias matchers for shorter test code
201
- const { match: M } = Cypress.sinon
202
-
203
- cy.get('@add').should('have.been.calledWith', M.number, M(3))
204
- })
205
- })
@@ -1,121 +0,0 @@
1
- /// <reference types="cypress" />
2
-
3
- context('Traversal', () => {
4
- beforeEach(() => {
5
- cy.visit('https://example.cypress.io/commands/traversal')
6
- })
7
-
8
- it('.children() - get child DOM elements', () => {
9
- // https://on.cypress.io/children
10
- cy.get('.traversal-breadcrumb')
11
- .children('.active')
12
- .should('contain', 'Data')
13
- })
14
-
15
- it('.closest() - get closest ancestor DOM element', () => {
16
- // https://on.cypress.io/closest
17
- cy.get('.traversal-badge')
18
- .closest('ul')
19
- .should('have.class', 'list-group')
20
- })
21
-
22
- it('.eq() - get a DOM element at a specific index', () => {
23
- // https://on.cypress.io/eq
24
- cy.get('.traversal-list>li')
25
- .eq(1).should('contain', 'siamese')
26
- })
27
-
28
- it('.filter() - get DOM elements that match the selector', () => {
29
- // https://on.cypress.io/filter
30
- cy.get('.traversal-nav>li')
31
- .filter('.active').should('contain', 'About')
32
- })
33
-
34
- it('.find() - get descendant DOM elements of the selector', () => {
35
- // https://on.cypress.io/find
36
- cy.get('.traversal-pagination')
37
- .find('li').find('a')
38
- .should('have.length', 7)
39
- })
40
-
41
- it('.first() - get first DOM element', () => {
42
- // https://on.cypress.io/first
43
- cy.get('.traversal-table td')
44
- .first().should('contain', '1')
45
- })
46
-
47
- it('.last() - get last DOM element', () => {
48
- // https://on.cypress.io/last
49
- cy.get('.traversal-buttons .btn')
50
- .last().should('contain', 'Submit')
51
- })
52
-
53
- it('.next() - get next sibling DOM element', () => {
54
- // https://on.cypress.io/next
55
- cy.get('.traversal-ul')
56
- .contains('apples').next().should('contain', 'oranges')
57
- })
58
-
59
- it('.nextAll() - get all next sibling DOM elements', () => {
60
- // https://on.cypress.io/nextall
61
- cy.get('.traversal-next-all')
62
- .contains('oranges')
63
- .nextAll().should('have.length', 3)
64
- })
65
-
66
- it('.nextUntil() - get next sibling DOM elements until next el', () => {
67
- // https://on.cypress.io/nextuntil
68
- cy.get('#veggies')
69
- .nextUntil('#nuts').should('have.length', 3)
70
- })
71
-
72
- it('.not() - remove DOM elements from set of DOM elements', () => {
73
- // https://on.cypress.io/not
74
- cy.get('.traversal-disabled .btn')
75
- .not('[disabled]').should('not.contain', 'Disabled')
76
- })
77
-
78
- it('.parent() - get parent DOM element from DOM elements', () => {
79
- // https://on.cypress.io/parent
80
- cy.get('.traversal-mark')
81
- .parent().should('contain', 'Morbi leo risus')
82
- })
83
-
84
- it('.parents() - get parent DOM elements from DOM elements', () => {
85
- // https://on.cypress.io/parents
86
- cy.get('.traversal-cite')
87
- .parents().should('match', 'blockquote')
88
- })
89
-
90
- it('.parentsUntil() - get parent DOM elements from DOM elements until el', () => {
91
- // https://on.cypress.io/parentsuntil
92
- cy.get('.clothes-nav')
93
- .find('.active')
94
- .parentsUntil('.clothes-nav')
95
- .should('have.length', 2)
96
- })
97
-
98
- it('.prev() - get previous sibling DOM element', () => {
99
- // https://on.cypress.io/prev
100
- cy.get('.birds').find('.active')
101
- .prev().should('contain', 'Lorikeets')
102
- })
103
-
104
- it('.prevAll() - get all previous sibling DOM elements', () => {
105
- // https://on.cypress.io/prevall
106
- cy.get('.fruits-list').find('.third')
107
- .prevAll().should('have.length', 2)
108
- })
109
-
110
- it('.prevUntil() - get all previous sibling DOM elements until el', () => {
111
- // https://on.cypress.io/prevuntil
112
- cy.get('.foods-list').find('#nuts')
113
- .prevUntil('#veggies').should('have.length', 3)
114
- })
115
-
116
- it('.siblings() - get all sibling DOM elements', () => {
117
- // https://on.cypress.io/siblings
118
- cy.get('.traversal-pills .active')
119
- .siblings().should('have.length', 2)
120
- })
121
- })