|
| 1 | +/* SPDX-License-Identifier: Apache-2.0 */ |
| 2 | +import { ComponentFixture, TestBed } from "@angular/core/testing"; |
| 3 | +import { SchemaRangeComponent } from "./schema-range.component"; |
| 4 | + |
| 5 | +describe("SchemaRangeComponent", function () { |
| 6 | + let component: SchemaRangeComponent; |
| 7 | + let fixture: ComponentFixture<SchemaRangeComponent>; |
| 8 | + |
| 9 | + beforeEach(() => { |
| 10 | + TestBed.configureTestingModule({ |
| 11 | + declarations: [SchemaRangeComponent], |
| 12 | + }).compileComponents(); |
| 13 | + |
| 14 | + fixture = TestBed.createComponent(SchemaRangeComponent as any); |
| 15 | + component = fixture.debugElement.componentInstance; |
| 16 | + }); |
| 17 | + |
| 18 | + it("should create the component", () => { |
| 19 | + expect(component).toBeTruthy(); |
| 20 | + }); |
| 21 | + |
| 22 | + it("should have `( 0.1 .. 10 )` as value", async () => { |
| 23 | + component.schema = { |
| 24 | + title: "test", |
| 25 | + minimum: 0.1, |
| 26 | + maximum: 10, |
| 27 | + exclusiveMinimum: true, |
| 28 | + exclusiveMaximum: true, |
| 29 | + }; |
| 30 | + |
| 31 | + fixture.detectChanges(); |
| 32 | + const compiled = fixture.debugElement.nativeElement; |
| 33 | + expect(compiled.querySelector("span").textContent).toContain( |
| 34 | + "( 0.1 .. 10 )" |
| 35 | + ); |
| 36 | + }); |
| 37 | + |
| 38 | + it("should have `[ 0.1 .. 10 )` as value", async () => { |
| 39 | + component.schema = { |
| 40 | + title: "test", |
| 41 | + minimum: 0.1, |
| 42 | + maximum: 10, |
| 43 | + exclusiveMinimum: false, |
| 44 | + exclusiveMaximum: true, |
| 45 | + }; |
| 46 | + |
| 47 | + fixture.detectChanges(); |
| 48 | + const compiled = fixture.debugElement.nativeElement; |
| 49 | + expect(compiled.querySelector("span").textContent).toContain( |
| 50 | + "[ 0.1 .. 10 )" |
| 51 | + ); |
| 52 | + }); |
| 53 | + |
| 54 | + it("should have `( 0.1 .. 10 ]` as value", async () => { |
| 55 | + component.schema = { |
| 56 | + title: "test", |
| 57 | + minimum: 0.1, |
| 58 | + maximum: 10, |
| 59 | + exclusiveMinimum: true, |
| 60 | + exclusiveMaximum: false, |
| 61 | + }; |
| 62 | + |
| 63 | + fixture.detectChanges(); |
| 64 | + const compiled = fixture.debugElement.nativeElement; |
| 65 | + expect(compiled.querySelector("span").textContent).toContain( |
| 66 | + "( 0.1 .. 10 ]" |
| 67 | + ); |
| 68 | + }); |
| 69 | + |
| 70 | + it("should have `[ 0.1 .. 10 ]` as value", async () => { |
| 71 | + component.schema = { |
| 72 | + title: "test", |
| 73 | + minimum: 0.1, |
| 74 | + maximum: 10, |
| 75 | + }; |
| 76 | + |
| 77 | + fixture.detectChanges(); |
| 78 | + const compiled = fixture.debugElement.nativeElement; |
| 79 | + expect(compiled.querySelector("span").textContent).toContain( |
| 80 | + "[ 0.1 .. 10 ]" |
| 81 | + ); |
| 82 | + }); |
| 83 | + |
| 84 | + it("should have `> 0.1` as value", async () => { |
| 85 | + component.schema = { |
| 86 | + title: "test", |
| 87 | + minimum: 0.1, |
| 88 | + exclusiveMinimum: true, |
| 89 | + }; |
| 90 | + |
| 91 | + fixture.detectChanges(); |
| 92 | + const compiled = fixture.debugElement.nativeElement; |
| 93 | + expect(compiled.querySelector("span").textContent).toContain("> 0.1"); |
| 94 | + }); |
| 95 | + |
| 96 | + it("should have `< 10` as value", async () => { |
| 97 | + component.schema = { |
| 98 | + title: "test", |
| 99 | + maximum: 10, |
| 100 | + exclusiveMaximum: true, |
| 101 | + }; |
| 102 | + |
| 103 | + fixture.detectChanges(); |
| 104 | + const compiled = fixture.debugElement.nativeElement; |
| 105 | + expect(compiled.querySelector("span").textContent).toContain("< 10"); |
| 106 | + }); |
| 107 | + |
| 108 | + it("should have `>= 0.1` as value", async () => { |
| 109 | + component.schema = { |
| 110 | + title: "test", |
| 111 | + minimum: 0.1, |
| 112 | + }; |
| 113 | + |
| 114 | + fixture.detectChanges(); |
| 115 | + const compiled = fixture.debugElement.nativeElement; |
| 116 | + expect(compiled.querySelector("span").textContent).toContain(">= 0.1"); |
| 117 | + }); |
| 118 | + |
| 119 | + it("should have `<= 10` as value", async () => { |
| 120 | + component.schema = { |
| 121 | + title: "test", |
| 122 | + maximum: 10, |
| 123 | + }; |
| 124 | + |
| 125 | + fixture.detectChanges(); |
| 126 | + const compiled = fixture.debugElement.nativeElement; |
| 127 | + expect(compiled.querySelector("span").textContent).toContain("<= 10"); |
| 128 | + }); |
| 129 | +}); |
0 commit comments