本文整理汇总了TypeScript中tape.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: test
test('#slugify.config()', tt => {
test('Get config', t => {
slugify.config(defaultOptions);
t.deepEqual(slugify.config(), defaultOptions, 'read current config');
slugify.config(undefined, true);
t.end();
});
test('Generate slugs', t => {
const tests: Array<[string, OptionsSlugify, string]> = [
];
for (const [str, options, slug] of tests) {
slugify.config(options);
t.equal(slugify(str), slug, `${str}-->${slug}`);
}
t.end();
});
tt.end();
});
开发者ID:andyhu,项目名称:node-transliteration,代码行数:20,代码来源:slugify.ts
示例2: testSchemas
//.........这里部分代码省略.........
const token = personObject.toToken(privateKey)
const tokenRecords = [wrapProfileToken(token)]
t.ok(tokenRecords, 'Person profile tokens should have been created')
const profileObject2 = Person.fromToken(tokenRecords[0].token, publicKey)
t.ok(profileObject2, 'Person profile should have been reconstructed from tokens')
const name = personObject.name()
t.ok(name, 'Name should have been returned')
t.equal(name, 'Naval Ravikant', 'Name should match the expected value')
const givenName = personObject.givenName()
t.ok(givenName, 'Given name should have been returned')
t.equal(givenName, 'Naval', 'Given name should match the expected value')
const familyName = personObject.familyName()
t.ok(familyName, 'Family name should have been returned')
t.equal(familyName, 'Ravikant', 'Family name should match the expected value')
const description = personObject.description()
t.ok(description, 'Avatar URL should have been returned')
const avatarUrl = personObject.avatarUrl()
t.ok(avatarUrl, 'Avatar URL should have been returned')
const verifiedAccounts = personObject.verifiedAccounts([])
t.ok(verifiedAccounts, 'Verified accounts should have been returned')
t.equal(verifiedAccounts.length, 0, 'Verified accounts should match the expected value')
const address = personObject.address()
t.ok(address, 'Address should have been returned')
const birthDate = personObject.birthDate()
t.ok(birthDate, 'Birth date should have been returned')
const connections = personObject.connections()
t.ok(connections, 'Connections should have been returned')
const organizations = personObject.organizations()
t.ok(organizations, 'Organizations should have been returned')
})
test('legacyFormat', (t) => {
t.plan(3)
const profileObject = Person.fromLegacyFormat(sampleProfiles.navalLegacy)
t.ok(profileObject, 'Profile object should have been created from legacy formatted profile')
const validationResults = Person.validateSchema(profileObject.toJSON(), true)
t.ok(validationResults, 'Profile should be in a valid format')
t.deepEqual(profileObject.toJSON(),
sampleProfiles.navalLegacyConvert,
'Parsed Legacy profile should match expectations.')
})
test('resolveZoneFileToPerson', (t) => {
t.plan(2)
const zoneFile = '$ORIGIN ryan.id\n$TTL 3600\n_http._tcp IN URI 10 1 "https://blockstack.s3.amazonaws.com/ryan.id"\n'
const ownerAddress = '19MoWG8u88L6t766j7Vne21Mg4wHsCQ7vk'
FetchMock.get(sampleTokenFiles.ryan.url, sampleTokenFiles.ryan.body)
resolveZoneFileToPerson(zoneFile, ownerAddress, (profile) => {
t.ok(profile, 'Profile was extracted')
t.equal(profile.name,
'Ryan Shea', 'The profile was recovered with the expected value of the name field')
})
})
test('profileLookUp', (t) => {
t.plan(4)
const name = 'ryan.id'
const zoneFileLookupURL = 'http://potato:6270/v1/names/'
const mockZonefile = {
zonefile: '$ORIGIN ryan.id\n$TTL 3600\n_http._tcp IN URI 10 1 "https://blockstack.s3.amazonaws.com/ryan.id"\n',
address: '19MoWG8u88L6t766j7Vne21Mg4wHsCQ7vk'
}
FetchMock.restore()
FetchMock.get('http://potato:6270/v1/names/ryan.id', mockZonefile)
FetchMock.get('https://core.blockstack.org/v1/names/ryan.id', mockZonefile)
FetchMock.get(sampleTokenFiles.ryan.url, sampleTokenFiles.ryan.body)
lookupProfile(name, zoneFileLookupURL)
.then((profile) => {
t.ok(profile, 'zonefile resolves to profile with zoneFileLookupUrl specified')
t.equal(profile.name,
'Ryan Shea', 'The profile was recovered with the expected value of the name field')
})
.then(() => lookupProfile(name))
.then((profile) => {
t.ok(profile, 'zonefile resolves to profile with default behavior')
t.equal(profile.name,
'Ryan Shea', 'The profile was recovered with the expected value of the name field')
})
})
}
开发者ID:blockstack,项目名称:blockstack-cli,代码行数:101,代码来源:unitTestsProfiles.ts
示例3: testTokening
function testTokening(filename, profile) {
const privateKey = 'a5c61c6ca7b3e7e55edee68566aeab22e4da26baa285c7bd10e8d2218aa3b229'
const publicKey = '027d28f9951ce46538951e3697c62588a87f1f1f295de4a14fdd4c780fc52cfe69'
let tokenRecords = []
test('profileToToken', (t) => {
t.plan(3)
const token = signProfileToken(profile, privateKey)
t.ok(token, 'Token must have been created')
const tokenRecord = wrapProfileToken(token)
t.ok(tokenRecord, 'Token record must have been created')
const decodedToken = verifyProfileToken(tokenRecord.token, publicKey)
t.ok(decodedToken, 'Token record must have been verified')
})
test('profileToTokens', (t) => {
t.plan(2)
tokenRecords = [wrapProfileToken(signProfileToken(profile, privateKey))]
t.ok(tokenRecords, 'Tokens should have been created')
// console.log(JSON.stringify(tokenRecords, null, 2))
// fs.writeFileSync('./docs/token-files/' + filename, JSON.stringify(tokenRecords, null, 2))
const tokensVerified = true
// this will throw an error if one is involid
tokenRecords.map(tokenRecord => verifyProfileToken(tokenRecord.token, publicKey))
t.equal(tokensVerified, true, 'All tokens should be valid')
})
test('tokenToProfile', (t) => {
t.plan(2)
const recoveredProfile = extractProfile(tokenRecords[0].token, publicKey)
// console.log(recoveredProfile)
t.ok(recoveredProfile, 'Profile should have been reconstructed')
t.equal(JSON.stringify(recoveredProfile),
JSON.stringify(profile), 'Profile should equal the reference')
})
test('makeProfileZoneFile', (t) => {
t.plan(1)
const origin = 'satoshi.id'
const tokenFileUrl = 'https://example.com/satoshi.json'
const expectedZoneFile = '$ORIGIN satoshi.id\n$TTL 3600\n_http._tcp IN URI 10 1 "https://example.com/satoshi.json"\n\n'
const actualZoneFile = makeProfileZoneFile(origin, tokenFileUrl)
t.equal(actualZoneFile, expectedZoneFile)
})
}
开发者ID:blockstack,项目名称:blockstack-cli,代码行数:55,代码来源:unitTestsProfiles.ts
示例4: testZoneFile
function testZoneFile() {
test('makeZoneFileForHostedProfile', (t) => {
t.plan(3)
const fileUrl = 'https://mq9.s3.amazonaws.com/naval.id/profile.json'
const incorrectFileUrl = 'mq9.s3.amazonaws.com/naval.id/profile.json'
const zoneFile = Profile.makeZoneFile('naval.id', fileUrl)
t.ok(zoneFile, 'Zone file should have been created for hosted profile')
t.ok(zoneFile.includes(`"${fileUrl}"`), 'Zone file should include quoted entire profile url')
t.notOk(zoneFile.includes(`"${incorrectFileUrl}"`),
'Zone file should not include quoted profile url without protocol')
})
}
开发者ID:blockstack,项目名称:blockstack-cli,代码行数:13,代码来源:unitTestsProfiles.ts
示例5: testVerifyToken
function testVerifyToken() {
const tokenFile = sampleTokenFiles.ryan_apr20.body
const token = tokenFile[0].token
const publicKey = '02413d7c51118104cfe1b41e540b6c2acaaf91f1e2e22316df7448fb6070d582ec'
const compressedAddress = '1BTku19roxQs2d54kbYKVTv21oBCuHEApF'
const uncompressedAddress = '12wes6TQpDF2j8zqvAbXV9KNCGQVF2y7G5'
test('verifyToken', (t) => {
t.plan(3)
const decodedToken1 = verifyProfileToken(token, publicKey)
t.ok(decodedToken1, 'Token should have been verified against a public key')
const decodedToken2 = verifyProfileToken(token, compressedAddress)
t.ok(decodedToken2, 'Token should have been verified against a compressed address')
const decodedToken3 = verifyProfileToken(token, uncompressedAddress)
t.ok(decodedToken3, 'Token should have been verified against an uncompressed address')
})
}
开发者ID:blockstack,项目名称:blockstack-cli,代码行数:21,代码来源:unitTestsProfiles.ts
示例6:
test("given a group of paths, it groups them in arrays when reducing over them", t => {
const paths = [
"index",
"banana",
"nested/banana",
"nested/apple",
"nested/super nested/thing"
];
const groupedPaths = [
{ type: "file", value: "index" },
{ type: "file", value: "banana" },
{
type: "dir",
name: "nested",
children: [
{ type: "file", value: "nested/banana" },
{ type: "file", value: "nested/apple" },
{
type: "dir",
name: "super nested",
children: [
{
type: "file",
value: "nested/super nested/thing"
}
]
}
]
}
];
t.deepEqual(paths.reduce(group, []), groupedPaths);
t.end();
});
开发者ID:joakin,项目名称:markdown-folder-to-html,代码行数:35,代码来源:group-by-path.ts
示例7: generateIndexInfo
const files = [
"index.md",
"1-banana.md",
"nested/another-banana.md",
"nested/so_apple.md"
];
const grouped = files.reduce(groupByPath, []);
// Generate info with the first file as the current one
const treeInfoFirstIsCurrent = generateIndexInfo(files[0], grouped);
test("current file has active property to true", t => {
const first = treeInfoFirstIsCurrent[0];
t.ok(first.type === "file" && first.value.active);
t.end();
});
test("leaf file has text property that has been parsed", t => {
const second = treeInfoFirstIsCurrent[1];
t.equal(second.type === "file" && second.value.text, "banana");
t.end();
});
test("nested files are kept in a hierarchy", t => {
const third = treeInfoFirstIsCurrent[2];
t.equal(third.type, "dir", "The nested tree is a dir");
t.equal(
third.type === "dir" && third.name,
"nested",
开发者ID:joakin,项目名称:markdown-folder-to-html,代码行数:30,代码来源:generate-index-info.ts
示例8: runTest
test('lambdascript compiler in js', function(t: any) {
function runTest(testFileName: string) {
const testFilePath = path.resolve(__dirname, '..', 'fixtures', testFileName);
logger.info({testFilePath: testFilePath}, 'Running test file');
return q.nfcall(tmp.file.bind(tmp), {postfix: '.js'})
.spread(function(jsOutputFilePath: string) {
logger.info({jsOutputFilePath: jsOutputFilePath, lsc: lsc}, 'Compiling to js output');
return lsc(testFilePath, jsOutputFilePath)
.then(function() {
const command = `node ${jsOutputFilePath}`;
logger.info({command: command}, 'Spawning node on generated js');
return q.nfcall(child_process.exec.bind(child_process), command);
})
.fail(function(err: any) {
logger.error(err, 'lsc failed');
throw err;
});
}).spread(function(stdout: Buffer, stderr: Buffer) {
if (stderr.length) {
throw new Error(stderr.toString());
}
logger.info({stdout: stdout.toString()}, 'Nodejs spawn complete');
return stdout.toString();
});
}
function stringEqual(t: any, str1: string, str2: string, message: string): void {
t.equal(str1, str2, message);
}
t.test('print string', function(t: any) {
t.plan(1);
runTest('print-string.lambda').then(function(stdout: string) {
stringEqual(t, stdout, 'hello-world\n', 'string is printed correctly to standard out');
}).catch(function(err: any) {
t.error(err);
throw err;
});
});
t.test('print empty string', function(t: any) {
t.plan(1);
runTest('print-empty-string.lambda').then(function(stdout: string) {
stringEqual(t, stdout, '\n', 'empty string is printed correctly to standard out');
}).catch(function(err: any) {
t.error(err);
throw err;
});
});
t.test('strings can have spaces', function(t: any) {
t.plan(1);
runTest('strings-have-spaces.lambda').then(function(stdout: string) {
stringEqual(
t, stdout, 'strings can have spaces\n', 'string with spaces is printed correctly to standard out'
);
}).catch(function(err: any) {
t.error(err);
throw err;
});
});
t.test('strings can contain escaped quotes', function(t: any) {
t.plan(1);
runTest('string-containing-quotes.lambda').then(function(stdout: string) {
stringEqual(
t, stdout, 'strings can contain escaped " quotes\n',
'string with spaces is printed correctly to standard out'
);
}).catch(function(err: any) {
t.error(err);
throw err;
});
});
t.test('booleans', function(t: any) {
t.plan(1);
runTest('print-boolean.lambda').then(function(stdout: string) {
stringEqual(
t, stdout, 'true\n',
'boolean expression is evaluated and printed correctly to standard out'
);
}).catch(function(err: any) {
t.error(err);
throw err;
});
});
t.test('regex lookup', function(t: any) {
t.plan(1);
runTest('print-regex-lookup.lambda').then(function(stdout: string) {
stringEqual(
t, stdout, 'aba\n',
'string regex lookup is evaluated and printed correctly to standard out'
);
}).catch(function(err: any) {
//.........这里部分代码省略.........
开发者ID:NickHeiner,项目名称:lambdascript,代码行数:101,代码来源:index.ts
示例9: test
test('#transliterate()', tt => {
test('- Purity tests', t => {
const tests = [];
for (let i = 1; tests.length < 127; tests.push(String.fromCharCode(i++))) {; }
tests.forEach((str) => {
t.equal(tr(str), str, `${str.charCodeAt(0).toString(16)} ${str}`);
});
t.end();
});
test('- Basic string tests', t => {
const tests: Array<string | number> = [
'',
1 / 10,
'I like pie.',
'\n',
'\r\n',
'I like pie.\n',
];
tests.forEach((str) => {
t.equal(tr(str.toString()), str.toString(), str as string);
});
t.end();
});
test('- Complex tests', t => {
const tests: Array<[string, string]> = [
['Æneid', 'AEneid'],
['étude', 'etude'],
['北亰', 'Bei Jing'],
// Chinese
['ᔕᓇᓇ', 'shanana'],
// Canadian syllabics
['ᏔᎵᏆ', 'taliqua'],
// Cherokee
['ܦܛܽܐܺ', 'ptu\'i'],
// Syriac
['अभिजीत', 'abhijiit'],
// Devanagari
['অভিজীত', 'abhijiit'],
// Bengali
['അഭിജീത', 'abhijiit'],
// Malayalaam
['മലയാലമ്', 'mlyaalm'],
// the Malayaalam word for 'Malayaalam'
// Yes, if we were doing it right, that'd be 'malayaalam', not 'mlyaalm'
['げんまい茶', 'genmai Cha'],
// Japanese, astonishingly unmangled.
[`\u0800\u1400${unescape('%uD840%uDD00')}`, ''],
// Unknown characters
];
for (const [str, result] of tests) {
t.equal(tr(str), result, `${str}-->${result}`);
}
t.end();
});
test('- With ignore option', t => {
const tests: Array<[string, string[], string]> = [
['Æneid', ['Æ'], 'Æneid'],
['你好,世界!', [',', '!'], 'Ni Hao, Shi Jie!'],
['你好,世界!', ['你好', '!'], '你好, Shi Jie!'],
];
for (const [str, ignore, result] of tests) {
t.equal(tr(str, { ignore }), result, `${str}-->${result}`);
}
t.end();
});
test('- With replace option', t => {
const tests: Array<[string, string[] | object, string]> = [
['你好,世界!', [['你好', 'Hola']], 'Hola, Shi Jie!'],
['你好,世界!', { '你好': 'Hola' }, 'Hola, Shi Jie!'],
];
for (const [str, replace, result] of tests) {
t.equal(tr(str, { replace: replace as OptionReplaceCombined }), result, `${str}-->${result} with ${typeof replace} option`);
}
t.end();
});
test('- With replaceAfter option', t => {
const tests: Array<[string, string[] | object, string]> = [
['你好,世界!', [['Ni Hao', 'Hola']], 'Hola, Shi Jie!'],
['你好,世界!', { 'Ni Hao': 'Hola' }, 'Hola, Shi Jie!'],
];
for (const [str, replaceAfter, result] of tests) {
t.equal(tr(str, { replaceAfter: replaceAfter as OptionReplaceCombined }), result, `${str}-->${result} with ${typeof replaceAfter} option`);
}
t.end();
});
test('- With replace / replaceAfter and ignore options', t => {
t.equal(tr('你好, 世界!', { replace: [['你好', 'Hola'], ['世界', 'mundo']], ignore: ['¡', '!'] }), 'Hola, mundo!', );
t.equal(tr('你好,世界!', { replaceAfter: [['你', 'tú']], ignore: ['你'] }), 'tú Hao, Shi Jie!', `你好,世界!-->tú Hao, Shi Jie! with 你-->tú replaceAfter option and ignore 你`);
t.end();
});
//.........这里部分代码省略.........
开发者ID:andyhu,项目名称:node-transliteration,代码行数:101,代码来源:transliterate.ts
注:本文中的tape.default函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论