kblincoe / VisualGit_SE701_2019_4

1 stars 0 forks source link

refactor service logic into diff service from diff panel component #259

Closed WanniCode closed 5 years ago

WanniCode commented 5 years ago

partially resolves #149

Tested the change on Windows and it seems to work as normal (no changes to UI, just backend): image

Note that because of the missing button for opening local repositories at the time of this PR, testing was done (and should be done) via cloning a repository remotely (i.e. some other way apart from the open local repository button).

Note that only the getLineChangesForFile() method is currently being used by the application, as it replaces what the diff panel component used to update the diff panel (instead it delegates this to the diff service, as it should). It might be especially useful to get some ideas/thoughts on the other two methods which have not been formally tested (see below).

Jest tests are not added alongside this PR since they are expected to be quite large and it would be easier to add them in as necessary in a separate PR. The specifications for how the tests would be written can be given now and are as follows (for each of the 3 methods):

// test getLineChangesForFile()
    // correct output relative to latest commit (default, no commit specified)
    // correct output relative to specified commit () -> this is when this functionality is to be added
    // error/empty when commit specified is invalid, or repo/file paths invalid

// test getFileContent()
     // correct output when no commit specified (should be LATEST commit )
     // correct output when commit specified 
     // empty string when file not exist/commit invalid/repo invalid

// test getAuthorAndLineBlame()
    // correct output when oldest/newest commit bounds not specified 
    // correct output when oldest commit bound specified
    // correct output when newest commit bound specified 
    // empty array returned when input is invalid