本文整理汇总了TypeScript中beater.test函数的典型用法代码示例。如果您正苦于以下问题:TypeScript test函数的具体用法?TypeScript test怎么用?TypeScript test使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了test函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
import { Test, run, test } from 'beater';
import assert from 'power-assert';
import {
compileMarkdown,
parse,
parseYaml,
separate
} from '../src/';
const tests1: Test[] = [
test('compileMarkdown', () => {
const markdown = 'This is my first entry.';
const html = compileMarkdown(markdown);
assert(html === '<p>This is my first entry.</p>\n');
}),
test('compileMarkdown with options', () => {
const markdown = 'http://example.com';
const html = compileMarkdown(markdown, { gfm: true });
assert(html === '<p><a href=\"http://example.com\">http://example.com</a></p>\n');
const htmlNoGfm = compileMarkdown(markdown, { gfm: false });
assert(htmlNoGfm === '<p>http://example.com</p>\n');
}),
test('parse', () => {
const yaml = [
'layout: post',
'title: Hello Jekyll'
].map((s) => s + '\n').join('');
const markdown = [
示例2: test
import { Test, test } from 'beater';
import assert from 'power-assert';
import { names } from '../src/names';
const category = '/names ';
const tests: Test[] = [
test(category, () => {
assert.deepEqual(names('/users'), []);
assert.deepEqual(names('/users/{id}'), ['id']);
assert.deepEqual(names('/users/{userId}/posts/{id}'), ['userId', 'id']);
assert.deepEqual(names('/users/{id}/posts/{id}'), ['id']); // remove dups
assert.deepEqual(names('/{x}{y}'), ['x', 'y']); // don't use this behavior
})
];
export { tests };
示例3: test
import { Test, test } from 'beater';
import * as assert from 'power-assert';
import {
formatAtom,
formatDailyJson,
formatMonthlyJson,
formatYearlyJson,
formatSitemap
} from '../src/format';
import { Entry } from '../src/types';
const tests1: Test[] = [
test('format.formatAtom', () => {
// TODO
assert(formatAtom);
}),
test('format.formatDailyJson', () => {
const entry: Entry = {
id: { year: '2006', month: '01', date: '03', title: undefined },
data: 'hello',
date: '2006-01-03', // 2006-01-02T15:04:05-07:00 in +09:00
html: '<p>hello</p>\n',
minutes: 15,
pubdate: '2006-01-02T15:04:05-07:00',
tags: ['misc'],
title: 'title'
};
const json = Object.assign({}, entry);
delete json.id;
示例4: test
import { Test, test } from 'beater';
import path from 'path';
import assert from 'power-assert';
import sinon from 'sinon';
import { Fotolife } from '../src/fotolife';
const category = '/fotolife ';
const tests: Test[] = [
test(category + 'constructor (wsse)', () => {
const fotolife = new Fotolife({
apikey: 'apikey',
username: 'username'
});
assert((fotolife as any)._type === 'wsse');
assert((fotolife as any)._username === 'username');
assert((fotolife as any)._apikey === 'apikey');
}),
test(category + 'constructor (oauth)', () => {
const fotolife = new Fotolife({
accessToken: 'accessToken',
accessTokenSecret: 'accessTokenSecret',
consumerKey: 'consumerKey',
consumerSecret: 'consumerSecret',
type: 'oauth'
});
assert((fotolife as any)._type === 'oauth');
assert((fotolife as any)._accessToken === 'accessToken');
assert((fotolife as any)._accessTokenSecret === 'accessTokenSecret');
assert((fotolife as any)._consumerKey === 'consumerKey');
示例5: UsernameToken
password,
// specify created & nonce
token1: new UsernameToken({ created, nonce, username, password }),
// auto generate created & nonce
token2: new UsernameToken({ username, password }),
// auto generate created & nonce (use smart constructor)
token3: usernameToken({ username, password }),
username
};
};
const tearDown = () => void 0;
const tests: Test[] = [
test(category + '#getCreated', fixture(setUp, tearDown,
({ created, token1, token2, token3 }) => {
assert(token1.getCreated() === created);
assert(token2.getCreated() !== null);
assert(token3.getCreated() !== null);
})),
test(category + '#getNonce', fixture(setUp, tearDown,
({ nonce, token1, token2, token3 }) => {
assert(token1.getNonce() === nonce);
assert(token2.getNonce() !== null);
assert(token3.getNonce() !== null);
})),
test(category + '#getNonceBase64', fixture(setUp, tearDown,
({ nonceBase64, token1, token2, token3 }) => {
assert(token1.getNonceBase64() === nonceBase64);
assert(token2.getNonceBase64() !== null);
assert(token3.getNonceBase64() !== null);
})),
test(category + '#getPassword', fixture(setUp, tearDown,
示例6: test
import { Test, test } from 'beater';
import assert from 'power-assert';
import { params } from '../src/params';
const category = '/params ';
const tests: Test[] = [
test(category + 'template without parameters', () => {
const p = params('/users');
assert.deepEqual(p('/users'), {});
assert.deepEqual(p('/users/'), null);
assert.deepEqual(p('/users/%20'), null);
assert.deepEqual(p('/users/123'), null);
assert.deepEqual(p('/users/abc'), null);
assert.deepEqual(p('/users/123/'), null);
}),
test(category + 'template with parameter', () => {
const p = params('/users/{id}');
assert.deepEqual(p('/users'), null);
assert.deepEqual(p('/users/'), { id: '' });
assert.deepEqual(p('/users/%20'), { id: ' ' });
assert.deepEqual(p('/users/123'), { id: '123' });
assert.deepEqual(p('/users/abc'), { id: 'abc' });
assert.deepEqual(p('/users/123/'), null);
}),
test(category + 'template with strict parameter', () => {
const p = params('/users/{id}', { id: /^\d+$/ });
assert.deepEqual(p('/users'), null);
assert.deepEqual(p('/users/'), null);
assert.deepEqual(p('/users/%20'), null);
示例7: test
import { Test, test } from 'beater';
import assert from 'power-assert';
import { path } from '../src/path';
const category = '/path ';
const tests: Test[] = [
test(category + 'template without parameters', () => {
const p = path('/users');
assert(p({}) === '/users');
}),
test(category + 'template with parameter', () => {
const p = path('/users/{id}');
assert(p({}) === null);
assert(p({ id: '' }) === '/users/');
assert(p({ id: ' ' }) === '/users/%20');
assert(p({ id: '123' }) === '/users/123');
assert(p({ id: 'abc' }) === '/users/abc');
}),
test(category + 'template with strict parameter', () => {
const p = path('/users/{id}', { id: /^\d+$/ });
assert(p({}) === null);
assert(p({ id: '' }) === null);
assert(p({ id: ' ' }) === null);
assert(p({ id: '123' }) === '/users/123');
assert(p({ id: 'abc' }) === null);
}),
test(category + 'template with duplicated parameters', () => {
const p = path('/users/{id}/posts/{id}');
示例8: test
import { Test, run, test } from 'beater';
import assert from 'power-assert';
import bathFn from '../src/';
import * as bath from '../src/';
import { tests as namesTests } from './names';
import { tests as paramsTests } from './params';
import { tests as pathTests } from './path';
const category = '/bath ';
const tests: Test[] = [
test(category + 'bath.names', () => {
const { names } = bath;
assert.deepEqual(names('/users/{id}'), ['id']);
}),
test(category + 'bath.path', () => {
const { path } = bath;
assert.deepEqual(path('/users/{id}')({ id: '123' }), '/users/123');
}),
test(category + 'bath.params', () => {
const { params } = bath;
assert.deepEqual(params('/users/{id}')('/users/123'), { id: '123' });
}),
test(category + 'bath(...).names & bath(...).path & bath(...).params', () => {
const data: Array<[
string,
{ [k: string]: RegExp; } | undefined,
string[],
string | null,
示例9: test
import { Test, test } from 'beater';
import * as assert from 'power-assert';
import * as sinon from 'sinon';
import * as proxyquire from 'proxyquire';
import {
Repository
} from '../src/repository';
const category = '/parse/repository';
const tests1: Test[] = [
test('repository.Repository', () => {
// TODO
assert(Repository);
assert(sinon);
assert(proxyquire);
}),
test(category + 'getEntryIds', () => {
const dir = 'dir1';
const ids = [{ year: '2006', month: '01', date: '02', title: undefined }];
const listEntryIds = sinon.stub().returns(ids);
const parse = sinon.stub();
const repository = new Repository(dir, listEntryIds, parse);
const result = repository.getEntryIds();
assert.deepEqual(result, ids);
assert(listEntryIds.callCount === 1);
assert.deepEqual(listEntryIds.getCall(0).args, [dir]);
assert(parse.callCount === 0);
})
];
示例10: test
import { Test, test } from 'beater';
import * as assert from 'power-assert';
import { compile, compileNew, compileOld } from '../../src/commands/build';
const tests1: Test[] = [
test('compile.compile', () => {
// TODO
assert(compile);
}),
test('compile.compileNew', () => {
assert(compileNew === compile);
}),
test('compile.compileOld', () => {
// TODO
assert(compileOld);
})
];
export { tests1 as tests };