@@ -4,7 +4,6 @@ import * as path from "path";
4
4
import fs from "fs-extra" ;
5
5
import chaiAsPromised from "chai-as-promised" ;
6
6
import sinon from "sinon" ;
7
- import axios , { AxiosInstance , AxiosRequestConfig , AxiosResponse , AxiosPromise } from "axios" ;
8
7
import { ManifestUtil , TeamsAppManifest , TeamsAppManifestJSONSchema } from "../src" ;
9
8
chai . use ( chaiAsPromised ) ;
10
9
@@ -54,16 +53,11 @@ describe("Manifest manipulation", async () => {
54
53
55
54
describe ( "validateManifest" , async ( ) => {
56
55
const mocker = sinon . createSandbox ( ) ;
57
- const axiosInstanceMock = createMockedAxiosInstance ( ) ;
58
- axiosInstanceMock . get = async function < T = any , R = AxiosResponse < T > > (
59
- url : string ,
60
- config ?: AxiosRequestConfig
61
- ) : Promise < R > {
62
- return { data : loadSchema ( ) } as unknown as R ;
63
- } ;
56
+
57
+ const schema = await loadSchema ( ) ;
64
58
65
59
before ( ( ) => {
66
- mocker . stub ( axios , "create " ) . returns ( axiosInstanceMock ) ;
60
+ mocker . stub ( ManifestUtil , "fetchSchema " ) . resolves ( schema ) ;
67
61
} ) ;
68
62
69
63
after ( ( ) => {
@@ -111,66 +105,3 @@ async function loadSchema(): Promise<TeamsAppManifestJSONSchema> {
111
105
const schemaPath = path . join ( __dirname , "MicrosoftTeams.schema.json" ) ;
112
106
return fs . readJson ( schemaPath ) ;
113
107
}
114
-
115
- function createMockedAxiosInstance ( ) : AxiosInstance {
116
- const mockAxiosInstance = ( url : string , config ?: AxiosRequestConfig ) : AxiosPromise => {
117
- throw new Error ( "Method not implemented." ) ;
118
- } ;
119
- mockAxiosInstance . defaults = axios . defaults ;
120
- mockAxiosInstance . interceptors = axios . interceptors ;
121
- mockAxiosInstance . getUri = ( config ?: AxiosRequestConfig ) : string => {
122
- throw new Error ( "Method not implemented." ) ;
123
- } ;
124
- mockAxiosInstance . request = function < T = any , R = AxiosResponse < T > > (
125
- config : AxiosRequestConfig
126
- ) : Promise < R > {
127
- throw new Error ( "Method not implemented." ) ;
128
- } ;
129
- mockAxiosInstance . get = function < T = any , R = AxiosResponse < T > > (
130
- url : string ,
131
- config ?: AxiosRequestConfig
132
- ) : Promise < R > {
133
- throw new Error ( "Method not implemented." ) ;
134
- } ;
135
- mockAxiosInstance . delete = function < T = any , R = AxiosResponse < T > > (
136
- url : string ,
137
- config ?: AxiosRequestConfig
138
- ) : Promise < R > {
139
- throw new Error ( "Method not implemented." ) ;
140
- } ;
141
- mockAxiosInstance . head = function < T = any , R = AxiosResponse < T > > (
142
- url : string ,
143
- config ?: AxiosRequestConfig
144
- ) : Promise < R > {
145
- throw new Error ( "Method not implemented." ) ;
146
- } ;
147
- mockAxiosInstance . options = function < T = any , R = AxiosResponse < T > > (
148
- url : string ,
149
- config ?: AxiosRequestConfig
150
- ) : Promise < R > {
151
- throw new Error ( "Method not implemented." ) ;
152
- } ;
153
- mockAxiosInstance . post = function < T = any , R = AxiosResponse < T > > (
154
- url : string ,
155
- data ?: any ,
156
- config ?: AxiosRequestConfig
157
- ) : Promise < R > {
158
- throw new Error ( "Method not implemented." ) ;
159
- } ;
160
- mockAxiosInstance . put = function < T = any , R = AxiosResponse < T > > (
161
- url : string ,
162
- data ?: any ,
163
- config ?: AxiosRequestConfig
164
- ) : Promise < R > {
165
- throw new Error ( "Method not implemented." ) ;
166
- } ;
167
- mockAxiosInstance . patch = function < T = any , R = AxiosResponse < T > > (
168
- url : string ,
169
- data ?: any ,
170
- config ?: AxiosRequestConfig
171
- ) : Promise < R > {
172
- throw new Error ( "Method not implemented." ) ;
173
- } ;
174
-
175
- return mockAxiosInstance as AxiosInstance ;
176
- }
0 commit comments