@microsoft/fast-html 1.0.0-alpha.3 → 1.0.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -95,8 +95,21 @@ Template directives include:
95
95
  Example:
96
96
  ```html
97
97
  <f-when value="{{show}}">Hello world</f-when>
98
+ <f-when value="{{!show}}">Goodbye world</f-when>
98
99
  ```
99
100
 
101
+ The following operators can also be used:
102
+ - `==`
103
+ - `!=`
104
+ - `>=`
105
+ - `>`
106
+ - `<=`
107
+ - `<`
108
+ - `||`
109
+ - `&&`
110
+
111
+ Where the right operand can be either a reference to a value (string e.g. `{{foo == 'bar'}}`, boolean e.g. `{{foo == true}}`, number e.g. `{{foo == 3}}`) or another binding value.
112
+
100
113
  - **repeat**
101
114
 
102
115
  Example:
@@ -104,6 +117,13 @@ Template directives include:
104
117
  <ul><f-repeat value="{{item in list}}"><li>{{item}}</li></f-repeat></ul>
105
118
  ```
106
119
 
120
+ Should you need to refer to the parent element (not the individual item in the list), you can use `../`. This will map to what `html` tag template literal uses, `c.parent`.
121
+
122
+ Example:
123
+ ```html
124
+ <ul><f-repeat value="{{item in list}}"><li>{{item}} - {{../title}}</li></f-repeat></ul>
125
+ ```
126
+
107
127
  - **partial & apply**
108
128
 
109
129
  These directives are new to the declarative HTML model and allow for the ability to declare a `partial` directive containing a template partial which can then be referenced by an `apply` directive.
@@ -71,5 +71,32 @@ export declare function getAllPartials(innerHTML: string, offset?: number, parti
71
71
  * @param self - Where the first item in the path path refers to the item itself (used by repeat).
72
72
  * @returns A function to access the value from a given path.
73
73
  */
74
- export declare function pathResolver(path: string, self?: boolean): (accessibleObject: any) => any;
74
+ export declare function pathResolver(path: string, self?: boolean): (accessibleObject: any, context: any) => any;
75
+ /**
76
+ * Available operators include:
77
+ *
78
+ * - access (no operator)
79
+ * - not (!)
80
+ * - equals (==)
81
+ * - not equal (!=)
82
+ * - greater than or equal (>=)
83
+ * - greater than (>)
84
+ * - less than or equal (<=)
85
+ * - less than (<)
86
+ * - or (||)
87
+ * - and (&&) and the HTML character entity (&amp;&amp;)
88
+ */
89
+ type Operator = "access" | "!" | "==" | "!=" | ">=" | ">" | "<=" | "<" | "||" | "&&" | "&amp;&amp;";
90
+ interface OperatorConfig {
91
+ operator: Operator;
92
+ left: string;
93
+ right: string | boolean | number | null;
94
+ rightIsValue: boolean | null;
95
+ }
96
+ /**
97
+ * Get the operator used.
98
+ * @param value the binded value
99
+ * @returns Operator
100
+ */
101
+ export declare function getOperator(value: string): OperatorConfig;
75
102
  export {};
@@ -1,7 +1,7 @@
1
1
  import { __awaiter, __decorate, __metadata } from "tslib";
2
2
  import { attr, FAST, FASTElement, fastElementRegistry, ViewTemplate, } from "@microsoft/fast-element";
3
3
  import { DOMPolicy } from "@microsoft/fast-element/dom-policy.js";
4
- import { getAllPartials, getNextBehavior, pathResolver, } from "./utilities.js";
4
+ import { getAllPartials, getNextBehavior, getOperator, pathResolver, } from "./utilities.js";
5
5
  /**
6
6
  * The <f-template> custom element that will provide view logic to the element
7
7
  */
@@ -72,7 +72,63 @@ class TemplateElement extends FASTElement {
72
72
  {
73
73
  const { strings, values } = yield this.resolveStringsAndValues(innerHTML.slice(behaviorConfig.openingTagEndIndex, behaviorConfig.closingTagStartIndex));
74
74
  const { when } = yield import("@microsoft/fast-element");
75
- externalValues.push(when(x => pathResolver(behaviorConfig.value, self)(x), this.resolveTemplateOrBehavior(strings, values)));
75
+ const { operator, left, right, rightIsValue } = getOperator(behaviorConfig.value);
76
+ let whenLogic = (x, c) => pathResolver(left, self)(x, c);
77
+ switch (operator) {
78
+ case "!":
79
+ whenLogic = (x, c) => !pathResolver(left, self)(x, c);
80
+ break;
81
+ case "==":
82
+ whenLogic = (x, c) => pathResolver(left, self)(x, c) ==
83
+ (rightIsValue
84
+ ? right
85
+ : pathResolver(right, self)(x, c));
86
+ break;
87
+ case "!=":
88
+ whenLogic = (x, c) => pathResolver(left, self)(x, c) !=
89
+ (rightIsValue
90
+ ? right
91
+ : pathResolver(right, self)(x, c));
92
+ break;
93
+ case "&&":
94
+ case "&amp;&amp;":
95
+ whenLogic = (x, c) => pathResolver(left, self)(x, c) &&
96
+ (rightIsValue
97
+ ? right
98
+ : pathResolver(right, self)(x, c));
99
+ break;
100
+ case "||":
101
+ whenLogic = (x, c) => pathResolver(left, self)(x, c) ||
102
+ (rightIsValue
103
+ ? right
104
+ : pathResolver(right, self)(x, c));
105
+ break;
106
+ case ">=":
107
+ whenLogic = (x, c) => pathResolver(left, self)(x, c) >=
108
+ (rightIsValue
109
+ ? right
110
+ : pathResolver(right, self)(x, c));
111
+ break;
112
+ case ">":
113
+ whenLogic = (x, c) => pathResolver(left, self)(x, c) >
114
+ (rightIsValue
115
+ ? right
116
+ : pathResolver(right, self)(x, c));
117
+ break;
118
+ case "<=":
119
+ whenLogic = (x, c) => pathResolver(left, self)(x, c) <=
120
+ (rightIsValue
121
+ ? right
122
+ : pathResolver(right, self)(x, c));
123
+ break;
124
+ case "<":
125
+ whenLogic = (x, c) => pathResolver(left, self)(x, c) <
126
+ (rightIsValue
127
+ ? right
128
+ : pathResolver(right, self)(x, c));
129
+ break;
130
+ }
131
+ externalValues.push(when(whenLogic, this.resolveTemplateOrBehavior(strings, values)));
76
132
  }
77
133
  break;
78
134
  case "repeat":
@@ -80,7 +136,7 @@ class TemplateElement extends FASTElement {
80
136
  const valueAttr = behaviorConfig.value.split(" "); // syntax {{x in y}}
81
137
  const { strings, values } = yield this.resolveStringsAndValues(innerHTML.slice(behaviorConfig.openingTagEndIndex, behaviorConfig.closingTagStartIndex), true);
82
138
  const { repeat } = yield import("@microsoft/fast-element");
83
- externalValues.push(repeat(x => pathResolver(valueAttr[2], self)(x), this.resolveTemplateOrBehavior(strings, values)));
139
+ externalValues.push(repeat((x, c) => pathResolver(valueAttr[2], self)(x, c), this.resolveTemplateOrBehavior(strings, values)));
84
140
  }
85
141
  break;
86
142
  case "apply": {
@@ -92,7 +148,7 @@ class TemplateElement extends FASTElement {
92
148
  })) === null || _a === void 0 ? void 0 : _a.split('"')[1];
93
149
  if (partial) {
94
150
  const { when } = yield import("@microsoft/fast-element");
95
- externalValues.push(when(x => pathResolver(behaviorConfig.value, self)(x), () => this.partials[partial]));
151
+ externalValues.push(when((x, c) => pathResolver(behaviorConfig.value, self)(x, c), () => this.partials[partial]));
96
152
  }
97
153
  }
98
154
  }
@@ -143,7 +199,7 @@ class TemplateElement extends FASTElement {
143
199
  {
144
200
  strings.push(innerHTML.slice(0, behaviorConfig.openingStartIndex));
145
201
  const propName = innerHTML.slice(behaviorConfig.openingEndIndex, behaviorConfig.closingStartIndex);
146
- const binding = (x) => pathResolver(propName, self)(x);
202
+ const binding = (x, c) => pathResolver(propName, self)(x, c);
147
203
  values.push(binding);
148
204
  yield this.resolveInnerHTML(innerHTML.slice(behaviorConfig.closingEndIndex, innerHTML.length), strings, values, self);
149
205
  }
@@ -152,12 +208,12 @@ class TemplateElement extends FASTElement {
152
208
  strings.push(innerHTML.slice(0, behaviorConfig.openingStartIndex));
153
209
  if (behaviorConfig.aspect === "@") {
154
210
  const propName = innerHTML.slice(behaviorConfig.openingEndIndex, behaviorConfig.closingStartIndex - 2);
155
- const binding = (x) => pathResolver(propName, self)(x)();
211
+ const binding = (x, c) => pathResolver(propName, self)(x, c)();
156
212
  values.push(binding);
157
213
  }
158
214
  else {
159
215
  const propName = innerHTML.slice(behaviorConfig.openingEndIndex, behaviorConfig.closingStartIndex);
160
- const binding = (x) => pathResolver(propName, self)(x);
216
+ const binding = (x, c) => pathResolver(propName, self)(x, c);
161
217
  values.push(binding);
162
218
  }
163
219
  yield this.resolveInnerHTML(innerHTML.slice(behaviorConfig.closingEndIndex, innerHTML.length), strings, values, self);
@@ -56,7 +56,8 @@ export function getIndexOfNextMatchingTag(openingTagStartSlice, openingTag, clos
56
56
  function getNextDirectiveBehavior(innerHTML) {
57
57
  const openingTagStartIndex = innerHTML.indexOf(openTagStart);
58
58
  const openingTagStartSlice = innerHTML.slice(openingTagStartIndex);
59
- const openingTagEndIndex = openingTagStartSlice.indexOf(tagEnd) + openingTagStartIndex + 1;
59
+ const openingTagEndIndex = // account for f-when which may include >= or > as operators, but will always include a condition attr
60
+ openingTagStartSlice.indexOf(`"${tagEnd}`) + openingTagStartIndex + 2;
60
61
  const directiveTag = innerHTML
61
62
  .slice(openingTagStartIndex + 3, openingTagEndIndex - 1)
62
63
  .split(" ")[0];
@@ -185,7 +186,7 @@ export function getAllPartials(innerHTML, offset = 0, partials = {}) {
185
186
  const startId = openingTagStartIndex + ' id="'.length + openingTag.length;
186
187
  const endId = innerHTML.slice(startId).indexOf('"') + startId;
187
188
  const id = innerHTML.slice(startId, endId);
188
- const openingTagEndIndex = openingTagStartSlice.indexOf(">") + 1 + openingTagStartIndex;
189
+ const openingTagEndIndex = openingTagStartSlice.indexOf(tagEnd) + 1 + openingTagStartIndex;
189
190
  const closingTagStartIndex = matchingCloseTagIndex - closingTagLength;
190
191
  partials[id] = {
191
192
  innerHTML: innerHTML.slice(openingTagEndIndex, closingTagStartIndex),
@@ -206,7 +207,8 @@ export function getAllPartials(innerHTML, offset = 0, partials = {}) {
206
207
  */
207
208
  export function pathResolver(path, self = false) {
208
209
  let splitPath = path.split(".");
209
- if (self) {
210
+ const usesContext = path.startsWith("../");
211
+ if (self && !usesContext) {
210
212
  if (splitPath.length > 1) {
211
213
  splitPath = splitPath.slice(1);
212
214
  }
@@ -216,14 +218,79 @@ export function pathResolver(path, self = false) {
216
218
  };
217
219
  }
218
220
  }
219
- if (splitPath.length === 1) {
221
+ if (splitPath.length === 1 && !usesContext) {
220
222
  return (accessibleObject) => {
221
223
  return accessibleObject === null || accessibleObject === void 0 ? void 0 : accessibleObject[splitPath[0]];
222
224
  };
223
225
  }
224
- return (accessibleObject) => {
226
+ return (accessibleObject, context) => {
227
+ if (usesContext) {
228
+ splitPath = [];
229
+ path.split("../").forEach(pathItem => {
230
+ if (pathItem === "") {
231
+ splitPath.unshift("parent");
232
+ }
233
+ else {
234
+ splitPath.push(...pathItem.split("."));
235
+ }
236
+ });
237
+ return splitPath.reduce((previousAccessors, pathItem) => {
238
+ return previousAccessors === null || previousAccessors === void 0 ? void 0 : previousAccessors[pathItem];
239
+ }, context);
240
+ }
225
241
  return splitPath.reduce((previousAccessors, pathItem) => {
226
242
  return previousAccessors === null || previousAccessors === void 0 ? void 0 : previousAccessors[pathItem];
227
243
  }, accessibleObject);
228
244
  };
229
245
  }
246
+ /**
247
+ * Determine if the operand is a value (boolean, number, string) or an accessor.
248
+ * @param operand
249
+ */
250
+ function isOperandValue(operand) {
251
+ try {
252
+ const value = JSON.parse(operand);
253
+ return {
254
+ value,
255
+ isValue: true,
256
+ };
257
+ }
258
+ catch (e) {
259
+ return {
260
+ value: operand,
261
+ isValue: false,
262
+ };
263
+ }
264
+ }
265
+ /**
266
+ * Get the operator used.
267
+ * @param value the binded value
268
+ * @returns Operator
269
+ */
270
+ export function getOperator(value) {
271
+ if (value[0] === "!") {
272
+ return {
273
+ operator: "!",
274
+ left: value.slice(1),
275
+ right: null,
276
+ rightIsValue: null,
277
+ };
278
+ }
279
+ const split = value.split(" ");
280
+ if (split.length === 3) {
281
+ const operator = split[1];
282
+ const { value, isValue } = isOperandValue(split[2]);
283
+ return {
284
+ operator,
285
+ left: split[0],
286
+ right: isValue ? value : split[2],
287
+ rightIsValue: isValue,
288
+ };
289
+ }
290
+ return {
291
+ operator: "access",
292
+ left: value,
293
+ right: null,
294
+ rightIsValue: null,
295
+ };
296
+ }
@@ -145,16 +145,19 @@ test.describe("utilities", () => __awaiter(void 0, void 0, void 0, function* ()
145
145
  }));
146
146
  test.describe("pathResolver", () => __awaiter(void 0, void 0, void 0, function* () {
147
147
  test("should resolve a path with no nesting", () => __awaiter(void 0, void 0, void 0, function* () {
148
- expect(pathResolver("foo")({ foo: "bar" })).toEqual("bar");
148
+ expect(pathResolver("foo")({ foo: "bar" }, {})).toEqual("bar");
149
149
  }));
150
150
  test("should resolve a path with nesting", () => __awaiter(void 0, void 0, void 0, function* () {
151
- expect(pathResolver("foo.bar.bat")({ foo: { bar: { bat: "baz" } } })).toEqual("baz");
151
+ expect(pathResolver("foo.bar.bat")({ foo: { bar: { bat: "baz" } } }, {})).toEqual("baz");
152
152
  }));
153
153
  test("should resolve a path with no nesting and self reference", () => __awaiter(void 0, void 0, void 0, function* () {
154
- expect(pathResolver("foo", true)("bar")).toEqual("bar");
154
+ expect(pathResolver("foo", true)("bar", {})).toEqual("bar");
155
155
  }));
156
156
  test("should resolve a path with nesting and self reference", () => __awaiter(void 0, void 0, void 0, function* () {
157
- expect(pathResolver("foo.bar.bat", true)({ bar: { bat: "baz" } })).toEqual("baz");
157
+ expect(pathResolver("foo.bar.bat", true)({ bar: { bat: "baz" } }, {})).toEqual("baz");
158
+ }));
159
+ test("should resolve a path with context", () => __awaiter(void 0, void 0, void 0, function* () {
160
+ expect(pathResolver("../foo")({}, { parent: { foo: "bar" } })).toEqual("bar");
158
161
  }));
159
162
  }));
160
163
  }));
@@ -5,6 +5,7 @@ class TestElement extends FASTElement {
5
5
  constructor() {
6
6
  super(...arguments);
7
7
  this.list = ["Foo", "Bar"];
8
+ this.parent = "Bat";
8
9
  }
9
10
  }
10
11
  __decorate([
@@ -6,8 +6,8 @@ test.describe("f-template", () => __awaiter(void 0, void 0, void 0, function* ()
6
6
  const customElement = yield page.locator("test-element");
7
7
  let customElementListItems = yield customElement.locator("li");
8
8
  expect(yield customElementListItems.count()).toEqual(2);
9
- expect(yield customElementListItems.nth(0).textContent()).toEqual("Foo");
10
- expect(yield customElementListItems.nth(1).textContent()).toEqual("Bar");
9
+ expect(yield customElementListItems.nth(0).textContent()).toEqual("Foo - Bat");
10
+ expect(yield customElementListItems.nth(1).textContent()).toEqual("Bar - Bat");
11
11
  yield page.evaluate(() => {
12
12
  const customElement = document.getElementsByTagName("test-element");
13
13
  customElement.item(0).list = [
@@ -19,8 +19,8 @@ test.describe("f-template", () => __awaiter(void 0, void 0, void 0, function* ()
19
19
  yield expect(customElement).toHaveJSProperty("list", ["A", "B", "C"]);
20
20
  customElementListItems = yield customElement.locator("li");
21
21
  expect(yield customElementListItems.count()).toEqual(3);
22
- expect(yield customElementListItems.nth(0).textContent()).toEqual("A");
23
- expect(yield customElementListItems.nth(1).textContent()).toEqual("B");
24
- expect(yield customElementListItems.nth(2).textContent()).toEqual("C");
22
+ expect(yield customElementListItems.nth(0).textContent()).toEqual("A - Bat");
23
+ expect(yield customElementListItems.nth(1).textContent()).toEqual("B - Bat");
24
+ expect(yield customElementListItems.nth(2).textContent()).toEqual("C - Bat");
25
25
  }));
26
26
  }));
@@ -14,6 +14,133 @@ __decorate([
14
14
  TestElement.define({
15
15
  name: "test-element",
16
16
  });
17
+ class TestElementNot extends FASTElement {
18
+ constructor() {
19
+ super(...arguments);
20
+ this.hide = false;
21
+ }
22
+ }
23
+ __decorate([
24
+ attr({ mode: "boolean" }),
25
+ __metadata("design:type", Boolean)
26
+ ], TestElementNot.prototype, "hide", void 0);
27
+ TestElementNot.define({
28
+ name: "test-element-not",
29
+ });
30
+ class TestElementEquals extends FASTElement {
31
+ constructor() {
32
+ super(...arguments);
33
+ this.varA = 0;
34
+ }
35
+ }
36
+ __decorate([
37
+ attr({ attribute: "var-a" }),
38
+ __metadata("design:type", Number)
39
+ ], TestElementEquals.prototype, "varA", void 0);
40
+ TestElementEquals.define({
41
+ name: "test-element-equals",
42
+ });
43
+ class TestElementNotEquals extends FASTElement {
44
+ constructor() {
45
+ super(...arguments);
46
+ this.varA = 0;
47
+ }
48
+ }
49
+ __decorate([
50
+ attr({ attribute: "var-a" }),
51
+ __metadata("design:type", Number)
52
+ ], TestElementNotEquals.prototype, "varA", void 0);
53
+ TestElementNotEquals.define({
54
+ name: "test-element-not-equals",
55
+ });
56
+ class TestElementGe extends FASTElement {
57
+ constructor() {
58
+ super(...arguments);
59
+ this.varA = 0;
60
+ }
61
+ }
62
+ __decorate([
63
+ attr({ attribute: "var-a" }),
64
+ __metadata("design:type", Number)
65
+ ], TestElementGe.prototype, "varA", void 0);
66
+ TestElementGe.define({
67
+ name: "test-element-ge",
68
+ });
69
+ class TestElementGt extends FASTElement {
70
+ constructor() {
71
+ super(...arguments);
72
+ this.varA = 0;
73
+ }
74
+ }
75
+ __decorate([
76
+ attr({ attribute: "var-a" }),
77
+ __metadata("design:type", Number)
78
+ ], TestElementGt.prototype, "varA", void 0);
79
+ TestElementGt.define({
80
+ name: "test-element-gt",
81
+ });
82
+ class TestElementLe extends FASTElement {
83
+ constructor() {
84
+ super(...arguments);
85
+ this.varA = 0;
86
+ }
87
+ }
88
+ __decorate([
89
+ attr({ attribute: "var-a" }),
90
+ __metadata("design:type", Number)
91
+ ], TestElementLe.prototype, "varA", void 0);
92
+ TestElementLe.define({
93
+ name: "test-element-le",
94
+ });
95
+ class TestElementLt extends FASTElement {
96
+ constructor() {
97
+ super(...arguments);
98
+ this.varA = 0;
99
+ }
100
+ }
101
+ __decorate([
102
+ attr({ attribute: "var-a" }),
103
+ __metadata("design:type", Number)
104
+ ], TestElementLt.prototype, "varA", void 0);
105
+ TestElementLt.define({
106
+ name: "test-element-lt",
107
+ });
108
+ class TestElementOr extends FASTElement {
109
+ constructor() {
110
+ super(...arguments);
111
+ this.thisVar = false;
112
+ this.thatVar = false;
113
+ }
114
+ }
115
+ __decorate([
116
+ attr({ attribute: "this-var", mode: "boolean" }),
117
+ __metadata("design:type", Boolean)
118
+ ], TestElementOr.prototype, "thisVar", void 0);
119
+ __decorate([
120
+ attr({ attribute: "that-var", mode: "boolean" }),
121
+ __metadata("design:type", Boolean)
122
+ ], TestElementOr.prototype, "thatVar", void 0);
123
+ TestElementOr.define({
124
+ name: "test-element-or",
125
+ });
126
+ class TestElementAnd extends FASTElement {
127
+ constructor() {
128
+ super(...arguments);
129
+ this.thisVar = false;
130
+ this.thatVar = false;
131
+ }
132
+ }
133
+ __decorate([
134
+ attr({ attribute: "this-var", mode: "boolean" }),
135
+ __metadata("design:type", Boolean)
136
+ ], TestElementAnd.prototype, "thisVar", void 0);
137
+ __decorate([
138
+ attr({ attribute: "that-var", mode: "boolean" }),
139
+ __metadata("design:type", Boolean)
140
+ ], TestElementAnd.prototype, "thatVar", void 0);
141
+ TestElementAnd.define({
142
+ name: "test-element-and",
143
+ });
17
144
  TemplateElement.define({
18
145
  name: "f-template",
19
146
  });
@@ -1,7 +1,7 @@
1
1
  import { __awaiter } from "tslib";
2
2
  import { expect, test } from "@playwright/test";
3
3
  test.describe("f-template", () => __awaiter(void 0, void 0, void 0, function* () {
4
- test("create a when directive", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
4
+ test("create a when directive for a boolean: true", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
5
5
  yield page.goto("/when");
6
6
  const customElementShow = yield page.locator("#show");
7
7
  const customElementHide = yield page.locator("#hide");
@@ -16,4 +16,67 @@ test.describe("f-template", () => __awaiter(void 0, void 0, void 0, function* ()
16
16
  yield expect(customElementShow).not.toHaveText("Hello world");
17
17
  yield expect(customElementHide).toHaveText("Hello world");
18
18
  }));
19
+ test("create a when directive for a boolean: false", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
20
+ yield page.goto("/when");
21
+ const customElementShow = yield page.locator("#show-not");
22
+ const customElementHide = yield page.locator("#hide-not");
23
+ yield expect(customElementShow).toHaveText("Hello world");
24
+ yield expect(customElementHide).not.toHaveText("Hello world");
25
+ }));
26
+ test("create a when directive value uses equals", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
27
+ yield page.goto("/when");
28
+ const customElementShow = yield page.locator("#equals-true");
29
+ const customElementHide = yield page.locator("#equals-false");
30
+ yield expect(customElementShow).toHaveText("Equals 3");
31
+ yield expect(customElementHide).not.toHaveText("Equals 3");
32
+ }));
33
+ test("create a when directive value uses not equals", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
34
+ yield page.goto("/when");
35
+ const customElementShow = yield page.locator("#not-equals-true");
36
+ const customElementHide = yield page.locator("#not-equals-false");
37
+ yield expect(customElementShow).toHaveText("Not equals 3");
38
+ yield expect(customElementHide).not.toHaveText("Not equals 3");
39
+ }));
40
+ test("create a when directive value uses greater than or equals", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
41
+ yield page.goto("/when");
42
+ const customElementShow = yield page.locator("#ge-true");
43
+ const customElementHide = yield page.locator("#ge-false");
44
+ yield expect(customElementShow).toHaveText("Two and Over");
45
+ yield expect(customElementHide).not.toHaveText("Two and Over");
46
+ }));
47
+ test("create a when directive value uses greater than", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
48
+ yield page.goto("/when");
49
+ const customElementShow = yield page.locator("#gt-true");
50
+ const customElementHide = yield page.locator("#gt-false");
51
+ yield expect(customElementShow).toHaveText("Over two");
52
+ yield expect(customElementHide).not.toHaveText("Over two");
53
+ }));
54
+ test("create a when directive value uses less than or equals", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
55
+ yield page.goto("/when");
56
+ const customElementShow = yield page.locator("#le-true");
57
+ const customElementHide = yield page.locator("#le-false");
58
+ yield expect(customElementShow).toHaveText("Two and Under");
59
+ yield expect(customElementHide).not.toHaveText("Two and Under");
60
+ }));
61
+ test("create a when directive value uses less than", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
62
+ yield page.goto("/when");
63
+ const customElementShow = yield page.locator("#lt-true");
64
+ const customElementHide = yield page.locator("#lt-false");
65
+ yield expect(customElementShow).toHaveText("Under two");
66
+ yield expect(customElementHide).not.toHaveText("Under two");
67
+ }));
68
+ test("create a when directive value uses or", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
69
+ yield page.goto("/when");
70
+ const customElementShow = yield page.locator("#or-true");
71
+ const customElementHide = yield page.locator("#or-false");
72
+ yield expect(customElementShow).toHaveText("This or That");
73
+ yield expect(customElementHide).not.toHaveText("This or That");
74
+ }));
75
+ test("create a when directive value uses and", ({ page }) => __awaiter(void 0, void 0, void 0, function* () {
76
+ yield page.goto("/when");
77
+ const customElementShow = yield page.locator("#and-true");
78
+ const customElementHide = yield page.locator("#and-false");
79
+ yield expect(customElementShow).toHaveText("This and That");
80
+ yield expect(customElementHide).not.toHaveText("This and That");
81
+ }));
19
82
  }));