File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { expect , fixture , html } from '@open-wc/testing'
2+ import { spy } from 'sinon'
3+ import { addStrategy , lazyDefine } from '../src/lazy-define.js'
4+
5+ describe ( 'addStrategy' , ( ) => {
6+ let strategy : ReturnType < typeof spy >
7+ let promise : Promise < void >
8+ let resolve : ( ) => void
9+
10+ beforeEach ( ( ) => {
11+ strategy = spy ( ( ) => promise = new Promise ( ( res ) => resolve = res ) )
12+ } )
13+
14+ it ( 'adds a new strategy' , async ( ) => {
15+ const onDefine = spy ( )
16+ lazyDefine ( 'foo-bar' , onDefine )
17+ addStrategy ( 'test' , strategy )
18+ await fixture ( html `< foo-bar data-load-on ="test "> </ foo-bar > ` )
19+
20+ expect ( strategy ) . to . be . calledOnceWith ( 'foo-bar' )
21+ expect ( onDefine ) . to . have . callCount ( 0 )
22+ resolve ( )
23+ await promise
24+ expect ( onDefine ) . to . be . callCount ( 1 )
25+ } )
26+
27+ it ( "doesn't overwrite a existing strategy" , ( ) => {
28+ expect ( ( ) => addStrategy ( 'ready' , spy ( ) ) ) . to . throw ( / a l r e a d y e x i s t s / )
29+ } )
30+ } )
31+
32+ describe ( 'lazyDefine' , ( ) => {
33+ it ( '' , ( ) => { } )
34+ } )
You can’t perform that action at this time.
0 commit comments