Sha256: c11a7897a6db5879f64b1f8138fcb83dc64e065943af2373f5315d10b5608cb2

Contents?: true

Size: 1.32 KB

Versions: 4

Compression:

Stored size: 1.32 KB

Contents

import React, {useState} from "react"
import { render, screen } from "../utilities/test-utils"

import { Draggable, DraggableProvider, SelectableList } from '../'

const testId = 'draggable'

const data = [
  {
    id: "1",
    text: "Task 1",
  },
  {
    id: "2",
    text: "Task 2",
  },
  {
    id: "3",
    text: "Task 3",
  },
  {
    id: "4",
    text: "Task 4",
  },
];


const DefaultDraggableKit = () => {
  const [initialState, setInitialState] = useState(data);

  return (
    <DraggableProvider
        initialItems={data}
        onReorder={(items) => setInitialState(items)}
    >
      <Draggable
          data={{ testid: testId }}
      >
        <Draggable.Container>
          <SelectableList variant="checkbox">
            {initialState.map(({ id, text }) => (
              <Draggable.Item id={id} 
                  key={id}
              >
                <SelectableList.Item label={text} 
                    name={id} 
                    value={id} 
                />
              </Draggable.Item>
            ))}
          </SelectableList>
        </Draggable.Container>
      </Draggable>
    </DraggableProvider>
  );
};

test('generated default kit and classname', () => {
render(<DefaultDraggableKit/>)
const kit = screen.getByTestId(testId)
expect(kit).toBeInTheDocument()
expect(kit).toHaveClass('pb_draggable')
})

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
playbook_ui-13.30.0.pre.alpha.PLAY1328fixtimelinekitglobalpropsreact3096 app/pb_kits/playbook/pb_draggable/draggable.test.jsx
playbook_ui-13.30.0 app/pb_kits/playbook/pb_draggable/draggable.test.jsx
playbook_ui-13.29.0.pre.alpha.PBNTR329draggablev33060 app/pb_kits/playbook/pb_draggable/draggable.test.jsx
playbook_ui-13.29.0.pre.alpha.PBNTR329draggablev33059 app/pb_kits/playbook/pb_draggable/draggable.test.jsx