@@ -2,15 +2,20 @@ import { writeFile } from 'fs/promises';
22import {
33 createZipFromObject as legacyCreateZipFromObject ,
44 extractDataSchema as legacyExtractDataSchema ,
5- } from '@iexec/dataprotector/dist/utils/data.js' ; // run `prepare- test-deps ` script before running this test file
6- import { describe , it , beforeAll , expect } from '@jest/globals' ;
5+ } from '@iexec/dataprotector/dist/utils/data.js' ; // run `test:prepare ` script before running this test file
6+ import { describe , it , beforeAll , expect , beforeEach } from '@jest/globals' ;
77import {
88 createZipFromObject ,
99 extractDataSchema ,
1010} from '../../sdk/dist/src/utils/data.js' ;
1111import { IExecDataProtectorDeserializer } from '../src/index.js' ;
1212
1313describe ( 'IExecDataProtectorDeserializer' , ( ) => {
14+ beforeEach ( ( ) => {
15+ // reset env
16+ delete process . env . IEXEC_IN ;
17+ delete process . env . IEXEC_DATASET_FILENAME ;
18+ } ) ;
1419 describe ( 'constructor' , ( ) => {
1520 it ( 'set default protectedDataPath with iexec envs' , ( ) => {
1621 process . env . IEXEC_IN = 'iexec_in' ;
@@ -27,6 +32,15 @@ describe('IExecDataProtectorDeserializer', () => {
2732 expect ( protectedDataDeserializer [ 'mode' ] ) . toBe ( 'optimistic' ) ;
2833 } ) ;
2934 } ) ;
35+ describe ( 'when used without protected data' , ( ) => {
36+ it ( 'getValue() fails to load the data' , async ( ) => {
37+ // process.env.IEXEC_IN = 'iexec_in';
38+ const protectedDataDeserializer = new IExecDataProtectorDeserializer ( ) ;
39+ await expect (
40+ protectedDataDeserializer . getValue ( 'foo' , 'string' )
41+ ) . rejects . toThrow ( Error ( 'Missing protected data' ) ) ;
42+ } ) ;
43+ } ) ;
3044 describe ( 'with a file that is not a protected data' , ( ) => {
3145 it ( 'getValue() fails to load the data' , async ( ) => {
3246 const protectedDataDeserializer = new IExecDataProtectorDeserializer ( {
0 commit comments