本文整理汇总了TypeScript中xhr-mock.setup函数的典型用法代码示例。如果您正苦于以下问题:TypeScript setup函数的具体用法?TypeScript setup怎么用?TypeScript setup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setup函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: beforeEach
beforeEach(() => {
// Init SUSH
sush = new SUSH();
// Stubs
origSend = XMLHttpRequest.prototype.send;
xhrMock.setup();
});
示例2: resetSpies
testNode2,
testNode3,
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();
示例3: mockSetup
public static mockSetup(): void {
xhrmock.setup();
}
示例4: beforeEach
beforeEach(() => mock.setup());
示例5: describe
/// <reference path="../lib/mocha.d.ts" />
/// <reference path="../lib/chai.d.ts" />
/// <reference path="../lib/xhrmock.d.ts" />
import * as Ajax from '../src/ajax';
import {expect} from 'chai';
import * as Mock from 'xhr-mock';
Mock.setup();
describe("Ajax", () => {
describe("#send", () => {
it('should send a request', () => {
var req = new Ajax.Request('get', '/test');
// TODO write tests
req.send().then(response => console.log(response)).done();
});
});
describe('#camelizeKeys', () => {
it("camelize an object's keys", () => {
var object = {
$foo_bar: 4, bar_foo: [{ foo_bar: 10 }, 'jon_doe'],
nested_object: { nested_keys_are: 'converted' }
};
var result = '{"$fooBar":4,"barFoo":[{"fooBar":10},"jon_doe"],"nestedObject":{"nestedKeysAre":"converted"}}';
object = Ajax.camelizeKeys(object);
expect(JSON.stringify(object)).to.equal(result);
});