本文整理汇总了TypeScript中lodash.property函数的典型用法代码示例。如果您正苦于以下问题:TypeScript property函数的具体用法?TypeScript property怎么用?TypeScript property使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了property函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: it
it('has the appropriate DOM structure', function() {
var labelText = dropdownButton.querySelector('button').textContent;
assert.equal(labelText, 'adaugă persoană', 'has the appropriate label');
actionButtons = _.toArray(dropdownButton.querySelectorAll('option-list>button'));
var actionButtonLablels = actionButtons.map(_.property('textContent'));
assert.deepEqual(actionButtonLablels, ['debitor', 'persoană terţă'], 'options have the appropriate labels');
});
开发者ID:gurdiga,项目名称:xo,代码行数:8,代码来源:NewCaseDialogTest.ts
示例2: it
it('has the appropriate DOM structure', function() {
assert.equal(domElement.tagName, 'DROPDOWN-BUTTON', 'is implemented with a DropdownButton');
var toggleButton = domElement.firstChild;
assert.equal(toggleButton.textContent, 'adaugă acţiune', 'has the appropriate label');
assert.equal(optionButtons.length, activities.length, 'has one option button for every activity');
var optionButtonLabels = optionButtons.map(_.property('textContent'));
assert.deepEqual(optionButtonLabels, ['Intentarea'], 'has the action descriptions as labels for action buttons');
});
开发者ID:gurdiga,项目名称:xo,代码行数:10,代码来源:AddActivityButtonTest.ts
示例3: it
it('creates TodoItem widgets for each item in the given array', function() {
var todoItemData = [{
id: 'first-item',
label: 'the first new item'
}, {
id: 'second-item',
label: 'the second new item'
}];
todoList.setData(todoItemData);
var itemElements = _.toArray(domElement.querySelectorAll('ul>li>labeled-checkbox input[type="checkbox"]'));
assert.equal(itemElements.length, todoItemData.length, 'renders items as <li>s');
var itemLabels = _.toArray(domElement.querySelectorAll('ul>li>labeled-checkbox'));
var itemLabelTexts = itemLabels.map(_.property('textContent'));
var expectedItemLabels = todoItemData.map(_.property('label'));
assert.deepEqual(itemLabelTexts, expectedItemLabels, 'items have the appropriate label texts');
});
开发者ID:gurdiga,项目名称:xo,代码行数:19,代码来源:TodoListTest.ts
示例4: it
it('has the appropriate options', function() {
var optionList = domElement.querySelector('option-list');
var expectedOptionLabels = Object.keys(options);
var expectedOptionCount = expectedOptionLabels.length;
var optionButtons = optionList.querySelectorAll('button');
assert.equal(optionButtons.length, expectedOptionCount, 'has the appropriate number of options');
var optionButtonLabels = _.map(optionButtons, _.property('textContent'));
assert.deepEqual(optionButtonLabels, expectedOptionLabels, 'options have the appropriate labels');
});
开发者ID:gurdiga,项目名称:xo,代码行数:11,代码来源:DropdownButtonTest.ts
示例5: it
it('properly normalizes a nested array with IDs', () => {
const fragment = `
fragment Item on ItemType {
id,
stringField,
numberField,
nullField,
nestedArray {
id,
stringField,
numberField,
nullField
}
}
`;
const result = {
id: 'abcd',
stringField: 'This is a string!',
numberField: 5,
nullField: null,
nestedArray: [
{
id: 'abcde',
stringField: 'This is a string too!',
numberField: 6,
nullField: null,
},
{
id: 'abcdef',
stringField: 'This is a string also!',
numberField: 7,
nullField: null,
},
],
};
assert.deepEqual(writeFragmentToStore({
fragment,
result: _.cloneDeep(result),
dataIdFromObject: getIdField,
}), {
[result.id]: _.assign({}, _.assign({}, _.omit(result, 'nestedArray')), {
nestedArray: result.nestedArray.map(_.property('id')),
}),
[result.nestedArray[0].id]: result.nestedArray[0],
[result.nestedArray[1].id]: result.nestedArray[1],
});
});
开发者ID:WilliamHolmes,项目名称:apollo-client,代码行数:49,代码来源:writeToStore.ts
示例6: it
it('accepts to reset its options', function() {
var handlerA = createSpy();
var handlerB = createSpy();
var newOptions = {
'labelA': handlerA,
'labelB': handlerB
};
optionList.setOptions(newOptions);
var optionLabels = _.toArray(domElement.children).map(_.property('textContent'));
assert.deepEqual(optionLabels, Object.keys(newOptions), 'option buttons have the expected labels');
var optionA = domElement.children[0];
optionA.click();
optionA.click();
assert.deepEqual(handlerA.calls.length, 2, 'clicking on an option calls its corresponding handler');
});
开发者ID:gurdiga,项目名称:xo,代码行数:18,代码来源:OptionListTest.ts
示例7: it
it('has the button to add activities', function() {
var addActivityButton = domElement.querySelector('dropdown-button');
var activityListContainer = addActivityButton.previousSibling;
assert.equal(activityListContainer.getAttribute('name'), 'activity-list-container',
'activity list container is marked as such for inspectability');
var toggleButton = addActivityButton.querySelector('button:first-child');
assert.equal(toggleButton.textContent, 'adaugă acţiune', 'has the appropriate label');
var options = _.toArray(addActivityButton.querySelectorAll('option-list>button'));
assert.equal(options.length, 2, 'has the appropriate number of options');
var optionsLabels = options.map(_.property('textContent'));
assert.deepEqual(optionsLabels, ['Intentarea', 'Refuz'], 'options have the appropriate labels');
assert.equal(activityListContainer.children.length, 0, 'activity list is initially empty');
options[0].click();
assert.equal(activityListContainer.children.length, 1, 'adds one activity');
assert.equal(activityListContainer.children[0].getAttribute('widget-name'),
'InstitutionActivity', 'the added activity is an InstitutionActivity');
});
开发者ID:gurdiga,项目名称:xo,代码行数:22,代码来源:ActivitiesSectionTest.ts
示例8: it
it('value', () => {
let f = _.property('name');
expect(f({ name: 'Alex' })).toEqual('Alex');
});
开发者ID:richie5um,项目名称:TESTLodash,代码行数:4,代码来源:index.spec.ts
示例9: getSongInfo
async function getSongInfo(
files: IndexingInputFile[],
options?: {
cache?: {
get(md5: string): OutputFileInfo
put(md5: string, info: OutputFileInfo): void
}
extra?: any
onProgress?: any
onError?: (error: Error, name: string) => void
getFileInfo?: typeof getFileInfo
}
): Promise<OutputSongInfo> {
options = options || {}
var warnings: string[] = []
var cache = options.cache || undefined
var extra = options.extra || {}
var report = options.onProgress || function() {}
var onError =
options.onError ||
function(e, name) {
if (global.console && console.error) {
console.error('Error while parsing ' + name, e)
}
}
var processed = 0
var doGetFileInfo = options.getFileInfo || getFileInfo
const results: OutputChart[][] = await Bluebird.map(
files,
async function(file): Promise<OutputChart[]> {
var name = file.name
var fileData = file.data
var hash = createHash('md5')
hash.update(fileData)
var md5Hash = hash.digest('hex')
try {
const cached = await Promise.resolve(cache && cache.get(md5Hash))
if (cached) {
return [{ ...cached, file: name }]
} else {
var meta = { name: name, md5: md5Hash }
const info = await Promise.resolve(doGetFileInfo(fileData, meta))
if (cache) cache.put(md5Hash, info)
return [{ ...info, file: name }]
}
} catch (e) {
onError(e, name)
warnings.push('Unable to parse ' + name + ': ' + e)
return []
} finally {
processed += 1
report(processed, files.length, name)
}
},
{ concurrency: 2 }
)
const charts = _.flatten(results)
if (charts.length === 0) {
warnings.push('No usable charts found!')
}
var song: Partial<OutputSongInfo> = {
title: common(charts, _.property('info.title')),
artist: common(charts, _.property('info.artist')),
genre: common(charts, _.property('info.genre')),
bpm: median(charts, _.property('bpm.median')),
}
assign(song, getSongVideoFromCharts(charts))
assign(song, extra)
song.charts = charts
song.warnings = warnings
return song as OutputSongInfo
}
开发者ID:bemusic,项目名称:bemuse,代码行数:72,代码来源:index.ts
注:本文中的lodash.property函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论