feat: test custom output for js objects (#45077)

This commit is contained in:
Krzysztof G
2022-02-10 21:38:03 +01:00
committed by GitHub
parent 16f7567827
commit 0f2246b750

View File

@ -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})'
);
});
});