diff --git a/Makefile b/Makefile index b394e86..3e1bf8c 100644 --- a/Makefile +++ b/Makefile @@ -91,6 +91,7 @@ i18n: .PHONY: cypress-run cypress-run: + rm -rf .nyc_output NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress run .PHONY: cypress-open diff --git a/cypress/e2e/01-style-block-basics.cy.js b/cypress/e2e/01-style-block-basics.cy.js index 8184845..6bafb6e 100644 --- a/cypress/e2e/01-style-block-basics.cy.js +++ b/cypress/e2e/01-style-block-basics.cy.js @@ -30,6 +30,22 @@ describe('Blocks Tests', () => { ).click(); cy.get('.github-picker.color-picker div[title="#9dc6d4"]').click(); + cy.get( + '.inline.field.field-wrapper-shadowDepth .slider-widget-wrapper .slider-knob.single', + ).dblclick(); + cy.get( + '.inline.field.field-wrapper-shadowDepth .slider-widget-wrapper input', + ).type('3{enter}'); + + cy.get( + '.inline.field.field-wrapper-shadowDepth .slider-widget-wrapper .slider-knob.single', + ).trigger('mousedown', { which: 1 }); + cy.get( + '.inline.field.field-wrapper-shadowDepth .slider-widget-wrapper .semantic_ui_range_inner', + ) + .trigger('mousemove', { clientX: 500 }) + .trigger('mouseup'); + cy.get('[contenteditable=true]').first().type('{enter}'); // Save page diff --git a/src/helpers.test.js b/src/helpers.test.js new file mode 100644 index 0000000..35e19a7 --- /dev/null +++ b/src/helpers.test.js @@ -0,0 +1,89 @@ +import { getFieldURL } from './helpers'; + +describe('getFieldURL', () => { + it('handles a URL type object with type and value', () => { + const data = { + '@type': 'URL', + value: 'value_url', + url: 'url_url', + href: 'href_url', + }; + expect(getFieldURL(data)).toEqual('value_url'); + }); + + it('handles an object with type and url', () => { + const data = { + '@type': 'URL', + url: 'url_url', + href: 'href_url', + }; + expect(getFieldURL(data)).toEqual('url_url'); + }); + + it('handles an object with type and href', () => { + const data = { + '@type': 'URL', + href: 'href_url', + }; + expect(getFieldURL(data)).toEqual('href_url'); + }); + + it('handles an object with type and no value, url and href', () => { + const data = { + '@type': 'URL', + }; + expect(getFieldURL(data)).toEqual({ '@type': 'URL' }); + }); + + it('handles an object without a specific type and url', () => { + const data = { + url: 'url_url', + href: 'href_url', + }; + expect(getFieldURL(data)).toEqual('url_url'); + }); + + it('handles an object without a specific type and href', () => { + const data = { + href: 'href_url', + }; + expect(getFieldURL(data)).toEqual('href_url'); + }); + + it('handles an object without a specific type and no id, url, href', () => { + const data = { + test: 'test_url', + }; + expect(getFieldURL(data)).toEqual({ + test: 'test_url', + }); + }); + + it('handles an array', () => { + const data = [ + { + '@type': 'URL', + value: 'value_url', + url: 'url_url', + href: 'href_url', + }, + { + '@id': 'id_url', + url: 'url_url', + href: 'href_url', + }, + ]; + expect(getFieldURL(data)).toEqual(['value_url', 'id_url']); + }); + + it('handles a string', () => { + const data = '/some/url'; + expect(getFieldURL(data)).toEqual('/some/url'); + }); + + it('returns the data unchanged for non-object/non-array/non-string inputs', () => { + expect(getFieldURL(42)).toEqual(42); + expect(getFieldURL(undefined)).toEqual(undefined); + expect(getFieldURL(null)).toEqual(null); + }); +});