当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ava.afterEach函数代码示例

本文整理汇总了TypeScript中ava.afterEach函数的典型用法代码示例。如果您正苦于以下问题:TypeScript afterEach函数的具体用法?TypeScript afterEach怎么用?TypeScript afterEach使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了afterEach函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1:

      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();
});

test('customlink: container: not render if disabled', async t => {
  config = {
    enabled: false,
  };
  await CustomLink.initialize(config);

  const containerElements = document.querySelectorAll<HTMLElement>(CustomLink.containerSelector);
  t.is(containerElements.length, 2);
  containerElements.forEach((el: HTMLElement) => t.is(el.children.length, 0));
});

test('customlink: container: render if enabled, explanation present', async t => {
  sandbox.stub(OneSignal, 'privateIsPushNotificationsEnabled').returns(true);
开发者ID:OneSignal,项目名称:OneSignal-Website-SDK,代码行数:31,代码来源:CustomLink.ts

示例2: require

import TestOut from './helpers/test_out'

const fetchMock = require('fetch-mock')
const debug = require('debug')('graphcool')

/*
 Tests:
- Succeeding project clone with specific name
- Succeeding project clone with specific name and different output path
- Succeeding project clone with specific name and project ID
- Succeeding project clone with specific name, project file and output path
- Failing because no project ID provided (no project file in current directory)
 */

test.afterEach(() => {
  new TestOut().write('\n')
  fetchMock.restore()
})


test('Succeeding project clone with specific name', async t => {

  // configure HTTP mocks
  fetchMock.post(systemAPIEndpoint, JSON.parse(mockedClonedProjectResponse))

  // create dummy project data
  const copyProjectId = 'abcdefghiklmn'
  const clonedProjectName = `Clone of MyProject`
  const props = {
    name: clonedProjectName,
    copyProjectId,
开发者ID:sadeeqaji,项目名称:graphcool-cli,代码行数:31,代码来源:clone.test.ts

示例3: cb

    q.forEach(q => obj[q.name] = true);
    cb(obj);
  });
});

test.beforeEach(t => {
  t.context.db = Knex({
    client: 'sqlite3',
    connection: {
      filename: ':memory:'
    }
  });
});

test.afterEach(async function(t) {
  await t.context.db.destroy();
});

test.serial(`should add table`, async function(t) {
  const r = new Migration(add.one, add.two);
  await Migration.run(t.context.db, await r.up());
  t.true(await t.context.db.schema.hasTable('test_table'));  
});

test.serial(`should drop table`, async function(t) {
  const m = new Migration(add.one, add.two);
  await Migration.run(t.context.db, await m.up(), await m.down());
  t.false(await t.context.db.schema.hasTable('test_table'));  
});

test.serial(`should rename table`, async function(t) {
开发者ID:gitter-badger,项目名称:overland,代码行数:31,代码来源:model.ts

示例4: NullStorage

let data: history.HistoryElement;

test.beforeEach(t => {
  storage = new NullStorage();
  storageMock = sinon.mock(storage);
  historyStore = new history.HistoryStore(storage);
  data = {
    name: 'name',
    value: 'value',
    time: JSON.stringify(new Date())
  };
});

test.afterEach( t => {
  storage = null;
  storageMock = null;
  historyStore = null;
  data = null;
});

test('HistoryStore should be able to add an element in the history', t => {
  storageMock.expects('setItem').once().withArgs(history.STORE_KEY, sinon.match(/"value":"value"/).and(sinon.match(/"time"/)).and(sinon.match(/"internalTime"/)));
  historyStore.addElement(data);
  storageMock.verify();
});

test('History store should trim query over > 75 char', t => {
    data.value = '';
    let newValue = '';
    for (var i = 0; i < 100; i++) {
        newValue += i.toString();
    }
开发者ID:coveo,项目名称:coveo.analytics.js,代码行数:32,代码来源:history_test.ts

示例5: Context

  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();

  t.is(await manager.getActiveState(), ServiceWorkerActiveState.None);
});

test('getActiveState() detects worker A, case sensitive', async t => {
  await navigator.serviceWorker.register('/Worker-A.js');

  const manager = LocalHelpers.getServiceWorkerManager();
  t.is(await manager.getActiveState(), ServiceWorkerActiveState.WorkerA);
});
开发者ID:OneSignal,项目名称:OneSignal-Website-SDK,代码行数:31,代码来源:ServiceWorkerManager.ts

示例6:

import sinon from 'sinon';
import SubscriptionHelper from '../../../src/helpers/SubscriptionHelper';
import { SubscriptionManager } from '../../../src/managers/SubscriptionManager';
import { SessionManager } from '../../../src/managers/SessionManager';

const sinonSandbox = sinon.sandbox.create();

test.beforeEach(async () => {
  await TestEnvironment.initialize({
    httpOrHttps: HttpHttpsEnvironment.Https
  });
  TestEnvironment.mockInternalOneSignal();
});

test.afterEach(() => {
  sinonSandbox.restore();
})

test('should not resubscribe user on subsequent page views if the user is already subscribed', async t => {
  sinonSandbox.stub(OneSignal, 'privateIsPushNotificationsEnabled').resolves(true);
  sinonSandbox.stub(SessionManager.prototype, 'getPageViewCount').returns(2);
  const subscribeSpy = sinonSandbox.spy(SubscriptionManager.prototype, 'subscribe');

  await SubscriptionHelper.registerForPush();
  t.true(subscribeSpy.notCalled);
});

test('should subscribe user on subsequent page views if the user is not subscribed', async t => {
  sinonSandbox.stub(OneSignal, 'isPushNotificationsEnabled').resolves(false);
  sinonSandbox.stub(SessionManager.prototype, 'getPageViewCount').returns(2);
  sinonSandbox.stub(SubscriptionManager.prototype, 'registerSubscription').resolves();
开发者ID:OneSignal,项目名称:OneSignal-Website-SDK,代码行数:31,代码来源:subscriptionHelper.ts

示例7: Application

let pathToApp = `../../../../src/evetron/bin/${(process.platform === 'darwin'
    ? 'Electron.app/Contents/MacOS/'
    : '')}electron${(process.platform === 'win32'
        ? '.exe'
        : '')}`;

ava.beforeEach((test: any) => {
    test.context.app = new Application({
        path: pathToApp,
    });

    return test.context.app.start();
});

ava.afterEach((test: any) => {
    return test.context.app.stop();
});

ava((test: any) => {
    return test.context.app.client.waitUntilWindowLoaded()
        .getWindowCount().then((count: number) => {
            test.is(count, 1);
        }).browserWindow.isMinimized().then((min: boolean) => {
            test.false(min);
        }).browserWindow.isDevToolsOpened().then((opened: boolean) => {
            test.false(opened);
        }).browserWindow.isVisible().then((visible: boolean) => {
            test.true(visible);
        }).browserWindow.getBounds().then((bounds: any) => {
            test.true(bounds.width > 0);
            test.true(bounds.height > 0);
开发者ID:JimiC,项目名称:evetron,代码行数:31,代码来源:main.ts

示例8: TestOut

import { Config } from '../src/utils/config'
import TestOut from './helpers/test_out'
import { graphcoolProjectFileName } from '../src/utils/constants'
import { testEnvironment } from './helpers/test_environment'
import { mockProjectFile1, mockProjectFileWithUppercaseAlias1 } from './fixtures/mock_data'
import { readProjectIdFromProjectFile } from '../src/utils/file'

/*
 Tests:
 - readProjectIdFromProjectFile with a file containing a project id
 - readProjectIdFromProjectFile with a file containing a project alias
 - readProjectIdFromProjectFile with a file missing a project id
 */

test.afterEach(() => {
  new TestOut().write('\n')
})

test('readProjectIdFromProjectFile with a file containing a project id', async t => {
  const env = testEnvironment({})
  env.resolver.write(graphcoolProjectFileName, mockProjectFile1)

  const project_id = readProjectIdFromProjectFile(env.resolver, graphcoolProjectFileName)

  t.is(project_id, 'abcdefghijklmn')
})

test('readProjectIdFromProjectFile with a file containing a project alias', async t => {
  const env = testEnvironment({})
  env.resolver.write(graphcoolProjectFileName, mockProjectFileWithUppercaseAlias1)
开发者ID:sadeeqaji,项目名称:graphcool-cli,代码行数:30,代码来源:utils_file.test.ts

示例9: catch

import test from 'ava';
import * as moment from 'moment';
import { MongoClient, ObjectId } from 'mongodb';
import { promise as sleep } from 'es6-sleep';
import { MongoCron } from '..';

test.beforeEach(async (t) => {
  t.context.mongo = await MongoClient.connect('mongodb://localhost:27017', { useNewUrlParser: true });
  t.context.db = t.context.mongo.db('test');
  t.context.collection = t.context.db.collection('jobs');
  try { await t.context.collection.drop(); } catch (e) {}
});

test.afterEach(async (t) => {
  await t.context.mongo.close();
});

test.serial('document with `sleepUntil` should be processed', async (t) => {
  let times = 0;
  const c = new MongoCron({
    collection: t.context.collection,
    lockDuration: 0,
    onDocument: () => times++,
  });
  await t.context.collection.insertMany([
    { sleepUntil: new Date() },
    { sleepUntil: new Date() },
    { sleepUntil: null },
    { sleepUntil: new Date() },
  ]);
  await c.start();
开发者ID:xpepermint,项目名称:mongodb-cron,代码行数:31,代码来源:cron.test.ts

示例10:

import { OneSignalUtils } from '../../../src/utils/OneSignalUtils';

let sinonSandbox: SinonSandbox;

test.beforeEach(async () => {
  sinonSandbox = sinon.sandbox.create();
  await TestEnvironment.initialize({
    httpOrHttps: HttpHttpsEnvironment.Https
  });

  // Required for sessionContext, not async
  TestEnvironment.mockInternalOneSignal();
});

test.afterEach(function (_t: TestContext) {
  sinonSandbox.restore();
});

test("getCurrentNotificationType for default permission", async t => {
  sinonSandbox.stub(OneSignal.context.permissionManager, "getNotificationPermission")
    .resolves(NotificationPermission.Default);
    
  t.is(await MainHelper.getCurrentNotificationType(), SubscriptionStateKind.Default);
});

test("getCurrentNotificationType for denied permission in HTTP context", async t => {
  sinonSandbox.stub(OneSignal.context.permissionManager, "getNotificationPermission")
    .resolves(NotificationPermission.Denied);
  sinonSandbox.stub(OneSignalUtils, "isUsingSubscriptionWorkaround").returns(true);

  t.is(await MainHelper.getCurrentNotificationType(), SubscriptionStateKind.Default);
开发者ID:OneSignal,项目名称:OneSignal-Website-SDK,代码行数:31,代码来源:MainHelper.ts

示例11: InitTestHelper

import { UpdateManager } from '../../../src/managers/UpdateManager';
import PermissionManager from '../../../src/managers/PermissionManager';

const sinonSandbox: SinonSandbox = sinon.sandbox.create();
const initTestHelper = new InitTestHelper(sinonSandbox);
const playerId = Random.getRandomUuid();
const appId = Random.getRandomUuid();

test.beforeEach(function () {
  mockWebPushAnalytics();
});

test.afterEach(function (_t: TestContext) {
  sinonSandbox.restore();

  OneSignal._initCalled = false;
  OneSignal.__initAlreadyCalled = false;
  OneSignal._sessionInitAlreadyRunning = false;
});

/**
 * HTTP/HTTPS
 * 1. user not subscribed and not opted out
 *    1. first page view
 *     + 1. autoPrompt -> click allow -> player create
 *     + 2. autoPrompt -> click dismiss -> no requests
 *     + 3. autoResubscribe and permissions granted -> player create
 *     + 4. autoResubscribe and permissions default or blocked -> no requests
 *     + 5. no autoResubscribe and no autoPrompt -> no requests
 *    2. second page view - TODO
 * 2. user opted out
开发者ID:OneSignal,项目名称:OneSignal-Website-SDK,代码行数:31,代码来源:onSession.ts

示例12: cb

test.before(t => {
  sinon.stub(inquirer, 'prompt', (q, cb) => {
    const obj = {};
    q.forEach(q => obj[q.name] = true);
    cb(obj);
  });
});

test.beforeEach(t => {
  t.context.log = console.log; 
  console.log = sinon.spy();
});

test.afterEach(t => {
  console.log = t.context.log;
});

test(`Should filter field props out of table.`, t => {
  const res = Migration.filterFields({
    app: 'myApp',
    tableName: 'myApp_foo',
    name: 'foo',
    fields: [
      { name: 'bar' },
      { name: 'baz' }
    ]
  })
  t.same(res, {
    app: 'myApp',
    tableName: 'myApp_foo',
开发者ID:gitter-badger,项目名称:overland,代码行数:30,代码来源:migration.ts

示例13: async

import InitHelper from "../../../src/helpers/InitHelper";
import OneSignalUtils from "../../../src/utils/OneSignalUtils";
import { TestEnvironment, BrowserUserAgent } from '../../support/sdk/TestEnvironment';
import { setBrowser } from '../../support/tester/browser';
import { stubMessageChannel } from '../../support/tester/utils';
import SubscriptionHelper from "../../../src/helpers/SubscriptionHelper";

let sandbox: SinonSandbox = sinon.sandbox.create();

test.beforeEach(async () => {
  await TestEnvironment.initialize();
  TestEnvironment.mockInternalOneSignal();
});

test.afterEach(() => {
  sandbox.restore();
});

/** registerForPushNotifications */
test('registerForPushNotifications: requesting a modal prompt', async (t) => {
  stubMessageChannel(t);

  await InitHelper.registerForPushNotifications({ modalPrompt: true });
  t.not(OneSignal.subscriptionModalHost, undefined);
  t.not(OneSignal.subscriptionModalHost.modal, undefined);
});

test('registerForPushNotifications: load fullscreen popup when using subscription workaround', async (t) => {

  const utilsStub = sandbox.stub(OneSignalUtils, 'isUsingSubscriptionWorkaround').returns(true);
  const loadStub = sandbox.stub(InitHelper, 'loadSubscriptionPopup').resolves();
开发者ID:OneSignal,项目名称:OneSignal-Website-SDK,代码行数:31,代码来源:InitHelper.ts

示例14:

  t.context.expectedSafeHttpOriginsForIrregularSubdomains = [
    'http://dev.www.site.com',
    'https://dev.www.site.com',
  ];

  t.context.expectedSafeHttpOriginsForReallyIrregularSubdomains = [
    'http://dev.www2-6.en.site.com',
    'http://www.dev.www2-6.en.site.com',
    'https://dev.www2-6.en.site.com',
    'https://www.dev.www2-6.en.site.com',
  ];
});

test.afterEach(async t => {
  (global as any).MessageChannel = t.context.originalMessageChannel;
});

/*
  When a developer chooses a site URL to integrate HTTP web push, multiple
  variants of his site origin will support prompting the user to subscribe
  because the final subscription takes place outside of his site origins on our
  subdomain of .os.tc.

  If a developer chooses to integrate HTTP web push on 'http://site.com', for
  example, the prefix variants 'http://', 'http://www.', 'https://', and
  'https://www.' will all support prompting the user. The user will still be
  subscribed on subdomain.os.tc though, and not on any one of the listed
  origins.

  The above changes if the developer chooses to integrate HTTP web push on
开发者ID:OneSignal,项目名称:OneSignal-Website-SDK,代码行数:30,代码来源:postmam.ts

示例15: fixture

const ftest = fixture(ava, 'fixtures/cases')

// ava.before(() => {
//   throw new Error('should not run before')
// })

ava.beforeEach(() => {
  throw new Error('should not run beforeEach')
})

// ava.after(() => {
//   throw new Error('should not run after')
// })

ava.afterEach(() => {
  throw new Error('should not run after each')
})

ava.skip('skip test', _t => {
  throw new Error('should not run ava skip')
})

ftest.skip('case-1', _t => {
  throw new Error('should not run ftest.skip')
})

ftest.skip.each(_t => {
  throw new Error('should not run')
})

ftest.skip.each.failing(_t => {
开发者ID:unional,项目名称:ava-fixture,代码行数:31,代码来源:fixture.skip.spec.ts


注:本文中的ava.afterEach函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。