From bb1723fff87f4ca2945d4f3faf4a1b061776c1f2 Mon Sep 17 00:00:00 2001 From: janmax <mail-github@jmx.io> Date: Fri, 10 Nov 2017 19:26:32 +0100 Subject: [PATCH] Finished an example test case for student page --- frontend/test/unit/specs/Hello.spec.js | 16 -------- frontend/test/unit/specs/Login.spec.js | 8 ---- .../test/unit/specs/SubmissionList.spec.js | 38 +++++++++++++++++++ 3 files changed, 38 insertions(+), 24 deletions(-) delete mode 100644 frontend/test/unit/specs/Hello.spec.js delete mode 100644 frontend/test/unit/specs/Login.spec.js create mode 100644 frontend/test/unit/specs/SubmissionList.spec.js diff --git a/frontend/test/unit/specs/Hello.spec.js b/frontend/test/unit/specs/Hello.spec.js deleted file mode 100644 index 4f647728..00000000 --- a/frontend/test/unit/specs/Hello.spec.js +++ /dev/null @@ -1,16 +0,0 @@ -import Vue from 'vue' -import Login from '@/components/Login' - -describe('Login.vue', () => { - it('is doing nothing but ensure that we can test', () => { - data = {"submissions": [ - { - "type": "Aufgabe 01", - "text": "Hallo, was geht denn da?", - "feedback": null, - "score": null, - "full_score": 12 - } - ]} - }) -}) diff --git a/frontend/test/unit/specs/Login.spec.js b/frontend/test/unit/specs/Login.spec.js deleted file mode 100644 index 127bc590..00000000 --- a/frontend/test/unit/specs/Login.spec.js +++ /dev/null @@ -1,8 +0,0 @@ -import Vue from 'vue' -import Login from '@/components/Login' - -describe('Login.vue', () => { - it('is doing nothing but ensure that we can test', () => { - - }) -}) diff --git a/frontend/test/unit/specs/SubmissionList.spec.js b/frontend/test/unit/specs/SubmissionList.spec.js new file mode 100644 index 00000000..784cba56 --- /dev/null +++ b/frontend/test/unit/specs/SubmissionList.spec.js @@ -0,0 +1,38 @@ +import Vue from 'vue' +import SubmissionList from '@/components/student/SubmissionList' + +describe('SubmissionList.vue', () => { + it('tests the SubmissionList for students', () => { + const data = [{ + 'type': 'Aufgabe 01', + 'text': 'I dont know the answer.', + 'feedback': 'I am very disappointed.', + 'score': 5, + 'full_score': 14 + },{ + 'type': 'Aufgabe 01', + 'text': 'A very good solution, indeed', + 'feedback': 'I am still very disappointed.', + 'score': 7, + 'full_score': 10 + }] + + const Constructor = Vue.extend(SubmissionList) + + const comp = new Constructor({ + propsData: { + // Props are passed in "propsData". + submissions: data + } + }).$mount() + + expect(comp.sumScore) + .to.equal(12) + + expect(comp.sumFullScore) + .to.equal(24) + + expect(comp.pointRatio) + .to.equal('50.00') + }) +}) -- GitLab