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


TypeScript ava.default函數代碼示例

本文整理匯總了TypeScript中ava.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了default函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: delete

import "../../support/polyfills/polyfills";
import test from "ava";
import { TestEnvironment, HttpHttpsEnvironment } from "../../support/sdk/TestEnvironment";
import TimedLocalStorage from '../../../src/modules/TimedLocalStorage';
import timemachine from "timemachine";


test("should not throw and return null if LocalStorage is not supported", async t => {
  await TestEnvironment.initialize({
    httpOrHttps: HttpHttpsEnvironment.Https
  });
  delete (window as any).localStorage;
  t.deepEqual(window.localStorage, undefined);
  const value = TimedLocalStorage.getItem("test");
  t.deepEqual(value, null);
});

test("should set and get item without expiration", async t => {
  await TestEnvironment.initialize({
    httpOrHttps: HttpHttpsEnvironment.Https
  });
  TimedLocalStorage.setItem("my-key", "my-value");
  t.deepEqual(TimedLocalStorage.getItem("my-key"), "my-value");
  timemachine.config({
    timestamp: new Date().getTime() + 1000 * 60 * 60 * 24 * 9999
  });
  t.deepEqual(TimedLocalStorage.getItem("my-key"), "my-value");
  timemachine.reset();
});

test("should set and get complex item without expiration", async t => {
開發者ID:OneSignal,項目名稱:OneSignal-Website-SDK,代碼行數:31,代碼來源:timedLocalStorage.ts

示例2:

import test from 'ava'

import {Pointer} from '../pointer'

const example = {bool: false, arr: [10, 20, 30], obj: {a: 'A', b: 'B'}}

test('Pointer#get bool', t => {
  t.deepEqual(Pointer.fromJSON('/bool').get(example), false, 'should get bool value')
})
test('Pointer#get array', t => {
  t.deepEqual(Pointer.fromJSON('/arr/1').get(example), 20, 'should get array value')
})
test('Pointer#get object', t => {
  t.deepEqual(Pointer.fromJSON('/obj/b').get(example), 'B', 'should get object value')
})

test('Pointer#set bool', t => {
  const input = {bool: true}
  Pointer.fromJSON('/bool').set(input, false)
  t.deepEqual(input.bool, false, 'should set bool value in-place')
})

test('Pointer#set array middle', t => {
  const input: any = {arr: ['10', '20', '30']}
  Pointer.fromJSON('/arr/1').set(input, 0)
  t.deepEqual(input.arr[1], 0, 'should set array value in-place')
})

test('Pointer#set array beyond', t => {
  const input: any = {arr: ['10', '20', '30']}
  Pointer.fromJSON('/arr/3').set(input, 40)
開發者ID:chbrown,項目名稱:rfc6902,代碼行數:31,代碼來源:pointer.ts

示例3:

import test from 'ava';

import index from './index';

test('blob is blob', t => {
  t.is(typeof index, 'function');
})
開發者ID:strangesast,項目名稱:es-git,代碼行數:7,代碼來源:index.test.ts

示例4:

let chunksWithPositionInformation: Chunk[];

test.before(() => {
    orbs  = [ [ 6, 5, 4, 1 ],
              [ 3, 2, 2, 5 ],
              [ 3, 3, 4, 2 ],
              [ 6, 4, 0, 6 ] ];
    chunks = [];
    _.each(walk.entireBoard(orbs), (metadata: Chunk) => {
        chunks.push(metadata.orbs);
    });
    chunksWithPositionInformation = walk.entireBoard(orbs, [4, 2], true);
});

test('has the correct length', t => {
    t.is(chunks.length, 6);
});

test('has the correct chunk size', t => {
    t.deepEqual(_.map(chunks, 'length'), _.fill(Array(6), 2));
});

test('each chunk has the correct slice size', t => {
    let allLengths = _.flatten(_.map(chunks, chunk => _.map(chunk, 'length')));
    t.deepEqual(allLengths, _.fill(Array(12), 4));
});

test('has the correct chunk contents', t => {
    let correctChunks = [
        [
            [6, 5, 4, 1],
開發者ID:PlaytestersKitchen,項目名稱:match-three-js,代碼行數:31,代碼來源:iterchunks.ts

示例5: RegExp

import * as common from "../lib/common";

ava("typeOf", t => {
  const cases = [
    [undefined, common.UNDEFINED_TYPE],
    [null, common.NULL_TYPE],
    [true, common.BOOLEAN_TYPE],
    [false, common.BOOLEAN_TYPE],
    [0, common.NUMBER_TYPE],
    [1, common.NUMBER_TYPE],
    [-1, common.NUMBER_TYPE],
    [0.0, common.NUMBER_TYPE],
    [1.0, common.NUMBER_TYPE],
    [1.1, common.NUMBER_TYPE],
    [-1.0, common.NUMBER_TYPE],
    [-1.1, common.NUMBER_TYPE],
    ["", common.STRING_TYPE],
    ["TEST", common.STRING_TYPE],
    [[], common.ARRAY_TYPE],
    [[1, 2, 3], common.ARRAY_TYPE],
    [{}, common.OBJECT_TYPE],
    [{ test: 1 }, common.OBJECT_TYPE],
    [/[^A-Za-z0-9_]/g, common.REGEXP_TYPE],
    [new RegExp("//"), common.REGEXP_TYPE],
    [new Date(), common.DATE_TYPE]
  ];
  t.plan(cases.length);
  for (const c of cases) t.is(common.typeOf(c[0]), c[1]);
});

ava("generateDeviceId", t => {
開發者ID:zaidka,項目名稱:genieacs,代碼行數:31,代碼來源:common.ts

示例6: require

import test from 'ava'

import Redux = require('redux')
import { makeLocalReducer, makeRootReducer, makeRootCursor } from '../src/index'

test('should complain if a local action given to global dispatch', t => {
    const reducer = makeLocalReducer('foo', {})
    const action = reducer.action('action', () => ({}))
    const cursor = makeRootCursor(Redux.createStore(makeRootReducer(reducer)), reducer)
    t.throws(() => {
        cursor.globalDispatch(action())
    })
})

test('should complain if a global action given to local dispatch', t => {
    const reducer = makeLocalReducer('foo', {})
    const cursor = makeRootCursor(Redux.createStore(makeRootReducer(reducer)), reducer)
    t.throws(() => {
        cursor.dispatch({ type: 'something' } as any)
    })
})

test('should complain if an action from another reducer tree is given', t => {
    const reducer1 = makeLocalReducer('reducer1', {})
    const reducer2 = makeLocalReducer('reducer2', {})
    const action = reducer1.action('action', () => ({}))
    const cursor = makeRootCursor(Redux.createStore(makeRootReducer(reducer1)), reducer2)
    t.throws(() => {
        cursor.dispatch(action())
    })
})
開發者ID:Dashlane,項目名稱:redux-cursor,代碼行數:31,代碼來源:wrong-action-dispatch.ts

示例7: 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

示例8:

import test from 'ava';
import * as coveoanalytics from '../src/index';

test('coverage', t => {
    const _ = coveoanalytics;
});
開發者ID:coveo,項目名稱:coveo.analytics.js,代碼行數:6,代碼來源:coverage_check_test.ts

示例9: require

import race = require('.')
import test from 'ava'

test(async t => {
  let p = race(
    [40, 90],
    x => new Promise(resolve => setTimeout(() => resolve(x)))
  )
  t.is(await p, 40)
})
開發者ID:seangenabe,項目名稱:starry,代碼行數:10,代碼來源:test.ts

示例10: toUint8Array

import test from 'ava';
import * as fs from 'fs';

import DigestableAsyncBuffer from './DigestableAsyncBuffer';

test('digest async buffer', async t => {
  const pack = fs.readFileSync(__dirname + '/../samples/sample2.pack');
  const buffer = new DigestableAsyncBuffer(gen(toUint8Array(pack)));
  const length = 277;
  await buffer.nextInt32();
  await buffer.nextInt32();
  await buffer.nextInt32();
  await buffer.next();
  await buffer.next();
  await buffer.next(159);
  await buffer.next();
  await buffer.next(22);
  await buffer.next();
  await buffer.next();
  await buffer.next(length - buffer.pos);
  t.is(buffer.digest(), '39f21cd1d568778a963bbbe0040445c627ed52cd');
});

async function* gen<T>(item : T) : AsyncIterableIterator<T> {
  yield item;
}

function toUint8Array(value : Buffer){
  return new Uint8Array(value.buffer.slice(value.byteOffset, value.byteOffset + value.byteLength));
}
開發者ID:strangesast,項目名稱:es-git,代碼行數:30,代碼來源:DigestableAsyncBuffer.test.ts


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