-
Notifications
You must be signed in to change notification settings - Fork 424
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(plugins): remove jQuery from Grid State plugin (#757)
- Loading branch information
1 parent
8c72373
commit aa8dc63
Showing
8 changed files
with
224 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,10 @@ | ||
# http://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_style = space | ||
indent_size = 2 | ||
insert_final_newline = false | ||
trim_trailing_whitespace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,114 @@ | ||
|
||
describe('Example 0070 - Grid State using Local Storage', () => { | ||
const originalTitles = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J']; | ||
|
||
beforeEach(() => { | ||
cy.restoreLocalStorage(); | ||
}); | ||
|
||
afterEach(() => { | ||
cy.saveLocalStorage(); | ||
}); | ||
|
||
it('should display Example title', () => { | ||
cy.visit(`${Cypress.config('baseExampleUrl')}/example-0070-plugin-state.html`); | ||
cy.get('h2 p').should('contain', 'Slick.State'); | ||
|
||
cy.clearLocalStorage(); | ||
cy.get('[data-test="clear-storage"]').click(); | ||
}); | ||
|
||
it('should have exact Column Titles in the grid', () => { | ||
cy.get('.slick-header-columns') | ||
.children() | ||
.each(($child, index) => expect($child.text()).to.eq(originalTitles[index])); | ||
}); | ||
|
||
it('should sort ascending column "D"', () => { | ||
cy.get('.slick-header-columns .slick-header-column:nth(3)') | ||
.click({ force: true }); | ||
|
||
cy.get('.slick-header-columns') | ||
.children('.slick-header-column:nth(3)') | ||
.find('.slick-sort-indicator.slick-sort-indicator-asc') | ||
.should('be.visible'); | ||
}); | ||
|
||
it('should drag column "A" to be after column "C" in the grid', () => { | ||
const expectedTitles = ['A', 'C', 'D', 'B', 'E', 'F', 'G', 'H', 'I', 'J']; | ||
|
||
cy.get('.slick-header-columns') | ||
.children('.slick-header-column:nth(1)') | ||
.contains('B') | ||
.drag('.slick-header-column:nth(3)'); | ||
|
||
cy.get('.slick-header-column:nth(3)').contains('B'); | ||
|
||
cy.get('.slick-header-columns') | ||
.children() | ||
.each(($child, index) => expect($child.text()).to.eq(expectedTitles[index])); | ||
}); | ||
|
||
it('should resize 1st column and make it wider', () => { | ||
cy.get('.slick-header-columns') | ||
.children('.slick-header-column:nth(1)') | ||
.should('contain', 'C'); | ||
|
||
cy.get('.slick-resizable-handle:nth(1)') | ||
.trigger('mousedown', { which: 1, force: true }) | ||
.trigger('mousemove', 'bottomRight'); | ||
|
||
cy.get('.slick-header-column:nth(2)') | ||
.trigger('mousemove', 'bottomRight') | ||
.trigger('mouseup', 'bottomRight', { which: 1, force: true }); | ||
|
||
cy.get('.slick-header-column:nth(1)') | ||
.should(($el) => { | ||
const expectedWidth = 170; // calculate with a calculated width including a ( /-)5px precision | ||
expect($el.width()).greaterThan(expectedWidth - 5); | ||
expect($el.width()).lessThan(expectedWidth 5); | ||
}); | ||
}); | ||
|
||
it('should reload the page', () => { | ||
cy.reload().wait(50); | ||
}); | ||
|
||
it('should reload page and expect same columns orders, 2nd column wider and 3rd column sorted ascending', () => { | ||
const expectedTitles = ['A', 'C', 'D', 'B', 'E', 'F', 'G', 'H', 'I', 'J']; | ||
|
||
cy.get('.slick-header-columns') | ||
.children() | ||
.each(($child, index) => expect($child.text()).to.eq(expectedTitles[index])); | ||
|
||
cy.get('.slick-header-column:nth(1)') | ||
.should(($el) => { | ||
const expectedWidth = 170; // calculate with a calculated width including a ( /-)5px precision | ||
expect($el.width()).greaterThan(expectedWidth - 5); | ||
expect($el.width()).lessThan(expectedWidth 5); | ||
}); | ||
|
||
cy.get('.slick-header-columns') | ||
.children('.slick-header-column:nth(2)') | ||
.find('.slick-sort-indicator.slick-sort-indicator-asc') | ||
.should('be.visible'); | ||
}); | ||
|
||
it('should clear local storage & reload the page', () => { | ||
cy.clearLocalStorage(); | ||
cy.get('[data-test="clear-storage"]').click(); | ||
|
||
cy.reload().wait(50); | ||
}); | ||
|
||
it('should expect grid to be reset to default', () => { | ||
cy.get('.slick-header-columns') | ||
.children() | ||
.each(($child, index) => expect($child.text()).to.eq(originalTitles[index])); | ||
|
||
cy.get('.slick-header-columns') | ||
.children('.slick-header-column:nth(2)') | ||
.find('.slick-sort-indicator.slick-sort-indicator-asc') | ||
.should('not.exist'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.