github.com/GoogleCloudPlatform/testgrid@v0.0.174/web/test/testgrid-grid-cell.test.ts (about)

     1  import {
     2      html,
     3      fixture,
     4      defineCE,
     5      unsafeStatic,
     6      expect,
     7  } from '@open-wc/testing';
     8  import { TestgridGridCell } from '../src/testgrid-grid-cell';
     9  import { TestStatus } from '../src/gen/pb/test_status/test_status';
    10  
    11  describe('TestGrid grid cell', () => {
    12      let element: TestgridGridCell;
    13      beforeEach(async () => {
    14          // Need to wrap an element to apply its properties (ex. @customElement)
    15          // See https://open-wc.org/docs/testing/helpers/#test-a-custom-class-with-properties
    16          const tagName = defineCE(class extends TestgridGridCell { });
    17          const tag = unsafeStatic(tagName);
    18          element = await fixture(html`<${tag}></${tag}>`);
    19      });
    20      it('passes the a11y audit', async () => {
    21          expect(element).shadowDom.to.be.accessible();
    22      });
    23  
    24      it('can instantiate', async () => {
    25          expect(element).to.exist;
    26          expect(element.icon).to.undefined;
    27          expect(element.status).to.undefined;
    28      });
    29  
    30      [
    31          {icon: 'P', status: TestStatus.PASS},
    32          {icon: 'F', status: TestStatus.FAIL},
    33          {icon: 'R', status: TestStatus.RUNNING},
    34      ].forEach(function(testCase) {
    35          it("renders with status " + TestStatus[testCase.status], async() => {
    36              const tagName = defineCE(class extends TestgridGridCell { });
    37              const tag = unsafeStatic(tagName);
    38              let el: TestgridGridCell;
    39              el = await fixture(html`<${tag} .icon=${testCase.icon} .status=${TestStatus[testCase.status]}></${tag}>`);
    40      
    41              expect(el).to.exist;
    42              expect(el.icon).to.equal(testCase.icon);
    43              expect(el.status).to.equal(TestStatus[testCase.status]);
    44          });
    45      });
    46  });