Skip to content

Commit e5acef5

Browse files
committed
TestVariationsService. updateIgnoreAreas covered
1 parent 0f471ea commit e5acef5

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

src/test-variations/test-variations.service.spec.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import { TestVariationsService } from './test-variations.service';
33
import { PrismaService } from '../prisma/prisma.service';
44
import { CreateTestRequestDto } from '../test/dto/create-test-request.dto';
55
import { StaticService } from '../shared/static/static.service';
6+
import { IgnoreAreaDto } from 'src/test/dto/ignore-area.dto';
67

78
const initModule = async ({
89
findManyMock = jest.fn().mockReturnValue([]),
910
createMock = jest.fn(),
11+
updateMock = jest.fn()
1012
}) => {
1113
const module: TestingModule = await Test.createTestingModule({
1214
providers: [
@@ -16,7 +18,8 @@ const initModule = async ({
1618
provide: PrismaService, useValue: {
1719
testVariation: {
1820
findMany: findManyMock,
19-
create: createMock
21+
create: createMock,
22+
update: updateMock,
2023
}
2124
}
2225
},
@@ -113,4 +116,31 @@ describe('TestVariationsService', () => {
113116
expect(result).toBe(data)
114117
})
115118
})
119+
120+
describe('updateIgnoreAreas', () => {
121+
it('can update', async () => {
122+
const id = 'test id'
123+
const ignoreAreas: IgnoreAreaDto[] = [
124+
{
125+
x: 1,
126+
y: 2.3,
127+
width: 442.1,
128+
height: 32.0
129+
}
130+
]
131+
const updateMock = jest.fn()
132+
service = await initModule({ updateMock })
133+
134+
await service.updateIgnoreAreas(id, ignoreAreas)
135+
136+
expect(updateMock).toBeCalledWith({
137+
where: {
138+
id
139+
},
140+
data: {
141+
ignoreAreas: JSON.stringify(ignoreAreas)
142+
}
143+
})
144+
})
145+
})
116146
});

0 commit comments

Comments
 (0)