本文整理汇总了TypeScript中xhr-mock.get函数的典型用法代码示例。如果您正苦于以下问题:TypeScript get函数的具体用法?TypeScript get怎么用?TypeScript get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should error', async () => {
mock.get('/', () => Promise.reject(new Error('😬')));
try {
const res = await superagent.get('/');
expect.fail();
} catch (error) {
expect(error).to.be.an('Error');
expect(error.message.toLowerCase()).to.contain('terminated');
}
});
开发者ID:jameslnewell,项目名称:xhr-mock,代码行数:11,代码来源:superagent.test.ts
示例2: it
it('should error', async () => {
mock.get('/', () => Promise.reject(new Error('😬')));
await $.ajax('/').then(
() => expect.fail(),
(xhr, status, error) => {
expect(status).to.eq('error');
expect(error).to.contain('');
}
);
});
开发者ID:jameslnewell,项目名称:xhr-mock,代码行数:11,代码来源:jquery.test.ts
示例3: it
it('should time out', async () => {
mock.get('/', () => new Promise(() => {}));
try {
const res = await axios.get('/', {timeout: 10});
expect.fail();
} catch (error) {
expect(error).to.be.an('Error');
expect(error.message.toLowerCase()).to.contain('timeout');
}
});
开发者ID:jameslnewell,项目名称:xhr-mock,代码行数:11,代码来源:axios.test.ts
示例4: it
it('should send a response containing an array buffer', done => {
mock.get('/myfile.png', {
body: new ArrayBuffer(0)
});
// sourced from https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Sending_and_Receiving_Binary_Data
const req = new XMLHttpRequest();
req.open('GET', '/myfile.png');
req.responseType = 'arraybuffer';
req.onload = () => {
const arrayBuffer = req.response;
expect(arrayBuffer).to.be.an('ArrayBuffer');
done();
};
req.send(null);
});
开发者ID:jameslnewell,项目名称:xhr-mock,代码行数:16,代码来源:native.test.ts
示例5: resetSpies
testNodeBase,
conflictNode1,
conflictNode2,
conflictComponent1,
conflictComponent2
} from "../Node/GomlParserTest_Registering";
import GomlLoader from "../../src/Node/GomlLoader";
import GrimoireInterface from "../../src/Interface/GrimoireInterface";
import fs from "../fileHelper";
const testcase1_goml = fs.readFile("../_TestResource/GomlNodeTest_Case1.goml");
const testcase1_html = fs.readFile("../_TestResource/GomlNodeTest_Case1.html");
xhrmock.setup();
xhrmock.get("./GomlNodeTest_Case1.goml", (req, res) => {
return res.status(200).body(testcase1_goml);
});
let stringConverterSpy,
testComponent1Spy,
testComponent2Spy,
testComponent3Spy,
testComponentBaseSpy,
testComponentOptionalSpy,
conflictComponent1Spy,
conflictComponent2Spy;
function resetSpies() {
stringConverterSpy.reset();
testComponent1Spy.reset();
testComponent2Spy.reset();
开发者ID:emadurandal,项目名称:GrimoireJS,代码行数:31,代码来源:NodeInterfaceTest.ts
示例6: mockXMLParse
declare namespace global {
let Node: any;
let document: any;
}
const testcase1_html = fs.readFile("../_TestResource/GomlLoaderTest_Case1.html");
const testcase2_html = fs.readFile("../_TestResource/GomlLoaderTest_Case2.html");
const testcase3_html = fs.readFile("../_TestResource/GomlLoaderTest_Case3.html");
const testcase4_html = fs.readFile("../_TestResource/GomlLoaderTest_Case4.html");
xhrmock.setup();
xhrmock.get("http://grimoire.gl/index.goml", (req, res) => {
return res.status(200).body("<goml>\n</goml>");
});
xhrmock.get("http://grimoire.gl/index2.goml", (req, res) => {
return res.status(200).body("<goml>\n</goml>");
});
xhrmock.get("http://grimoire.gl/index3.goml", (req, res) => {
return res.status(200).body("<goml>\n</goml>");
});
function mockXMLParse(func) {
return prequire("../../src/Node/GomlLoader", {
"../Base/XMLReader": {
default: {
parseXML: (srcHtml) => {
func(srcHtml);
return XMLReader.parseXML(srcHtml);
开发者ID:emadurandal,项目名称:GrimoireJS,代码行数:30,代码来源:GomlLoaderTest.ts
示例7: mock
public static mock(path: string, content: string): void {
xhrmock.get(path, (req, res) => {
let aa = res.status(200).body(content);
return aa;
});
}
开发者ID:emadurandal,项目名称:GrimoireJS,代码行数:6,代码来源:PageLoadingHelper.ts
注:本文中的xhr-mock.get函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论