Skip to content

Commit d3ed313

Browse files
committed
test: 💍 (upgrade) upgrade test to the latest jest version
1 parent 002e020 commit d3ed313

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

projects/ng-sortgrid/src/lib/helpers/class/ngsg-class.service.spec.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {NgsgClassService} from './ngsg-class.service';
2-
import createSpy = jasmine.createSpy;
32

43
describe('NgsgClassService', () => {
54

@@ -8,56 +7,56 @@ describe('NgsgClassService', () => {
87
beforeEach(() => sut = new NgsgClassService());
98

109
it('should add the placeholder class', () => {
11-
const addClassSpy = createSpy();
10+
const addClassSpy = jest.fn();
1211
const element = {classList: {add: addClassSpy}} as any;
1312
sut.addPlaceHolderClass(element);
1413
expect(addClassSpy).toHaveBeenCalledWith('ng-sg-placeholder');
1514
});
1615

1716
it('should remove the placeholder class', () => {
18-
const removeClassSpy = createSpy();
17+
const removeClassSpy = jest.fn();
1918
const element = {classList: {remove: removeClassSpy}} as any;
2019
sut.removePlaceHolderClass(element);
2120
expect(removeClassSpy).toHaveBeenCalledWith('ng-sg-placeholder');
2221
});
2322

2423
it('should add the dropped class', () => {
25-
const addClassSpy = createSpy();
24+
const addClassSpy = jest.fn();
2625
const element = {classList: {add: addClassSpy}} as any;
2726
sut.addDroppedClass(element);
2827
expect(addClassSpy).toHaveBeenCalledWith('ng-sg-dropped');
2928
});
3029

3130
it('should remove the placeholder class', () => {
32-
const removeClassSpy = createSpy();
31+
const removeClassSpy = jest.fn();
3332
const element = {classList: {remove: removeClassSpy}} as any;
3433
sut.removeDroppedClass(element);
3534
expect(removeClassSpy).toHaveBeenCalledWith('ng-sg-dropped');
3635
});
3736

3837
it('should add the dropped class', () => {
39-
const addClassSpy = createSpy();
38+
const addClassSpy = jest.fn();
4039
const element = {classList: {add: addClassSpy}} as any;
4140
sut.addSelectedClass(element);
4241
expect(addClassSpy).toHaveBeenCalledWith('ng-sg-selected');
4342
});
4443

4544
it('should remove the placeholder class', () => {
46-
const removeClassSpy = createSpy();
45+
const removeClassSpy = jest.fn();
4746
const element = {classList: {remove: removeClassSpy}} as any;
4847
sut.removeSelectedClass(element);
4948
expect(removeClassSpy).toHaveBeenCalledWith('ng-sg-selected');
5049
});
5150

5251
it('should add the active class', () => {
53-
const addClassSpy = createSpy();
52+
const addClassSpy = jest.fn();
5453
const element = {classList: {add: addClassSpy}} as any;
5554
sut.addActiveClass(element);
5655
expect(addClassSpy).toHaveBeenCalledWith('ng-sg-active');
5756
});
5857

5958
it('should remove the active class', () => {
60-
const removeClassSpy = createSpy();
59+
const removeClassSpy = jest.fn();
6160
const element = {classList: {remove: removeClassSpy}} as any;
6261
sut.removeActiveClass(element);
6362
expect(removeClassSpy).toHaveBeenCalledWith('ng-sg-active');

projects/ng-sortgrid/src/lib/helpers/scroll/scroll-helper.service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('Scroll helper', () => {
1515

1616
beforeEach(() => {
1717
sut = new ScrollHelperService(documentMock);
18-
scrollSpy = spyOn(documentMock.defaultView, 'scrollBy');
18+
scrollSpy = jest.spyOn(documentMock.defaultView, 'scrollBy');
1919
});
2020

2121
describe('Top scroll', () => {

projects/ng-sortgrid/src/lib/ngsg-item.directive.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ describe('NgsgItemDirective', () => {
242242
it('should log a warning message if you drop and you did not provide any items', () => {
243243
const expectedWarniningMessage = `Ng-sortgrid: No items provided - please use [sortGridItems] to pass in an array of items -
244244
otherwhise the ordered items can not be emitted in the (sorted) event`;
245-
const consoleWarnSpy = spyOn(console, 'warn');
245+
const consoleWarnSpy = jest.spyOn(console, 'warn');
246246
ngsgStore.hasItems = () => false;
247247

248248
sut.drop();

projects/ng-sortgrid/src/lib/sort/sort/ngsg-sort.service.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ describe('NgsgSortService', () => {
4242

4343
ngsgStore.getFirstSelectItem = () => ({ originalIndex: 0 } as any);
4444
ngsgStore.getSelectedItems = () => [dragElement] as any;
45-
const insertBeforeSpy = spyOn(dropElement.parentNode, 'insertBefore');
45+
const insertBeforeSpy = jest.spyOn(dropElement.parentNode, 'insertBefore');
4646
NgsgElementsHelper.findIndex = () => 1;
4747

4848
sut.initSort(group);
@@ -61,7 +61,7 @@ describe('NgsgSortService', () => {
6161

6262
ngsgStore.getFirstSelectItem = () => ({ originalIndex: 2 } as any);
6363
ngsgStore.getSelectedItems = () => [dragElement];
64-
const insertBeforeSpy = spyOn(dropElement.parentNode, 'insertBefore');
64+
const insertBeforeSpy = jest.spyOn(dropElement.parentNode, 'insertBefore');
6565
NgsgElementsHelper.findIndex = () => 1;
6666

6767
sut.initSort(group);

0 commit comments

Comments
 (0)