Skip to content

Commit

Permalink
Improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
dqnykamp committed Feb 13, 2023
1 parent e8d3634 commit e6408c3
Showing 1 changed file with 42 additions and 40 deletions.
82 changes: 42 additions & 40 deletions cypress/e2e/DoenetML/tagSpecific/conditionalcontent.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,48 @@ describe('Conditional Content Tag Tests', function () {

});

it('correctly withhold replacements when shadowing', () => {
cy.window().then(async (win) => {
win.postMessage({
doenetML: `
<p>Hide greeting:
<booleanInput name="hide" />
</p>
<p name="p">Greeting is hidden: $hide. Greeting: <conditionalContent condition="not $hide">Hello!</conditionalContent></p>
<p>Show copy:
<booleanInput name="show_copy" />
</p>
<conditionalContent condition="$show_copy" assignNames="(p2)">
$p
</conditionalContent>
`}, "*");
});

cy.get('#\\/p').should('have.text', 'Greeting is hidden: false. Greeting: Hello!');
cy.get('#\\/p2').should('not.exist');

cy.get('#\\/hide').click();

cy.get('#\\/p').should('have.text', 'Greeting is hidden: true. Greeting: ');
cy.get('#\\/p2').should('not.exist');


cy.get('#\\/show_copy').click();
cy.get('#\\/p2').should('have.text', 'Greeting is hidden: true. Greeting: ');


cy.get('#\\/hide').click();

cy.get('#\\/p').should('have.text', 'Greeting is hidden: false. Greeting: Hello!');
cy.get('#\\/p2').should('have.text', 'Greeting is hidden: false. Greeting: Hello!');



})


// tests with cases or else

Expand Down Expand Up @@ -2680,46 +2722,6 @@ describe('Conditional Content Tag Tests', function () {

})

it('correctly withhold replacements when shadowing', () => {
cy.window().then(async (win) => {
win.postMessage({
doenetML: `
<booleanInput name="bi" />
<p name="p">
<conditionalContent condition="$bi">
hello
</conditionalContent>
<conditionalContent condition="not $bi">
bye
</conditionalContent>
</p>
<booleanInput name="bi2" />
<conditionalContent condition="$bi2" assignNames="(p2)">
$p
</conditionalContent>
`}, "*");
});

cy.get('#\\/p').should('contain.text', 'bye');
cy.get('#\\/p').should('not.contain.text', 'hello');
cy.get('#\\/p2').should('not.exist');

cy.get('#\\/bi').click();

cy.get('#\\/p').should('contain.text', 'hello');
cy.get('#\\/p').should('not.contain.text', 'bye');
cy.get('#\\/p2').should('not.exist');


cy.get('#\\/bi2').click();

cy.get('#\\/p2').should('contain.text', 'hello');
cy.get('#\\/p2').should('not.contain.text', 'bye');
})


})

Expand Down

0 comments on commit e6408c3

Please sign in to comment.