1
+ import { HfInference , HfInferenceEndpoint } from '@huggingface/inference' ;
1
2
import { describe , expect , test } from '@jest/globals' ;
2
3
import { runInference } from './inference' ;
3
- import { Task } from './tasks' ;
4
- import { HfInference , HfInferenceEndpoint } from '@huggingface/inference' ;
4
+ import { TaskId } from './tasks' ;
5
5
6
6
const inference = new HfInference ( 'test' ) ;
7
7
@@ -20,7 +20,7 @@ jest.mock('@huggingface/inference', () => ({
20
20
} ) ) ,
21
21
} ) ) ;
22
22
23
- describe ( Task . fillMask , ( ) => {
23
+ describe ( TaskId . fillMask , ( ) => {
24
24
test ( 'should throw an error if inputs are not provided' , async ( ) => {
25
25
const snapshot = {
26
26
data : ( ) => ( {
@@ -29,7 +29,7 @@ describe(Task.fillMask, () => {
29
29
} as any ;
30
30
31
31
await expect (
32
- runInference ( snapshot , Task . fillMask , inference ) ,
32
+ runInference ( snapshot , TaskId . fillMask , inference ) ,
33
33
) . rejects . toThrow ( Error ) ;
34
34
} ) ;
35
35
@@ -41,12 +41,12 @@ describe(Task.fillMask, () => {
41
41
} as any ;
42
42
43
43
await expect (
44
- runInference ( snapshot , Task . fillMask , inference ) ,
44
+ runInference ( snapshot , TaskId . fillMask , inference ) ,
45
45
) . rejects . toThrow ( Error ) ;
46
46
} ) ;
47
47
} ) ;
48
48
49
- describe ( Task . summarization , ( ) => {
49
+ describe ( TaskId . summarization , ( ) => {
50
50
test ( 'should throw an error if inputs are not provided' , async ( ) => {
51
51
const snapshot = {
52
52
data : ( ) => ( {
@@ -55,7 +55,7 @@ describe(Task.summarization, () => {
55
55
} as any ;
56
56
57
57
await expect (
58
- runInference ( snapshot , Task . summarization , inference ) ,
58
+ runInference ( snapshot , TaskId . summarization , inference ) ,
59
59
) . rejects . toThrow ( Error ) ;
60
60
} ) ;
61
61
@@ -67,18 +67,18 @@ describe(Task.summarization, () => {
67
67
} as any ;
68
68
69
69
await expect (
70
- runInference ( snapshot , Task . summarization , inference ) ,
70
+ runInference ( snapshot , TaskId . summarization , inference ) ,
71
71
) . rejects . toThrow ( Error ) ;
72
72
} ) ;
73
73
} ) ;
74
74
75
75
// Testing questionAnswering task.
76
- describe ( Task . questionAnswering , ( ) => {
77
- let mockTask : Task ;
76
+ describe ( TaskId . questionAnswering , ( ) => {
77
+ let mockTask : TaskId ;
78
78
let inference : HfInference | HfInferenceEndpoint ;
79
79
80
80
beforeAll ( ( ) => {
81
- mockTask = Task . questionAnswering ;
81
+ mockTask = TaskId . questionAnswering ;
82
82
inference = new HfInference ( ) ;
83
83
} ) ;
84
84
@@ -140,8 +140,8 @@ describe(Task.questionAnswering, () => {
140
140
} ) ;
141
141
142
142
// Testing tableQuestionAnswering task.
143
- describe ( Task . tableQuestionAnswering , ( ) => {
144
- let mockTask : Task ;
143
+ describe ( TaskId . tableQuestionAnswering , ( ) => {
144
+ let mockTask : TaskId ;
145
145
let inference : HfInference | HfInferenceEndpoint ;
146
146
const snapshot = {
147
147
data : ( ) => ( {
@@ -156,7 +156,7 @@ describe(Task.tableQuestionAnswering, () => {
156
156
} as any ;
157
157
158
158
beforeAll ( ( ) => {
159
- mockTask = Task . tableQuestionAnswering ;
159
+ mockTask = TaskId . tableQuestionAnswering ;
160
160
inference = new HfInference ( ) ;
161
161
} ) ;
162
162
0 commit comments