Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kr0nox committed Oct 24, 2023
1 parent ac72e44 commit 47f1ad4
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 1 deletion.
12 changes: 12 additions & 0 deletions report-viewer/tests/unit/components/VersionInfoComponent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,44 @@ vi.mock('@/version.json')
describe('VersionInfoComponent', () => {
it('Render develop version', async () => {
version.report_viewer_version = mockVersionJSON(0, 0, 0)
version.minimal_report_version = mockVersionJSON(4, 0, 0)
global.fetch = vi.fn().mockResolvedValueOnce(mockVersionResponse('v4.3.0'))

const wrapper = mount(VersionInfoComponent)
await flushPromises()

expect(wrapper.text()).toContain('development version')
expect(wrapper.text()).not.toContain(
'The minimal version of JPlag that is supported by the viewer is v4.0.0.'
)
})

it('Render outdated version', async () => {
version.report_viewer_version = mockVersionJSON(4, 3, 0)
version.minimal_report_version = mockVersionJSON(4, 0, 0)
global.fetch = vi.fn().mockResolvedValueOnce(mockVersionResponse('v4.4.0'))

const wrapper = mount(VersionInfoComponent)
await flushPromises()

expect(wrapper.text()).toContain('outdated version')
expect(wrapper.text()).toContain(
'The minimal version of JPlag that is supported by the viewer is v4.0.0.'
)
})

it('Render latest version', async () => {
version.report_viewer_version = mockVersionJSON(4, 3, 0)
version.minimal_report_version = mockVersionJSON(4, 0, 0)
global.fetch = vi.fn().mockResolvedValueOnce(mockVersionResponse('v4.3.0'))

const wrapper = mount(VersionInfoComponent)
await flushPromises()

expect(wrapper.text()).toContain('JPlag v4.3.0')
expect(wrapper.text()).toContain(
'The minimal version of JPlag that is supported by the viewer is v4.0.0.'
)
})
})

Expand Down
73 changes: 73 additions & 0 deletions report-viewer/tests/unit/model/factories/OutdatedOverview.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"jplag_version": { "major": 3, "minor": 0, "patch": 0 },
"submission_folder_path": ["files"],
"base_code_folder_path": "",
"language": "Javac based AST plugin",
"file_extensions": [".java", ".JAVA"],
"submission_id_to_display_name": { "A": "A", "B": "B", "C": "C", "D": "D" },
"submission_ids_to_comparison_file_name": {
"A": { "B": "B-A.json", "C": "A-C.json", "D": "D-A.json" },
"B": { "A": "B-A.json", "C": "B-C.json", "D": "B-D.json" },
"C": { "A": "A-C.json", "B": "B-C.json", "D": "D-C.json" },
"D": { "A": "D-A.json", "B": "B-D.json", "C": "D-C.json" }
},
"failed_submission_names": [],
"excluded_files": [],
"match_sensitivity": 9,
"date_of_execution": "12/07/23",
"execution_time": 12,
"distributions": {
"MAX": [
1, 0, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0
],
"AVG": [
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0
]
},
"top_comparisons": [
{
"first_submission": "A",
"second_submission": "C",
"similarities": { "AVG": 0.9960435212660732, "MAX": 0.9960435212660732 }
},
{
"first_submission": "D",
"second_submission": "A",
"similarities": { "AVG": 0.751044776119403, "MAX": 0.947289156626506 }
},
{
"first_submission": "D",
"second_submission": "C",
"similarities": { "AVG": 0.751044776119403, "MAX": 0.947289156626506 }
},
{
"first_submission": "B",
"second_submission": "D",
"similarities": { "AVG": 0.28322981366459626, "MAX": 0.8085106382978723 }
},
{
"first_submission": "B",
"second_submission": "A",
"similarities": { "AVG": 0.2378472222222222, "MAX": 0.9716312056737588 }
},
{
"first_submission": "B",
"second_submission": "C",
"similarities": { "AVG": 0.2378472222222222, "MAX": 0.9716312056737588 }
}
],
"clusters": [
{
"average_similarity": 94.746956,
"strength": 0.0,
"members": ["C", "A", "B", "D"]
}
],
"total_comparisons": 6
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { HundredValueDistribution } from '@/model/HundredValueDistribution'
import { TenValueDistribution } from '@/model/TenValueDistribution'
import validNew from './ValidNewOverview.json'
import validOld from './ValidOldOverview.json'
import outdated from './OutdatedOverview.json'

const store = {
state: {
Expand Down Expand Up @@ -175,3 +176,10 @@ describe('Test JSON to Overview', () => {
})
})
})

describe('Outdated JSON to Overview', () => {
it('Outdated version', async () => {
store.state.files['overview.json'] = JSON.stringify(outdated)
expect(() => OverviewFactory.getOverview()).rejects.toThrowError()
})
})
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"jplag_version": { "major": 0, "minor": 0, "patch": 0 },
"jplag_version": { "major": 4, "minor": 0, "patch": 0 },
"submission_folder_path": ["files"],
"base_code_folder_path": "",
"language": "Javac based AST plugin",
Expand Down

0 comments on commit 47f1ad4

Please sign in to comment.