`;
- const expectedMessage = '[#127]';
+ const expectedMessage = '[#125]';
assertThrows(callback, expectedMessage, { startsWith: true });
});
it('throws if a bound defined attribute starts with a number', () => {
const callback = () => html`
`;
- const expectedMessage = '[#127]';
+ const expectedMessage = '[#125]';
assertThrows(callback, expectedMessage, { startsWith: true });
});
it('throws if a bound defined attribute has an uppercase letter', () => {
const callback = () => html`
`;
- const expectedMessage = '[#127]';
+ const expectedMessage = '[#125]';
assertThrows(callback, expectedMessage, { startsWith: true });
});
it('throws if a bound defined attribute ends with a hyphen', () => {
const callback = () => html`
`;
- const expectedMessage = '[#127]';
+ const expectedMessage = '[#125]';
assertThrows(callback, expectedMessage, { startsWith: true });
});
it('throws if a bound defined attribute has a malformed dangling quote', () => {
const callback = () => html`
`;
- const expectedMessage = '[#130]';
+ const expectedMessage = '[#127]';
+ assertThrows(callback, expectedMessage, { startsWith: true });
+ });
+
+ it('throws if a bound defined attribute is at the end of the template', () => {
+ const callback = () => htmlol`
{
const callback = () => html`
`;
- const expectedMessage = '[#128]';
+ const expectedMessage = '[#125]';
assertThrows(callback, expectedMessage, { startsWith: true });
});
it('throws if a bound attribute starts with a number', () => {
const callback = () => html`
`;
- const expectedMessage = '[#128]';
+ const expectedMessage = '[#125]';
assertThrows(callback, expectedMessage, { startsWith: true });
});
it('throws if a bound attribute has an uppercase letter', () => {
const callback = () => html`
`;
- const expectedMessage = '[#128]';
+ const expectedMessage = '[#125]';
assertThrows(callback, expectedMessage, { startsWith: true });
});
it('throws if a bound attribute ends with a hyphen', () => {
const callback = () => html`
`;
- const expectedMessage = '[#128]';
+ const expectedMessage = '[#125]';
assertThrows(callback, expectedMessage, { startsWith: true });
});
it('throws if a bound attribute has a malformed dangling quote', () => {
const callback = () => html`
`;
- const expectedMessage = '[#130]';
+ const expectedMessage = '[#127]';
+ assertThrows(callback, expectedMessage, { startsWith: true });
+ });
+
+ it('throws if a bound attribute is at the end of the template', () => {
+ const callback = () => htmlol`
`;
- const expectedMessage = '[#105]';
+ const expectedMessage = '[#104]';
assertThrows(callback, expectedMessage, { startsWith: true });
});
it('throws if a bound property starts with an underscore', () => {
const callback = () => html`
`;
- const expectedMessage = '[#129]';
+ const expectedMessage = '[#126]';
assertThrows(callback, expectedMessage, { startsWith: true });
});
it('throws if a bound property starts with a number', () => {
const callback = () => html`
`;
- const expectedMessage = '[#129]';
+ const expectedMessage = '[#126]';
assertThrows(callback, expectedMessage, { startsWith: true });
});
it('throws if a bound property starts with a capital letter', () => {
const callback = () => html`
`;
- const expectedMessage = '[#129]';
+ const expectedMessage = '[#126]';
assertThrows(callback, expectedMessage, { startsWith: true });
});
it('throws if a bound property ends with an underscore', () => {
const callback = () => html`
`;
- const expectedMessage = '[#129]';
+ const expectedMessage = '[#126]';
assertThrows(callback, expectedMessage, { startsWith: true });
});
it('throws if a bound property has a malformed dangling quote', () => {
const callback = () => html`
`;
- const expectedMessage = '[#130]';
+ const expectedMessage = '[#127]';
+ assertThrows(callback, expectedMessage, { startsWith: true });
+ });
+
+ it('throws if a bound property is at the end of the template', () => {
+ const callback = () => htmlol`
`;
+ const expectedMessage = '[#156]';
+ assertThrows(callback, expectedMessage, { startsWith: true });
+ });
+});
+
+// Sanity check to make sure we’re able to hit all our errors.
+describe('errors coverage', () => {
+
+ it('throws when initial markup cannot be parsed', () => {
+ const callback = () => htmlol`<`;
+ const expectedMessage = '[#100]';
+ assertThrows(callback, expectedMessage, { startsWith: true });
+ });
+
+ it('throws when markup after text cannot be parsed', () => {
+ const callback = () => htmlol`text<`;
+ const expectedMessage = '[#101]';
+ assertThrows(callback, expectedMessage, { startsWith: true });
+ });
+
+ it('throws when markup after comment cannot be parsed', () => {
+ const callback = () => htmlol`<`;
+ const expectedMessage = '[#102]';
+ assertThrows(callback, expectedMessage, { startsWith: true });
+ });
+
+ it('throws when markup after content interpolation cannot be parsed', () => {
+ const callback = () => htmlol`${VALUE}<`;
+ const expectedMessage = '[#103]';
+ assertThrows(callback, expectedMessage, { startsWith: true });
+ });
+
+ it('throws when markup after start tag space cannot be parsed', () => {
+ const callback = () => htmlol`
`;
+ const expectedMessage = '[#104]';
+ assertThrows(callback, expectedMessage, { startsWith: true });
+ });
+
+ it('throws when markup after start tag cannot be parsed', () => {
+ const callback = () => htmlol`
<`;
+ const expectedMessage = '[#105]';
+ assertThrows(callback, expectedMessage, { startsWith: true });
+ });
+
+ it('throws when markup after bound boolean cannot be parsed', () => {
+ const callback = () => htmlol`
{
+ const callback = () => htmlol`
{
+ const callback = () => htmlol`
{
+ const callback = () => htmlol`
<`;
+ const expectedMessage = '[#110]';
+ assertThrows(callback, expectedMessage, { startsWith: true });
+ });
+
+ //////////////////////////////////////////////////////////////////////////////
+
+ it('throws when start tag is invalid', () => {
+ const callback = () => htmlol`
`;
+ const expectedMessage = '[#120]';
+ assertThrows(callback, expectedMessage, { startsWith: true });
+ });
+
+ it('throws when start tag space is invalid', () => {
+ // There is a literal tab character here.
+ const callback = () => htmlol`
`;
+ const expectedMessage = '[#121]';
+ assertThrows(callback, expectedMessage, { startsWith: true });
+ });
+
+ it('throws when start tag close is invalid', () => {
+ const callback = () => htmlol`
`;
+ const expectedMessage = '[#122]';
+ assertThrows(callback, expectedMessage, { startsWith: true });
+ });
+
+ it('throws when end tag is invalid', () => {
+ const callback = () => htmlol`
div>`;
+ const expectedMessage = '[#123]';
+ assertThrows(callback, expectedMessage, { startsWith: true });
+ });
+
+ it('throws when attribute name is invalid', () => {
+ const callback = () => htmlol`
`;
+ const expectedMessage = '[#124]';
+ assertThrows(callback, expectedMessage, { startsWith: true });
+ });
+
+ it('throws when bound attribute name is invalid', () => {
+ const callback = () => htmlol`
`;
+ const expectedMessage = '[#125]';
+ assertThrows(callback, expectedMessage, { startsWith: true });
+ });
+
+ it('throws when bound property name is invalid', () => {
+ const callback = () => htmlol`
`;
+ const expectedMessage = '[#126]';
+ assertThrows(callback, expectedMessage, { startsWith: true });
+ });
+
+ it('throws when bound closing quote is invalid', () => {
+ const callback = () => htmlol`
{
describe('html error formatting', () => {
it('single line template', () => {
const callback = () => html`
Gotta double-quote those.
`;
- const expectedMessage = '[#128] Invalid tag attribute interpolation (must use kebab-case names and double-quoted values).\nSee substring `not-ok=`.\nYour HTML was parsed through: `
{
const callback = () => html`
Gotta double-quote those.
`;
- const expectedMessage = '[#128] Invalid tag attribute interpolation (must use kebab-case names and double-quoted values).\nSee substring `not-ok=\'`.\nYour HTML was parsed through: `\n
{
Gotta double-quote those.
`;
- const expectedMessage = '[#129] Invalid tag property interpolation (must use kebab-case names and double-quoted values).\nSee substring `.notOk=`.\nYour HTML was parsed through: `\n \n \n
” or “->” characters, they cannot include a set of “--” characters, and they cannot end with a “-” character." | "Unsupported native tag - supported native tags are listed here: https://github.com/Netflix/x-element/blob/main/doc/TEMPLATES.md#supported-native-tags." | "Invalid closing tag (all non-void start tags much have matching end tags)." | "Unsupported