@@ -8,20 +8,42 @@ test("FileAttachments is exported by stdlib", t => {
88} ) ;
99
1010test ( "FileAttachment ensures that URLs are strings" , async t => {
11- const fileAttachments = FileAttachments ( ( name ) =>
11+ const FileAttachment = FileAttachments ( ( name ) =>
1212 new URL ( `https://example.com/${ name } .js` )
1313 ) ;
14- const file = fileAttachments ( "filename" ) ;
14+ const file = FileAttachment ( "filename" ) ;
1515 t . equal ( file . constructor . name , "FileAttachment" ) ;
1616 t . equal ( await file . url ( ) , "https://example.com/filename.js" ) ;
1717 t . end ( ) ;
1818} ) ;
1919
20+ test ( "FileAttachment returns instances of FileAttachment" , async t => {
21+ const FileAttachment = FileAttachments ( ( name ) =>
22+ new URL ( `https://example.com/${ name } .js` )
23+ ) ;
24+ const file = FileAttachment ( "filename" ) ;
25+ t . true ( file instanceof FileAttachment ) ;
26+ t . end ( ) ;
27+ } ) ;
28+
29+ test ( "FileAttachment cannot be used as a constructor" , async t => {
30+ const FileAttachment = FileAttachments ( ( name ) =>
31+ new URL ( `https://example.com/${ name } .js` )
32+ ) ;
33+ try {
34+ new FileAttachment ( "filename" ) ;
35+ t . fail ( ) ;
36+ } catch ( error ) {
37+ t . equal ( error . message , "FileAttachment is not a constructor" ) ;
38+ }
39+ t . end ( ) ;
40+ } ) ;
41+
2042test ( "FileAttachment works with Promises that resolve to URLs" , async t => {
21- const fileAttachments = FileAttachments ( async ( name ) =>
43+ const FileAttachment = FileAttachments ( async ( name ) =>
2244 new URL ( `https://example.com/${ name } .js` )
2345 ) ;
24- const file = fileAttachments ( "otherfile" ) ;
46+ const file = FileAttachment ( "otherfile" ) ;
2547 t . equal ( file . constructor . name , "FileAttachment" ) ;
2648 t . equal ( await file . url ( ) , "https://example.com/otherfile.js" ) ;
2749 t . end ( ) ;
0 commit comments