本文整理汇总了TypeScript中@ephox/agar.Assertions.assertStructure方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Assertions.assertStructure方法的具体用法?TypeScript Assertions.assertStructure怎么用?TypeScript Assertions.assertStructure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/agar.Assertions
的用法示例。
在下文中一共展示了Assertions.assertStructure方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getSkinCssFilenames
const mAssertEditors = Step.label('mAssertEditors', Step.stateful(function (editors: any[], next, die) {
Assertions.assertHtml('Editor contents should be the first div content', '<p>a</p>', editors[0].getContent());
Assertions.assertHtml('Editor contents should be the second div content', '<p>b</p>', editors[1].getContent());
console.log('Editor container 0:', editors[0].editorContainer);
const containerApproxStructure = ApproxStructure.build((s, str, arr) => {
return s.element('div', {
classes: [ arr.has('tox'), arr.has('tox-tinymce'), arr.has('tox-tinymce-inline') ],
children: [
s.element('div', {
classes: [ arr.has('tox-editor-container') ],
children: [
s.element('div', {
classes: [ arr.has('tox-menubar') ],
attrs: {
role: str.is('menubar'),
},
}),
s.element('div', {
classes: [ arr.has('tox-toolbar') ],
attrs: {
role: str.is('group'),
},
}),
s.element('div', {
classes: [ arr.has('tox-anchorbar') ]
})
]
}),
s.element('div', {
classes: [ arr.has('tox-throbber') ]
})
]
});
});
Assertions.assertStructure('Editor container should match expected structure', containerApproxStructure, Element.fromDom(editors[0].editorContainer));
Assertions.assertStructure('Editor container should match expected structure', containerApproxStructure, Element.fromDom(editors[1].editorContainer));
Assertions.assertEq(
'Should only be two skin files the skin and the content for inline mode',
['skin.min.css', 'content.inline.min.css'],
getSkinCssFilenames()
);
const targets = Arr.map(editors, function (editor) {
return editor.getElement();
});
Assertions.assertEq('Targets should be two since there are two editors', 2, targets.length);
next(targets);
}));
示例2:
Chain.op((urlinput) => {
Assertions.assertStructure(
'Checking content of url input',
ApproxStructure.build(expected),
urlinput
);
})
示例3:
return Logger.t('Assert HTML structure of the element ' + expected, Step.sync(() => {
const body = editor.getBody();
body.normalize(); // consolidate text nodes
Assertions.assertStructure(
'Asserting HTML structure of the element: ' + selector,
expected,
SelectorFind.descendant(Element.fromDom(body), selector).getOrDie('Nothing in the Editor matches selector: ' + selector)
);
}));
示例4:
return Step.sync(function () {
const rawBody = editor.getBody().cloneNode(true);
rawBody.normalize();
Assertions.assertStructure(
'Asserting the normalized structure of tiny content.',
expected,
Element.fromDom(rawBody)
);
});
示例5:
return Step.sync(function () {
const body = editor.getBody();
body.normalize(); // consolidate text nodes
Assertions.assertStructure(
'Asserting HTML structure of the element: ' + selector,
ApproxStructure.fromHtml(expected),
SelectorFind.descendant(Element.fromDom(body), selector).getOrDie('Nothing in the Editor matches selector: ' + selector)
);
});
示例6:
Chain.op((input) =>
Assertions.assertStructure('should have all attributes', ApproxStructure.build((s, str, arr) => {
return s.element('iframe', {
attrs: {
width: str.is('300'),
height: str.is('150')
},
styles: {
width: str.none('should not have width style'),
height: str.none('should not have height style')
},
});
}), input)
示例7:
}, (rootElement: SugarElement) => {
Assertions.assertStructure('A basic dialog should have these components',
ApproxStructure.build((s, str, arr) => {
return s.element('div', {
classes: [ arr.has('mce-silver-sink') ],
children: [
s.element('div', {
classes: [ arr.has('tox-dialog-wrap') ],
children: [
s.element('div', { classes: [ arr.has('tox-dialog-wrap__backdrop') ] }),
s.element('div', {
classes: [ arr.has('tox-dialog') ],
children: [
s.element('div', {
classes: [ arr.has('tox-dialog__header') ],
children: [
s.element('div', { classes: [ arr.has('tox-dialog__title') ] }),
s.element('div', { classes: [ arr.has('tox-dialog__draghandle') ] }),
s.element('button', { classes: [ arr.has('tox-button') ] })
]
}),
s.element('div', {
classes: [ arr.has('tox-dialog__content-js') ],
children: [
s.element('div', {
classes: [ arr.has('tox-dialog__body') ],
children: [
s.element('div', {
// Potentially reinstate once we have the structure 100% defined.
// attrs: {
// role: str.is('presentation')
// }
})
]
})
]
}),
s.element('div', {
classes: [ arr.has('tox-dialog__footer') ]
})
]
})
]
})
]
});
}),
rootElement
);
});
示例8:
Chain.op((lock) => {
Assertions.assertStructure(
'Checking lock has toggled',
ApproxStructure.build((s, str, arr) => {
return s.element('button', {
classes: [
arr.has('tox-lock'),
arr.has('tox-button'),
(locked ? arr.has : arr.not)('tox-locked')]
});
}),
lock
);
})
示例9:
Arr.each(nodes, (node) => {
Assertions.assertEq('Wrapper must be in content', true, editor.getBody().contains(node));
Assertions.assertStructure(
'Checking wrapper has correct decoration',
ApproxStructure.build((s, str, arr) => {
return s.element('span', {
attrs: {
'data-mce-annotation': str.is(name),
'data-mce-annotation-uid': str.is(uid)
}
});
}),
SugarElement.fromDom(node)
);
});