@@ -21,15 +21,38 @@ const TEST_FILE_PATH = 'test-data/fileReaderTest.txt'; // Relative to repo root
2121
2222describe ( 'CbuildRunReader' , ( ) => {
2323
24- it ( 'successfully parses a *.cbuild-run.yml file' , async ( ) => {
25- const reader = new CbuildRunReader ( ) ;
26- const contents = await reader . parse ( TEST_CBUILD_RUN_FILE ) ;
27- expect ( contents ) . toMatchSnapshot ( ) ;
24+ describe ( 'Parser' , ( ) => {
25+ it ( 'successfully parses a *.cbuild-run.yml file' , async ( ) => {
26+ const cbuildRunReader = new CbuildRunReader ( ) ;
27+ await expect ( cbuildRunReader . parse ( TEST_CBUILD_RUN_FILE ) ) . resolves . not . toThrow ( ) ;
28+ expect ( cbuildRunReader . hasContents ( ) ) . toBe ( true ) ;
29+ const contents = cbuildRunReader . getContents ( ) ;
30+ expect ( contents ) . toBeDefined ( ) ;
31+ expect ( contents ) . toMatchSnapshot ( ) ;
32+ } ) ;
33+
34+ it ( 'throws if it parses something other than a *.cbuild-run.yml file' , async ( ) => {
35+ const expectedError = / I n v a l i d ' \* \. c b u i l d - r u n \. y m l ' f i l e : .* t e s t - d a t a \/ f i l e R e a d e r T e s t \. t x t / ;
36+ const cbuildRunReader = new CbuildRunReader ( ) ;
37+ await expect ( cbuildRunReader . parse ( TEST_FILE_PATH ) ) . rejects . toThrow ( expectedError ) ;
38+ expect ( cbuildRunReader . hasContents ( ) ) . toBe ( false ) ;
39+ expect ( cbuildRunReader . getContents ( ) ) . toBeUndefined ( ) ;
40+ } ) ;
2841 } ) ;
2942
30- it ( 'throws if it parses something other than a *.cbuild-run.yml file' , async ( ) => {
31- const expectedError = / I n v a l i d ' \* \. c b u i l d - r u n \. y m l ' f i l e : .* t e s t - d a t a \/ f i l e R e a d e r T e s t \. t x t / ;
32- const reader = new CbuildRunReader ( ) ;
33- await expect ( reader . parse ( TEST_FILE_PATH ) ) . rejects . toThrow ( expectedError ) ;
43+ describe ( 'Extract Values' , ( ) => {
44+ let cbuildRunReader : CbuildRunReader ;
45+
46+ beforeAll ( async ( ) => {
47+ cbuildRunReader = new CbuildRunReader ( ) ;
48+ } ) ;
49+
50+ it ( 'returns SVD file path' , async ( ) => {
51+ const expectedSvdFilePaths = [ '/my/pack/root/MyVendor/MyDevice/1.0.0/Debug/SVD/MyDevice_Core0.svd' ] ;
52+ await cbuildRunReader . parse ( TEST_CBUILD_RUN_FILE ) ;
53+ const svdFilePaths = cbuildRunReader . getSvdFilePaths ( '/my/pack/root' ) ;
54+ expect ( svdFilePaths ) . toEqual ( expectedSvdFilePaths ) ;
55+ } ) ;
56+
3457 } ) ;
3558} ) ;
0 commit comments