33const path = require ( 'path' ) ;
44const fs = require ( 'fs-extra' ) ;
55const utils = require ( 'lib/server-utils' ) ;
6+ const { getShortMD5} = require ( 'lib/gui/tool-runner-factory/hermione/utils' ) ;
67
78describe ( 'server-utils' , ( ) => {
9+ const sandbox = sinon . sandbox . create ( ) ;
10+
11+ afterEach ( ( ) => sandbox . restore ( ) ) ;
12+
813 [
914 { name : 'Reference' , prefix : 'ref' } ,
1015 { name : 'Current' , prefix : 'current' } ,
@@ -47,14 +52,10 @@ describe('server-utils', () => {
4752 } ) ;
4853
4954 describe ( `get${ testData . name } AbsolutePath` , ( ) => {
50- const sandbox = sinon . sandbox . create ( ) ;
51-
5255 beforeEach ( ( ) => {
5356 sandbox . stub ( process , 'cwd' ) . returns ( '/root' ) ;
5457 } ) ;
5558
56- afterEach ( ( ) => sandbox . restore ( ) ) ;
57-
5859 it ( 'should generate correct absolute path for test image' , ( ) => {
5960 const test = {
6061 imageDir : 'some/dir' ,
@@ -80,10 +81,6 @@ describe('server-utils', () => {
8081 } ) ;
8182
8283 describe ( 'prepareCommonJSData' , ( ) => {
83- const sandbox = sinon . sandbox . create ( ) ;
84-
85- afterEach ( ( ) => sandbox . restore ( ) ) ;
86-
8784 it ( 'should wrap passed data with commonjs wrapper' , ( ) => {
8885 const result = utils . prepareCommonJSData ( { some : 'data' } ) ;
8986
@@ -103,15 +100,11 @@ describe('server-utils', () => {
103100 } ) ;
104101
105102 describe ( 'copyImageAsync' , ( ) => {
106- const sandbox = sinon . sandbox . create ( ) ;
107-
108103 beforeEach ( ( ) => {
109104 sandbox . stub ( fs , 'copy' ) . resolves ( ) ;
110105 sandbox . stub ( fs , 'mkdirs' ) . resolves ( ) ;
111106 } ) ;
112107
113- afterEach ( ( ) => sandbox . restore ( ) ) ;
114-
115108 it ( 'should create directory and copy image' , ( ) => {
116109 const fromPath = '/from/image.png' ,
117110 toPath = '/to/image.png' ;
@@ -123,4 +116,14 @@ describe('server-utils', () => {
123116 } ) ;
124117 } ) ;
125118 } ) ;
119+
120+ describe ( 'getDetailsFileName' , ( ) => {
121+ it ( 'should compose correct file name from suite path, browser id and attempt' , ( ) => {
122+ sandbox . stub ( Date , 'now' ) . returns ( '123456789' ) ;
123+ const suitePath = [ 'root-title' , 'some-title' ] ;
124+ const expected = `${ getShortMD5 ( 'root-title some-title' ) } -bro_2_123456789.json` ;
125+
126+ assert . equal ( utils . getDetailsFileName ( suitePath , 'bro' , 1 ) , expected ) ;
127+ } ) ;
128+ } ) ;
126129} ) ;
0 commit comments