本文整理汇总了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;未经允许,请勿转载。 |
请发表评论