How to use the stampit.statics function in stampit

To help you get started, we’ve selected a few stampit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github char0n / page-objects / src / todo-list.page.js View on Github external
'use strict';

const { By } = require('selenium-webdriver');
const stampit = require('stampit');

const TodoListItem = require('./todo-list-item.page');


const TodoList = stampit
  .statics({
    completeListId: 'completed',
    todoListId: 'todo',
  })
  .init(function ({ webElement }) {
    this.isComplete = async function isComplete() {
      return (await webElement.getAttribute('id')) === TodoList.completeListId;
    };

    this.isTodo = async function isTodo() {
      return (await webElement.getAttribute('id')) === TodoList.todoListId;
    };

    this.getItems = async function getItems() {
      const items = await webElement.findElements(By.css('li'));
github char0n / page-objects / src / todo-list-item-creator.page.js View on Github external
this.isEnabled = async function isEnabled() {
    const element = await findElement();

    return element.isEnabled();
  };

  this.click = async function click() {
    const element = await findElement();

    return element.click();
  };
});


const TodoListItemCreator = stampit
  .statics({
    AddButton,
  })
  .init(function ({ driver }) {
    const findElement = async () => driver.findElement(By.css('header input'));

    this.focus = async function focus() {
      const element = await findElement();

      return element.sendKeys('');
    };

    this.sendKeys = async function sendKeys(...keys) {
      const element = await findElement();

      return element.sendKeys(...keys);

stampit

Create objects from reusable, composable behaviors.

MIT
Latest version published 4 years ago

Package Health Score

62 / 100
Full package analysis