當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript xhr-mock.setup函數代碼示例

本文整理匯總了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();
 });
開發者ID:3846masa,項目名稱:SUSH,代碼行數:7,代碼來源:index.spec.ts

示例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();
開發者ID:emadurandal,項目名稱:GrimoireJS,代碼行數:31,代碼來源:NodeInterfaceTest.ts

示例3: mockSetup

 public static mockSetup(): void {
   xhrmock.setup();
 }
開發者ID:emadurandal,項目名稱:GrimoireJS,代碼行數:3,代碼來源:PageLoadingHelper.ts

示例4: beforeEach

 beforeEach(() => mock.setup());
開發者ID:jameslnewell,項目名稱:xhr-mock,代碼行數:1,代碼來源:rxjs.test.ts

示例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);
        });
開發者ID:kuon,項目名稱:ajax-utils,代碼行數:31,代碼來源:ajax.ts


注:本文中的xhr-mock.setup函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。