1- import * as os from "../src/os " ;
1+ import { getOS } from "../src/core " ;
22
33jest . mock ( "getos" ) ;
44
@@ -8,45 +8,17 @@ describe("os resolver", () => {
88 it ( "finds matching system and version" , async ( ) => {
99 setSystem ( { os : "linux" , dist : "Ubuntu" , release : "22.04" } ) ;
1010
11- let ubuntu = await os . getSystem ( ) ;
12- expect ( ubuntu . os ) . toBe ( os . OS . Ubuntu ) ;
13- expect ( ubuntu . version ) . toBe ( "22.04" ) ;
14- expect ( ubuntu . name ) . toBe ( "Ubuntu" ) ;
11+ let ubuntu = await getOS ( ) ;
12+ expect ( ubuntu ) . toBe ( "linux" ) ;
1513
1614 setSystem ( { os : "darwin" , dist : "macOS" , release : "latest" } ) ;
1715
18- let mac = await os . getSystem ( ) ;
19- expect ( mac . os ) . toBe ( os . OS . MacOS ) ;
20- expect ( mac . version ) . toBe ( "latest" ) ;
21- expect ( mac . name ) . toBe ( "macOS" ) ;
16+ let mac = await getOS ( ) ;
17+ expect ( mac ) . toBe ( "darwin" ) ;
2218
2319 setSystem ( { os : "win32" , dist : "Windows" , release : "latest" } ) ;
2420
25- let windows = await os . getSystem ( ) ;
26- expect ( windows . os ) . toBe ( os . OS . Windows ) ;
27- expect ( windows . version ) . toBe ( "latest" ) ;
28- expect ( windows . name ) . toBe ( "Windows" ) ;
29- } ) ;
30-
31- it ( "throws an error if the os is not supported" , async ( ) => {
32- setSystem ( { os : "windows" , dist : "Microsoft Windows 10" , release : "10.0" } ) ;
33- expect . assertions ( 1 ) ;
34- try {
35- await os . getSystem ( ) ;
36- } catch ( e ) {
37- expect ( e ) . toEqual ( new Error ( '"windows" is not a supported platform' ) ) ;
38- }
39- } ) ;
40-
41- it ( "throws an error if the version is not supported" , async ( ) => {
42- setSystem ( { os : "linux" , dist : "Ubuntu" , release : "15.04" } ) ;
43- expect . assertions ( 1 ) ;
44- try {
45- await os . getSystem ( ) ;
46- } catch ( e ) {
47- expect ( e ) . toEqual (
48- new Error ( 'Version "15.04" of Ubuntu is not supported' )
49- ) ;
50- }
21+ let windows = await getOS ( ) ;
22+ expect ( windows ) . toBe ( "win32" ) ;
5123 } ) ;
5224} ) ;
0 commit comments