本文整理匯總了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);
});