diff --git a/app/assets/js/scripts.js b/app/assets/js/scripts.js index 216404a70..181ae5a17 100644 --- a/app/assets/js/scripts.js +++ b/app/assets/js/scripts.js @@ -23,6 +23,7 @@ $(() => { let pos = getMousePos(canvas, e) let posx = pos.x let posy = pos.y + context.fillStyle = 'red' context.beginPath() context.arc(posx, posy, 5, 0, 2 * Math.PI) @@ -31,6 +32,7 @@ $(() => { function getMousePos (canvas, evt) { let rect = canvas.getBoundingClientRect() + return { x: evt.clientX - rect.left, y: evt.clientY - rect.top, @@ -82,6 +84,7 @@ $(() => { // listen to input range for trigger command $('.trigger-input-range').on('change', (e) => { const $range = $(e.target) + $range.next('p').text($range.val()) }) @@ -179,6 +182,7 @@ $(() => { $('.utility-jquery li').on('click', (e) => { let $li = $(e.currentTarget) + $li.addClass('active') }) diff --git a/cypress/integration/examples/assertions.spec.js b/cypress/integration/examples/assertions.spec.js index e882bb3ce..90ca1d676 100644 --- a/cypress/integration/examples/assertions.spec.js +++ b/cypress/integration/examples/assertions.spec.js @@ -53,6 +53,7 @@ context('Assertions', () => { // We can use Chai's BDD style assertions expect(true).to.be.true const o = { foo: 'bar' } + expect(o).to.equal(o) expect(o).to.deep.equal({ foo: 'bar' }) // matching text using regular expression @@ -150,6 +151,7 @@ context('Assertions', () => { .should(($div) => { // we can massage text before comparing const secondText = normalizeText($div.text()) + expect(secondText, 'second text').to.equal(text) }) }) @@ -159,6 +161,7 @@ context('Assertions', () => { name: 'Joe', age: 20, } + assert.isObject(person, 'value is object') }) }) diff --git a/cypress/integration/examples/network_requests.spec.js b/cypress/integration/examples/network_requests.spec.js index ad223a9a9..a2dda0dbe 100644 --- a/cypress/integration/examples/network_requests.spec.js +++ b/cypress/integration/examples/network_requests.spec.js @@ -91,6 +91,7 @@ context('Network Requests', () => { // https://on.cypress.io/route let message = 'whoa, this comment does not exist' + cy.server() // Listen to GET to comments/1 diff --git a/cypress/integration/examples/utilities.spec.js b/cypress/integration/examples/utilities.spec.js index 853c1ade9..c4ae71086 100644 --- a/cypress/integration/examples/utilities.spec.js +++ b/cypress/integration/examples/utilities.spec.js @@ -34,6 +34,7 @@ context('Utilities', () => { .then((dataUrl) => { // create an element and set its src to the dataUrl let img = Cypress.$('', { src: dataUrl }) + // need to explicitly return cy here since we are initially returning // the Cypress.Blob.imgSrcToDataURL promise to our test // append the image @@ -49,6 +50,7 @@ context('Utilities', () => { let matching = Cypress.minimatch('/users/1/comments', '/users/*/comments', { matchBase: true, }) + expect(matching, 'matching wildcard').to.be.true matching = Cypress.minimatch('/users/1/comments/2', '/users/*/comments', { @@ -75,6 +77,7 @@ context('Utilities', () => { // https://on.cypress.io/moment // eslint-disable-next-line no-unused-vars const time = Cypress.moment().utc('2014-04-25T19:38:53.196Z').format('h:mm A') + expect(time).to.be.a('string') cy.get('.utility-moment').contains('3:38 PM')