|
| 1 | +describe('Ember SortableJS ', function() { |
| 2 | + it('renders a list', function() { |
| 3 | + const initial = ['one', 'two', 'three', 'four', 'five']; |
| 4 | + |
| 5 | + cy.visit('http://localhost:4200/simple'); |
| 6 | + |
| 7 | + cy |
| 8 | + .get('div[data-list-item]') |
| 9 | + .should(($divs) => { |
| 10 | + expect($divs).to.have.length(5); |
| 11 | + |
| 12 | + const renderedList = $divs.map((i, el) => el.innerText); |
| 13 | + |
| 14 | + expect(renderedList.get()).to.deep.eq(initial); |
| 15 | + }); |
| 16 | + }); |
| 17 | + |
| 18 | + it('reorders as list from top to bottom', function() { |
| 19 | + const sorted = ['two', 'three', 'four', 'five', 'one']; |
| 20 | + |
| 21 | + cy.visit('http://localhost:4200/simple'); |
| 22 | + cy.get('div[data-list-item="0"').drag('div[data-list-item="4"', { force: true, position: 'bottom' }) |
| 23 | + |
| 24 | + cy |
| 25 | + .get('div[data-list-item]') |
| 26 | + .should(($divs) => { |
| 27 | + expect($divs).to.have.length(5); |
| 28 | + |
| 29 | + const renderedList = $divs.map((i, el) => el.innerText); |
| 30 | + |
| 31 | + expect(renderedList.get()).to.deep.eq(sorted); |
| 32 | + }); |
| 33 | + }); |
| 34 | + |
| 35 | + it('reorders a list bottom to top', function() { |
| 36 | + const sorted = ['five', 'one', 'two', 'three', 'four']; |
| 37 | + |
| 38 | + cy.visit('http://localhost:4200/simple'); |
| 39 | + cy.get('div[data-list-item="4"').drag('div[data-list-item="0"', { force: true, position: 'center' }) |
| 40 | + |
| 41 | + cy |
| 42 | + .get('div[data-list-item]') |
| 43 | + .should(($divs) => { |
| 44 | + expect($divs).to.have.length(5); |
| 45 | + |
| 46 | + const renderedList = $divs.map((i, el) => el.innerText); |
| 47 | + |
| 48 | + expect(renderedList.get()).to.deep.eq(sorted); |
| 49 | + }); |
| 50 | + }); |
| 51 | + |
| 52 | + it('adds an item from one list to another', function() { |
| 53 | + cy.visit('http://localhost:4200/shared'); |
| 54 | + cy.get('.list-a > div[data-list-item="0"').drag('.list-b > div[data-list-item="1"', { force: true, position: 'top' }); |
| 55 | + |
| 56 | + const listA = ['Jaden', 'Gustavo']; |
| 57 | + const listB = ['Lance', 'Luis', 'Britni', 'Kelly']; |
| 58 | + |
| 59 | + cy |
| 60 | + .get('.list-a > div[data-list-item]') |
| 61 | + .should(($divs) => { |
| 62 | + expect($divs).to.have.length(2); |
| 63 | + |
| 64 | + const renderedList = $divs.map((i, el) => el.innerText); |
| 65 | + |
| 66 | + expect(renderedList.get()).to.deep.eq(listA); |
| 67 | + }); |
| 68 | + |
| 69 | + cy |
| 70 | + .get('.list-b > div[data-list-item]') |
| 71 | + .should(($divs) => { |
| 72 | + expect($divs).to.have.length(4); |
| 73 | + |
| 74 | + const renderedList = $divs.map((i, el) => el.innerText); |
| 75 | + |
| 76 | + expect(renderedList.get()).to.deep.eq(listB); |
| 77 | + }); |
| 78 | + }); |
| 79 | +}); |
0 commit comments