本文整理汇总了TypeScript中ava.test类的典型用法代码示例。如果您正苦于以下问题:TypeScript test类的具体用法?TypeScript test怎么用?TypeScript test使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了test类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: require
many: '{host} has some {candidate} and she\'s ecstatic.'
},
other: {
zero: '{host} have no {candidate} and they are sad.',
'1': '{host} have one {candidate} and they are excited.',
many: '{host} have some {candidate} and they are ecstatic.'
}
},
upperGreet: 'Hello {name:format:uppercase}',
lowerGreet: 'Hello {name:format:lowercase}',
titleGreet: 'Hello {name:format:title}',
denormCap: 'Hello {name:format:denormalize,uppercase}'
};
test.before(() => {
global.Intl = require('intl');
});
test.beforeEach(t => {
t.context.chomsky = new Chomsky();
t.context.chomsky.dictionaryManager.add('fr', FR_TRANSLATIONS);
t.context.chomsky.dictionaryManager.add('en', US_TRANSLATIONS);
sinon.stub(t.context.chomsky, 'getTranslations', () => { return Observable.of({ KEY: 'value' }); });
sinon.stub(t.context.chomsky.loader, 'load', () => { return Observable.of({ KEY: 'value' }); });
});
// setLocation(location)
test('setLocation should set the location', t => {
t.context.chomsky.setLocation('LOCATION');
t.is(t.context.chomsky.location, 'LOCATION');
开发者ID:bullhorn,项目名称:chomsky,代码行数:31,代码来源:chomsky.spec.ts
示例2: BudgetContext
import * as ava from "ava";
import * as moment from "moment";
import BudgetContext from "../client/data/budgetcontext";
import Expense from "../client/expenses/expense";
import * as it from "../client/rates/intervaltype";
import Rate from "../client/rates/rate";
import {ExpenseDataSource, ExpenseController} from "../client/expenses/expensecontroller";
ava.test.beforeEach(t => {
t.context.budgetContext = new BudgetContext();
});
ava.test("update", t => {
let bc = t.context.budgetContext;
let date = moment([2016, 0, 5]);
let controller = new ExpenseController(bc, date);
t.is(controller.vm.list().length, 0);
bc.addExpense(new Expense("test", date, -25));
t.is(controller.vm.list().length, 1);
t.is(controller.vm.list()[0].id(), 1);
t.is(controller.vm.total(), -25);
controller.vm.remove(1);
t.is(controller.vm.list().length, 0);
});
ava.test("add", t => {
let bc = t.context.budgetContext;
let date = moment([2016, 0, 5]);
let controller = new ExpenseController(bc, date);
开发者ID:AlexanderLindsay,项目名称:dailybudgeteer,代码行数:31,代码来源:testExpenseController.ts
示例3: express
import { json } from 'body-parser';
import AppVeyorClient from '../lib/appveyor';
test.cb('appveyor > get', t => {
const expectedResponse = {data: 'something'};
const server = express();
server.get('/data', (req, res) => {
res.send(JSON.stringify(expectedResponse));
});
server.listen(3000, () => {
const appVeyorClient = new AppVeyorClient("my token");
appVeyorClient.hostname = 'localhost';
appVeyorClient.port = 3000;
appVeyorClient.protocol = 'http:';
appVeyorClient.get('/data')
.then(res => {
t.is(res.ok, true);
t.is(res.statusCode, 200);
t.deepEqual(res.body, expectedResponse);
t.end();
})
.catch(t.end);
});
});
test.cb('appveyor > post', t => {
const expectedRequest = {input: 'whatever'};
开发者ID:LiberisLabs,项目名称:appveyor-client,代码行数:32,代码来源:appveyor.test.ts
示例4: buildSchema
import * as fs from 'fs'
import * as path from 'path'
import { buildSchema } from 'graphql'
import { TypescriptGenerator } from './typescript-client'
import { test } from 'ava'
const typeDefs = fs.readFileSync(
path.join(__dirname, '../../src/codegen/fixtures/schema.graphql'),
'utf-8',
)
test.only('typescript generator', t => {
const schema = buildSchema(typeDefs)
const generator = new TypescriptGenerator({
schema,
internalTypes: [],
})
const result = generator.render()
t.snapshot(result)
})
开发者ID:dhruvcodeword,项目名称:prisma,代码行数:19,代码来源:typescript-client.test.ts
示例5: Promise
test.cb("it should support dynamic loading", t => {
const events: string[] = []
const User = types.model({
name: types.string,
age: 0
})
const UserByNameReference = types.maybe(
types.reference(User, {
get(identifier /* string */, parent: any /*Store*/) {
return parent.getOrLoadUser(identifier)
},
set(value /* User */) {
return value.name
}
})
)
const Store = types
.model({
users: types.array(User),
selection: UserByNameReference
})
.actions(self => ({
loadUser: flow(function* loadUser(name) {
events.push("loading " + name)
self.users.push({ name } as any)
yield new Promise(resolve => {
setTimeout(resolve, 200)
})
events.push("loaded " + name)
const user = (self.users.find(u => u.name === name).age = name.length * 3) // wonderful!
})
}))
.views(self => ({
// Important: a view so that the reference will automatically react to the reference being changed!
getOrLoadUser(name) {
const user = self.users.find(u => u.name === name) || null
if (!user) {
/*
TODO: this is ugly, but workaround the idea that views should be side effect free.
We need a more elegant solution..
*/
setImmediate(() => self.loadUser(name))
}
return user
}
}))
const s = Store.create({
users: [],
selection: "Mattia"
})
unprotect(s)
t.deepEqual(events, [])
t.is(s.users.length, 0)
t.is(s.selection, null)
when(
() => s.users.length === 1 && s.users[0].age === 18 && s.users[0].name === "Mattia",
() => {
t.is(s.selection, s.users[0])
t.deepEqual(events, ["loading Mattia", "loaded Mattia"])
t.end()
}
)
})
开发者ID:lelandyolo,项目名称:mobx-state-tree,代码行数:69,代码来源:reference-custom.ts
示例6: start
import { test } from "ava"
import { smallScenario, mediumScenario, largeScenario } from "./perf/scenarios"
import { start } from "./perf/timer"
// TODO: Not sure how this should work. This feels super fragile.
const TOO_SLOW_MS = 10000
test.serial("performs well on small scenario", t => {
t.true(smallScenario(10).elapsed < TOO_SLOW_MS)
})
test.serial("performs well on medium scenario", t => {
t.true(mediumScenario(10).elapsed < TOO_SLOW_MS)
})
test.serial("performs well on large scenario", t => {
t.true(largeScenario(10, 0, 0).elapsed < TOO_SLOW_MS)
t.true(largeScenario(10, 10, 0).elapsed < TOO_SLOW_MS)
t.true(largeScenario(10, 0, 10).elapsed < TOO_SLOW_MS)
t.true(largeScenario(10, 10, 10).elapsed < TOO_SLOW_MS)
})
test.cb("timer", t => {
const go = start()
setTimeout(function() {
const lap = go(true)
setTimeout(function() {
const done = go()
t.not(lap, 0)
t.not(done, 0)
t.not(lap, done)
开发者ID:lelandyolo,项目名称:mobx-state-tree,代码行数:31,代码来源:perf.ts
示例7: flow
)
}
test.cb("flow happens in single ticks", t => {
const X = types
.model({
y: 1
})
.actions(self => ({
p: flow(function*() {
self.y++
self.y++
yield delay(1, true, false)
self.y++
self.y++
})
}))
const x = X.create()
const values: number[] = []
reaction(() => x.y, v => values.push(v))
debugger
x.p().then(() => {
t.is(x.y, 5)
t.deepEqual(values, [3, 5])
t.end()
})
})
test.cb("can handle async actions", t => {
testCoffeeTodo(
开发者ID:lelandyolo,项目名称:mobx-state-tree,代码行数:32,代码来源:async.ts
示例8: require
timeLong: '12:00 '
},
'fr-FR': {
short: '04/12/1987 12:00',
medium: '4 déc. 1987 à 12:00',
long: '4 décembre 1987 à 12:00',
dateShort: '04/12/1987',
dateMedium: '4 déc. 1987',
dateLong: '4 décembre 1987',
timeShort: '12:00',
timeLong: '12:00 '
}
};
test.before(() => {
global.Intl = require('intl');
});
test.beforeEach(t => {
t.context.formats = new Formats();
// Provide the DEFAULT overrides
t.context.formats.override(FORMAT_DEFAULTS);
});
// Method Checking
test('should have overrides defined', t => {
t.truthy(t.context.formats.override);
});
test('should have setLocale defined', t => {
开发者ID:bullhorn,项目名称:chomsky,代码行数:31,代码来源:formats.spec.ts
示例9: TestAstServiceParser
import { test } from 'ava';
import { AstServiceParser } from './AstServiceParser';
class TestAstServiceParser extends AstServiceParser {
/*public getInstancePropertyName(): string {
return this._getInstancePropertyName();
}*/
}
const componentFilename: string = 'test.component.ts';
let parser: TestAstServiceParser;
test.beforeEach(() => {
parser = new TestAstServiceParser();
});
test('should extract strings in TranslateService\'s get() method', async t => {
const contents = `
@Component({ })
export class AppComponent {
public constructor(protected _translateService: TranslateService) { }
public test() {
this._translateService.get('Hello World');
}
`;
const keys = parser.extract(contents, componentFilename).keys();
t.deepEqual(keys, ['Hello World']);
});
test('should extract strings in TranslateService\'s instant() method', async t => {
const contents = `
开发者ID:bvkimball,项目名称:linguist,代码行数:31,代码来源:AstServiceParser.spec.ts
示例10: constructor
import { test } from 'ava'
import { DIContainer } from './di'
test.skip('Service Decorator', t => {
//
// @service('testservice')
class TestClass {
constructor(protected test1: string, test2: boolean, test3: number) {}
}
t.pass()
})
test.serial('Singleton', async t => {
let container = new DIContainer()
let cont2 = new DIContainer()
t.not(container, cont2)
container = DIContainer.getContainer()
t.throws(
() => new DIContainer(),
/singleton - please user DIContainer.getContainer()/
)
cont2 = DIContainer.getContainer()
t.is(container, cont2)
cont2.destroy()
})
开发者ID:ha4us,项目名称:ha4us.old,代码行数:30,代码来源:di.spec.ts
注:本文中的ava.test类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论