@operato/font 10.29.81 → 10.29.84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,64 +0,0 @@
1
- import { aTimeout, expect, fixture } from '@open-wc/testing'
2
- import { html } from 'lit'
3
-
4
- import '../src/font-creation-card.js'
5
-
6
- /**
7
- * The font card's file pick.
8
- *
9
- * ## Why this is tested
10
- *
11
- * The card picked font files with its own `ox-file-selector`, one of several file pickers that did
12
- * the same thing. It now uses `ox-input-file`, the one picker. What must hold: picked font files
13
- * reach `create-font`, a file that is not a font is refused, picking does not flip the card, and
14
- * reset empties the pick.
15
- */
16
- describe('font-creation-card', () => {
17
- const drop = (area: HTMLElement, ...files: File[]) => {
18
- const dataTransfer = new DataTransfer()
19
- files.forEach(one => dataTransfer.items.add(one))
20
- area.dispatchEvent(new DragEvent('drop', { dataTransfer, bubbles: true, cancelable: true }))
21
- }
22
-
23
- it('takes the picked font files into create-font', async () => {
24
- const card: any = await fixture(html`<font-creation-card></font-creation-card>`)
25
- card.provider = 'custom'
26
- await card.updateComplete
27
-
28
- const picker = card.renderRoot.querySelector('ox-input-file')
29
- expect(picker, 'the card has no picker').to.exist
30
-
31
- drop(picker, new File(['x'], 'brand.woff2'), new File(['x'], 'notes.txt', { type: 'text/plain' }))
32
- await aTimeout(0)
33
- await card.updateComplete
34
-
35
- expect(card.files.map((one: File) => one.name), 'a non-font was taken').to.deep.equal(['brand.woff2'])
36
-
37
- let detail: any
38
- card.addEventListener('create-font', (e: CustomEvent) => (detail = e.detail))
39
- const form = card.renderRoot.querySelector('form')
40
- ;(form.elements.namedItem('name') as HTMLInputElement).value = 'Brand'
41
- form.dispatchEvent(new Event('submit', { cancelable: true }))
42
-
43
- expect(detail.files.map((one: File) => one.name)).to.deep.equal(['brand.woff2'])
44
- })
45
-
46
- it('does not flip when the picker is clicked, and reset empties the pick', async () => {
47
- const card: any = await fixture(html`<font-creation-card></font-creation-card>`)
48
- card.provider = 'custom'
49
- card.classList.add('flipped')
50
- await card.updateComplete
51
-
52
- const picker = card.renderRoot.querySelector('ox-input-file')
53
- picker.click()
54
- expect(card.classList.contains('flipped'), 'clicking the picker flipped the card').to.equal(true)
55
-
56
- drop(picker, new File(['x'], 'brand.ttf'))
57
- await aTimeout(0)
58
- card.reset()
59
- await card.updateComplete
60
-
61
- expect(card.files).to.deep.equal([])
62
- expect(picker.value).to.deep.equal([])
63
- })
64
- })