Skip to content

Commit

Permalink
test: create new instance for each test
Browse files Browse the repository at this point in the history
  • Loading branch information
tomivirkki committed Dec 16, 2021
1 parent e92eac5 commit c6cd586
Showing 1 changed file with 5 additions and 32 deletions.
37 changes: 5 additions & 32 deletions test/drag-and-drop.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,12 @@
return event;
};

before(done => {
beforeEach(done => {
dragData = {};
grid = fixture('default');
grid.hidden = true;
grid.items = getTestItems();
flushGrid(grid);
requestAnimationFrame(() => {
// Wait for the appear animation to finish
listenOnce(grid, 'animationend', () => {
Expand All @@ -136,31 +139,6 @@
});
});

beforeEach(done => {
dragData = {};
if (!grid.parentElement) {
document.body.appendChild(grid);
}
grid.items = getTestItems();
flushGrid(grid);
if (grid._safari) {
setTimeout(() => done());
} else {
done();
}

});

afterEach(() => {
fireDragEnd(grid.$.table);
fireDrop(grid.$.table);
grid.rowsDraggable = false;
grid.dropMode = null;
grid.style.height = '';
grid.selectedItems = [];
grid.dataProvider = null;
});

it('should not be draggable by default', () => {
expect(getDraggable(grid)).not.to.be.ok;
});
Expand All @@ -186,18 +164,13 @@
let dragStartSpy;
let dropSpy;

before(() => {
beforeEach(() => {
dragStartSpy = sinon.spy();
dropSpy = sinon.spy();
grid.addEventListener('grid-dragstart', dragStartSpy);
grid.addEventListener('grid-drop', dropSpy);
});

beforeEach(() => {
grid.rowsDraggable = true;
grid.dropMode = 'on-top';
dragStartSpy.reset();
dropSpy.reset();
});

it('should stop the native event', () => {
Expand Down

0 comments on commit c6cd586

Please # to comment.