File tree 5 files changed +231
-190
lines changed
5 files changed +231
-190
lines changed Original file line number Diff line number Diff line change
1
+ name : Tests
2
+
3
+ on :
4
+ push :
5
+ branches : [main]
6
+ pull_request :
7
+ branches : [main]
8
+
9
+ jobs :
10
+ test :
11
+ runs-on : ubuntu-latest
12
+ steps :
13
+ - uses : actions/checkout@v4
14
+ - uses : jdx/mise-action@v2
15
+ - name : Build
16
+ run : npm run build
17
+ - name : Test
18
+ run : npm run test
Original file line number Diff line number Diff line change @@ -61,15 +61,15 @@ ${scriptlets
61
61
62
62
return `
63
63
scriptlets['${ scriptlet . name } '] = {
64
+ aliases: ${ JSON . stringify ( scriptlet . aliases || [ ] ) } ,
65
+ ${ scriptlet . world ? `world: '${ scriptlet . world } ',` : '' }
66
+ requiresTrust: ${ scriptlet . requiresTrust || false } ,
64
67
func: function (...args) {
65
68
const scriptletGlobals = {};
66
69
${ deps . map ( ( dep ) => dep . toString ( ) ) . join ( '\n' ) }
67
70
${ scriptlet . fn . toString ( ) } ;
68
71
${ scriptlet . fn . name } (...args);
69
72
},
70
- aliases: ${ JSON . stringify ( scriptlet . aliases || [ ] ) } ,
71
- ${ scriptlet . world ? `world: '${ scriptlet . world } ',` : '' }
72
- requiresTrust: ${ scriptlet . requiresTrust || false } ,
73
73
};
74
74
` ;
75
75
} )
Original file line number Diff line number Diff line change 1
- import scriptlets from './ubo.js' ;
1
+ import SCRIPTLETS from './ubo.js' ;
2
+
3
+ const scriptlets = { } ;
4
+
5
+ for ( const [ name , scriptlet ] of Object . entries ( SCRIPTLETS ) ) {
6
+ scriptlets [ name ] = scriptlet ;
7
+ for ( const alias of scriptlet . aliases ) {
8
+ scriptlets [ alias ] = scriptlet ;
9
+ }
10
+ }
11
+
2
12
export default scriptlets ;
Original file line number Diff line number Diff line change 1
- import test from "node:test" ;
1
+ import { test , suite } from "node:test" ;
2
2
import assert from "node:assert" ;
3
3
import scriptlets from "./index.js" ;
4
4
@@ -9,7 +9,20 @@ test("default export is an object", () => {
9
9
test ( "each scriptlet has basic properties" , ( ) => {
10
10
for ( const [ name , scriptlet ] of Object . entries ( scriptlets ) ) {
11
11
assert ( name . length > 0 , `${ name } - name is too short` ) ;
12
- assert ( scriptlet . func instanceof Function , `${ name } - func is not have a Function` ) ;
13
- assert ( scriptlet . aliases instanceof Array , `${ name } - aliases is not an Array` ) ;
12
+ assert (
13
+ scriptlet . func instanceof Function ,
14
+ `${ name } - func is not have a Function`
15
+ ) ;
16
+ assert (
17
+ scriptlet . aliases instanceof Array ,
18
+ `${ name } - aliases is not an Array`
19
+ ) ;
14
20
}
15
21
} ) ;
22
+
23
+ suite ( "uBO" , ( ) => {
24
+ test ( "handles aliases" , ( ) => {
25
+ assert ( scriptlets [ "set-constant.js" ] ) ;
26
+ assert . strictEqual ( scriptlets [ "set-constant.js" ] , scriptlets [ "set.js" ] ) ;
27
+ } ) ;
28
+ } ) ;
You can’t perform that action at this time.
0 commit comments