本文整理汇总了TypeScript中ava.beforeEach函数的典型用法代码示例。如果您正苦于以下问题:TypeScript beforeEach函数的具体用法?TypeScript beforeEach怎么用?TypeScript beforeEach使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了beforeEach函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: getContext
export function beforeEach<T>(getContext: () => Promise<T>): RegisterContextual<T> {
ava.beforeEach(async t => {
Object.assign(t.context, await getContext());
});
return ava;
}
开发者ID:OneSignal,项目名称:OneSignal-Website-SDK,代码行数:7,代码来源:typify.ts
示例2: function
registrationOptions: { scope: '/' }
});
}
}
// manually create and restore the sandbox
let sandbox: SinonSandbox;
let getRegistrationStub: SinonStub;
test.beforeEach(async function() {
sandbox = sinon.sandbox.create();
await TestEnvironment.stubDomEnvironment();
getRegistrationStub = sandbox.stub(navigator.serviceWorker, 'getRegistration').callThrough();
const appConfig = TestEnvironment.getFakeAppConfig();
appConfig.appId = Random.getRandomUuid();
OneSignal.context = new Context(appConfig);
// global assign required for TestEnvironment.stubDomEnvironment()
(global as any).OneSignal = { context: OneSignal.context };
});
test.afterEach(function () {
if (getRegistrationStub.callCount > 0)
sandbox.assert.alwaysCalledWithExactly(getRegistrationStub, location.href);
sandbox.restore();
});
test('getActiveState() detects no installed worker', async t => {
const manager = LocalHelpers.getServiceWorkerManager();
开发者ID:OneSignal,项目名称:OneSignal-Website-SDK,代码行数:31,代码来源:ServiceWorkerManager.ts
示例3: DOMParser
test.beforeEach(async () => {
GrimoireInterface.clear();
const parser = new DOMParser();
const htmlDoc = parser.parseFromString(testcase1_html, "text/html");
global.document = htmlDoc;
global.document.querySelectorAll = function(selector) {
return global.document.getElementsByTagName("script");
};
global.Node = {
ELEMENT_NODE: 1
};
goml();
testNode1();
testNode2();
testNode3();
testNodeBase();
conflictNode1();
conflictNode2();
stringConverterSpy = stringConverter();
testComponent1Spy = testComponent1();
testComponent2Spy = testComponent2();
testComponent3Spy = testComponent3();
testComponentBaseSpy = testComponentBase();
testComponentOptionalSpy = testComponentOptional();
conflictComponent1Spy = conflictComponent1();
conflictComponent2Spy = conflictComponent2();
await GrimoireInterface.resolvePlugins();
await GomlLoader.loadForPage();
global["rootNode"] = _.values(GrimoireInterface.rootNodes)[0];
global["rootNode"].element.ownerDocument = global["document"];
});
开发者ID:emadurandal,项目名称:GrimoireJS,代码行数:31,代码来源:NodeInterfaceTest.ts
示例4: proxyquire
import * as sinon from 'sinon';
import * as proxyquire from 'proxyquire';
import { A, O } from 'boa-core';
import { Route } from 'boa-router';
import { init as initType } from '../src/';
import { History as HistoryType } from '../src/history';
import 'rxjs/add/observable/empty';
import 'rxjs/add/observable/of';
test.beforeEach(t => {
const sandbox = sinon.sandbox.create();
const go = sandbox.stub();
const start = sandbox.stub();
const History = sandbox.stub();
History.prototype.go = go;
History.prototype.start = start;
t.context.go = go;
t.context.start = start;
t.context.History = History;
t.context.init = proxyquire('../src/', {
'./history': { History }
}).init;
});
test(t => {
t.plan(3);
const init: typeof initType = t.context.init;
const History: sinon.SinonStub = t.context.History;
const go: sinon.SinonStub = t.context.go;
const start: sinon.SinonStub = t.context.start;
const routes: Route[] = [];
const action$ = O.empty<A<any>>();
开发者ID:bouzuya,项目名称:boa-handler-history,代码行数:32,代码来源:index.ts
示例5: CookieStorage
import test from 'ava';
import {NullStorage, CookieStorage, getAvailableStorage} from '../src/storage';
import * as detector from '../src/detector';
let cookie_key: string;
let cookie_data: string;
test.beforeEach(t => {
cookie_key = 'key',
cookie_data = 'data';
});
test('CookieStorage setItem writes data to a cookie', t => {
let storage = new CookieStorage();
storage.setItem(cookie_key, cookie_data);
t.deepEqual(storage.getItem(cookie_key), cookie_data);
});
test('CookieStorage removeItem removes the cookie', t => {
let storage = new CookieStorage();
storage.setItem(cookie_key, cookie_data);
storage.removeItem(cookie_key);
t.deepEqual(storage.getItem(cookie_key), null);
});
开发者ID:coveo,项目名称:coveo.analytics.js,代码行数:24,代码来源:storage_test.ts
示例6: DefaultHost
import test from 'ava';
import { resolve } from 'path';
import { readFileSync, existsSync, unlinkSync } from 'fs';
import { DefaultHost } from '../src/host';
test.beforeEach(t => {
t.context.host = new DefaultHost();
});
test('DefaultHost#cwd should return the current directory', t => {
t.is(t.context.host.cwd(), process.cwd());
});
test('DefaultHost#fileExists should return true for existing file', t => {
t.true(t.context.host.fileExists('../../package.json'));
});
test('DefaultHost#fileExists should return false for non-existing file', t => {
t.false(t.context.host.fileExists('./package.json'));
});
test('DefaultHost#isFile should return true for file', t => {
t.true(t.context.host.isFile('../../package.json'));
});
test('DefaultHost#isFile should return false for directory', t => {
t.false(t.context.host.isFile('../../node_modules'));
});
test('DefaultHost#readFile should return the file content', t => {
开发者ID:ZauberNerd,项目名称:paeckchen,代码行数:31,代码来源:host-test.ts
示例7:
import { TestEnvironment, HttpHttpsEnvironment } from '../../support/sdk/TestEnvironment';
import ServiceWorkerRegistration from '../../support/mocks/service-workers/models/ServiceWorkerRegistration';
import PushManager from '../../support/mocks/service-workers/models/PushManager';
import PushSubscriptionOptions from '../../support/mocks/service-workers/models/PushSubscriptionOptions';
import PushSubscription from '../../support/mocks/service-workers/models/PushSubscription';
import Random from "../../support/tester/Random";
const VAPID_PUBLIC_KEY_1 = 'CAdXhdGDgXJfJccxabiFhmlyTyF17HrCsfyIj3XEhg2j-RmT4wXU7lHiBPqSKSotvtfejZlAaPywJ3E-3AxXQBj1';
const VAPID_PUBLIC_KEY_2 =
'MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEgrjd4cWBgjEtiIqh45fbzkJdlr8ir7ZidvNzMAsHP_uBQuPsn1n5QWYqJy80fkkjbf-1LH99C_y9RjLGjsesUg';
test.beforeEach(async t => {
await TestEnvironment.initialize({
httpOrHttps: HttpHttpsEnvironment.Https
});
await navigator.serviceWorker.register('/worker.js');
});
test('mock push manager properties should exist', async t => {
const registration: ServiceWorkerRegistration = await navigator.serviceWorker.getRegistration() as any;
t.true(registration.pushManager instanceof PushManager);
t.true(registration.pushManager.getSubscription instanceof Function);
t.true(registration.pushManager.subscribe instanceof Function);
});
test('mock push manager should not return an existing subscription for a clean run', async t => {
const registration: ServiceWorkerRegistration = await navigator.serviceWorker.getRegistration() as any;
开发者ID:OneSignal,项目名称:OneSignal-Website-SDK,代码行数:29,代码来源:mockPushManager.ts
示例8:
const stateSubscribedClass = "state-subscribed";
const stateUnsubscribedClass = "state-unsubscribed";
test.beforeEach(async () => {
config = {
enabled: true,
style: "button",
size: "small",
color: {
button: "#000000",
text: "#ffffff",
},
text: {
subscribe: "Let's do it",
unsubscribe: "I don't want it anymore",
explanation: "Wanna stay in touch?",
},
unsubscribeEnabled: true,
};
await TestEnvironment.initialize({
addPrompts: true,
httpOrHttps: HttpHttpsEnvironment.Https,
});
TestEnvironment.mockInternalOneSignal();
sandbox.stub(OneSignal.context.dynamicResourceLoader, 'loadSdkStylesheet')
.returns(ResourceLoadState.Loaded);
});
test.afterEach(function () {
sandbox.restore();
开发者ID:OneSignal,项目名称:OneSignal-Website-SDK,代码行数:31,代码来源:CustomLink.ts
示例9: PipeParser
import test from 'ava';
import { PipeParser } from './PipeParser';
const templateFilename: string = 'test.template.html';
let parser: PipeParser;
test.beforeEach(() => {
parser = new PipeParser();
});
test('should only extract string using pipe', async t => {
const contents = `<button [style.background]="'lime'">{{ 'SomeKey_NotWorking' | translate }}</button>`;
const keys = parser.extract(contents, templateFilename).keys();
t.deepEqual(keys, ['SomeKey_NotWorking']);
});
test('should extract interpolated strings using translate pipe', async t => {
const contents = `Hello {{ 'World' | translate }}`;
const keys = parser.extract(contents, templateFilename).keys();
t.deepEqual(keys, ['World']);
});
test.skip('should extract strings with escaped quotes', async t => {
const contents = `Hello {{ 'World\'s largest potato' | translate }}`;
const keys = parser.extract(contents, templateFilename).keys();
t.deepEqual(keys, [`World's largest potato`]);
});
test('should extract interpolated strings using translate pipe in attributes', async t => {
const contents = `<span attr="{{ 'Hello World' | translate }}"></span>`;
const keys = parser.extract(contents, templateFilename).keys();
开发者ID:bvkimball,项目名称:linguist,代码行数:31,代码来源:PipeParser.spec.ts
示例10: getGraphQLProjectConfig
import test from 'ava'
import {
getGraphQLProjectConfig,
GraphQLEndpointsExtension,
getUsedEnvs,
} from '../../'
import { serveSchema } from '../utils'
let endpoints: GraphQLEndpointsExtension
test.beforeEach(() => {
endpoints = getGraphQLProjectConfig(__dirname)
.endpointsExtension as GraphQLEndpointsExtension
})
test('getEndpointsMap', async t => {
t.deepEqual(endpoints.getRawEndpointsMap(), {
default: {
url: '${env:TEST_ENDPOINT_URL}',
},
})
})
test('getEndpointEnvVars should returns null for undefined env var', async t => {
t.deepEqual(endpoints.getEnvVarsForEndpoint('default'), {
TEST_ENDPOINT_URL: null,
})
})
test('getEndpointEnvVars should returns value for defined env var', async t => {
const testURL = 'http://test.com'
process.env['TEST_ENDPOINT_URL'] = testURL
开发者ID:graphcool,项目名称:graphql-config,代码行数:31,代码来源:string-refs.ts
注:本文中的ava.beforeEach函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论