|
| 1 | +const chai = require('chai'); |
| 2 | +const chaiAsPromised = require('chai-as-promised'); |
| 3 | +const chaiArrays = require('chai-arrays'); |
| 4 | + |
| 5 | +const utils = require('./utils.js'); |
| 6 | + |
| 7 | +const isVisible = utils.isVisible; |
| 8 | + |
| 9 | +chai.use(chaiAsPromised); |
| 10 | +chai.use(chaiArrays); |
| 11 | +const expect = chai.expect; |
| 12 | + |
| 13 | +describe('Libraries', function() { |
| 14 | + before(utils.launchBrowser); |
| 15 | + |
| 16 | + after(utils.closeBrowser); |
| 17 | + |
| 18 | + it('Displays libraries when clicking on navbar', async function() { |
| 19 | + await this.page.click('a[href="#libraries-io"]'); |
| 20 | + // Wait for scroll |
| 21 | + await this.page.waitFor(3000); |
| 22 | + expect(await this.page.$eval('#libraries-io', isVisible)).to.be.true; |
| 23 | + }); |
| 24 | + |
| 25 | + it('Displays a sorted library filter', async function() { |
| 26 | + const libraries = await this.page.$eval('#libraries-select', select => { |
| 27 | + const result = []; |
| 28 | + |
| 29 | + Array.prototype.forEach.call(select.children, element => { |
| 30 | + result.push(element.value); |
| 31 | + }); |
| 32 | + |
| 33 | + return result; |
| 34 | + }); |
| 35 | + |
| 36 | + expect(libraries).to.be.sorted; |
| 37 | + }); |
| 38 | + |
| 39 | + it('Hides and displays libraries using filters', async function() { |
| 40 | + await this.page.select('#libraries-select', '.php'); |
| 41 | + // Wait for animation |
| 42 | + await this.page.waitFor(2000); |
| 43 | + |
| 44 | + expect(await this.page.$eval('.php', isVisible)).to.be.true; |
| 45 | + expect(await this.page.$eval('.net', isVisible)).to.be.false; |
| 46 | + expect(await this.page.$eval('.python', isVisible)).to.be.false; |
| 47 | + |
| 48 | + await this.page.waitForSelector('.net', { |
| 49 | + hidden: true |
| 50 | + }); |
| 51 | + await this.page.waitForSelector('.python', { |
| 52 | + hidden: true |
| 53 | + }); |
| 54 | + |
| 55 | + await this.page.select('#libraries-select', '*'); |
| 56 | + // Wait for animation |
| 57 | + await this.page.waitFor(2000); |
| 58 | + |
| 59 | + await this.page.waitForSelector('.net', { |
| 60 | + visible: true |
| 61 | + }); |
| 62 | + await this.page.waitForSelector('.php', { |
| 63 | + visible: true |
| 64 | + }); |
| 65 | + await this.page.waitForSelector('.python', { |
| 66 | + visible: true |
| 67 | + }); |
| 68 | + }); |
| 69 | +}); |
0 commit comments