-
Notifications
You must be signed in to change notification settings - Fork 2k
/
react.spec.ts
33 lines (29 loc) · 1.54 KB
/
react.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
describe('@uppy/react', () => {
beforeEach(() => {
cy.visit('/react')
cy.get('#dashboard .uppy-Dashboard-input:first').as('dashboard-input')
cy.get('#modal .uppy-Dashboard-input:first').as('modal-input')
cy.get('#drag-drop .uppy-DragDrop-input').as('dragdrop-input')
})
it('should render Dashboard in React and show thumbnails', () => {
cy.get('@dashboard-input').selectFile(['cypress/fixtures/images/cat.jpg', 'cypress/fixtures/images/traffic.jpg'], { force:true })
cy.get('#dashboard .uppy-Dashboard-Item-previewImg')
.should('have.length', 2)
.each((element) => expect(element).attr('src').to.include('blob:'))
})
it('should render Modal in React and show thumbnails', () => {
cy.get('#open').click()
cy.get('@modal-input').selectFile(['cypress/fixtures/images/cat.jpg', 'cypress/fixtures/images/traffic.jpg'], { force:true })
cy.get('#modal .uppy-Dashboard-Item-previewImg')
.should('have.length', 2)
.each((element) => expect(element).attr('src').to.include('blob:'))
})
it('should render Drag & Drop in React and create a thumbail with @uppy/thumbnail-generator', () => {
const spy = cy.spy()
cy.window().then(({ uppy }) => uppy.on('thumbnail:generated', spy))
cy.get('@dragdrop-input').selectFile(['cypress/fixtures/images/cat.jpg', 'cypress/fixtures/images/traffic.jpg'], { force:true })
// not sure how I can accurately wait for the thumbnail
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(1000).then(() => expect(spy).to.be.called)
})
})