From 0f2246b75073eaeab8a6015778e44ea7d0d3ddb1 Mon Sep 17 00:00:00 2001 From: Krzysztof G <60067306+gikf@users.noreply.github.com> Date: Thu, 10 Feb 2022 21:38:03 +0100 Subject: [PATCH] feat: test custom output for js objects (#45077) --- .../integration/learn/challenges/output.js | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/cypress/integration/learn/challenges/output.js b/cypress/integration/learn/challenges/output.js index 024b9d3c65..5f2032e3e3 100644 --- a/cypress/integration/learn/challenges/output.js +++ b/cypress/integration/learn/challenges/output.js @@ -11,7 +11,10 @@ const locations = { 'say-hello-to-html-elements', jQuery: '/learn/front-end-development-libraries/jquery/' + - 'target-html-elements-with-selectors-using-jquery' + 'target-html-elements-with-selectors-using-jquery', + js: + '/learn/javascript-algorithms-and-data-structures/basic-javascript/' + + 'comment-your-javascript-code' }; const defaultOutput = ` @@ -84,3 +87,42 @@ describe('jQuery challenge', function () { ); }); }); + +describe('Custom output for JavaScript objects', function () { + beforeEach(() => { + cy.visit(locations.js); + cy.get(selectors.editor, { + timeout: 15000 + }) + .first() + .click() + .focused() + .type('{ctrl}a') + .clear(); + }); + + it('Set object', () => { + cy.get(selectors.editor) + .first() + .click() + .focused() + .type( + 'const set = new Set();{enter}set.add(1);{enter}set.add("set");{enter}set.add(10);{enter}console.log(set);' + ); + cy.get(selectors.defaultOutput).should('contain', 'Set(3) {1, set, 10}'); + }); + + it('Map object', () => { + cy.get(selectors.editor) + .first() + .click() + .focused() + .type( + 'const map = new Map();{enter}map.set("first", 1);{enter}map.set("second", 2);{enter}map.set("other", "map");{enter}console.log(map);' + ); + cy.get(selectors.defaultOutput).should( + 'contain', + 'Map(3) {first => 1, second => 2, other => map})' + ); + }); +});