Skip to content

Commit

Permalink
Converted errors jasmine test to jest test fixes #770 (#771)
Browse files Browse the repository at this point in the history
* added script link to popper.min.js

* jest version for errors test file

Co-authored-by: Jeffrey Warren <[email protected]>
  • Loading branch information
NARUDESIGNS and jywarren authored Dec 30, 2021
1 parent 313c3c0 commit 1ab7b20
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/errors.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<link href="../dist/PublicLab.Editor.css" rel="stylesheet">

<script src="../node_modules/jquery/dist/jquery.min.js"></script>
<script src="../node_modules/popper.js/dist/umd/popper.min.js" type="text/javascript"></script>
<script src="../node_modules/bootstrap/dist/js/bootstrap.min.js"></script>

<!-- required for TagsModule -->
Expand Down
20 changes: 20 additions & 0 deletions test/ui-testing/errors.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const timeout = process.env.SLOWMO ? 60000 : 10000;
const fs = require('fs');
beforeAll(async () => {
path = fs.realpathSync('file://../examples/errors.html');
await page.goto('file://' + path, {waitUntil: 'domcontentloaded'});
});

describe('Errors', () => {
test('displays given errors', async () => {
expect( await page.evaluate(() => document.querySelectorAll('.ple-errors').length)).toBeGreaterThan(0);
expect( await page.evaluate(() => document.querySelectorAll('.ple-errors .alert').length)).toBe(1);
expect( await page.evaluate(() => document.querySelectorAll('.ple-errors p').length)).toBe(1);
expect( await page.evaluate(() => document.querySelector('.ple-errors p').innerText)).toBe("Error: title can't be blank.");
});

test("does not display error alert if there are no errors", async () => {
await page.evaluate(() => document.querySelector('.ple-errors').innerHTML = '');
expect( await page.evaluate(() => document.querySelectorAll('.ple-errors .alert').length) ).toBe(0);
});
});

0 comments on commit 1ab7b20

Please sign in to comment.