forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTurnitinSettingsSpec.coffee
More file actions
136 lines (114 loc) · 4.54 KB
/
Copy pathTurnitinSettingsSpec.coffee
File metadata and controls
136 lines (114 loc) · 4.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#
# Copyright (C) 2013 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
define [
'compiled/models/TurnitinSettings'
], ( TurnitinSettings ) ->
QUnit.module "TurnitinSettings"
QUnit.module "TurnitinSettings#constructor"
test "assigns originalityReportVisibility", ->
ts = new TurnitinSettings originality_report_visibility: 'after_grading'
strictEqual ts.originalityReportVisibility, 'after_grading'
test "assigns sPaperCheck", ->
ts = new TurnitinSettings s_paper_check: true
strictEqual ts.sPaperCheck, true
test "assigns internetCheck", ->
ts = new TurnitinSettings internet_check: true
strictEqual ts.internetCheck, true
test "assigns excludeBiblio", ->
ts = new TurnitinSettings exclude_biblio: false
strictEqual ts.excludeBiblio, false
test "assigns excludeQuoted", ->
ts = new TurnitinSettings exclude_quoted: false
strictEqual ts.excludeQuoted, false
test "assigns journalCheck", ->
ts = new TurnitinSettings journal_check: true
strictEqual ts.journalCheck, true
test "works with '0' and '1' as well", ->
ts = new TurnitinSettings
s_paper_check: '0'
internet_check: '1'
exclude_biblio: '0'
exclude_quoted: '1'
journal_check: '0'
strictEqual ts.sPaperCheck, false
strictEqual ts.internetCheck, true
strictEqual ts.excludeBiblio, false
strictEqual ts.excludeQuoted, true
strictEqual ts.journalCheck, false
test "assigns excludeSmallMatchesType", ->
ts = new TurnitinSettings exclude_small_matches_type: 'words'
strictEqual ts.excludeSmallMatchesType, 'words'
test "assigns excludeSmallMatchesValue", ->
ts = new TurnitinSettings exclude_small_matches_value: 100
strictEqual ts.excludeSmallMatchesValue, 100
test "assigns correct percent", ->
ts = new TurnitinSettings
exclude_small_matches_type: 'words'
exclude_small_matches_value: 100
strictEqual ts.percent(), ""
ts = new TurnitinSettings
exclude_small_matches_type: 'percent'
exclude_small_matches_value: 100
strictEqual ts.percent(), 100
test "assigns correct words", ->
ts = new TurnitinSettings
exclude_small_matches_type: 'words'
exclude_small_matches_value: 100
strictEqual ts.words(), 100
ts = new TurnitinSettings
exclude_small_matches_type: 'percent'
exclude_small_matches_value: 100
strictEqual ts.words(), ""
QUnit.module "TurnitinSettings#toJSON"
test "it converts back to snake_case", ->
options =
exclude_small_matches_value: 100
exclude_small_matches_type: 'words'
journal_check: false
exclude_quoted: false
exclude_biblio: true
internet_check: true
originality_report_visibility: 'after_grading'
s_paper_check: true
submit_papers_to: false
ts = new TurnitinSettings options
deepEqual ts.toJSON(), options
QUnit.module "TurnitinSettings#excludesSmallMatches"
test "returns true when excludeSmallMatchesType is not null", ->
ts = new TurnitinSettings exclude_small_matches_type: 'words'
strictEqual ts.excludesSmallMatches(), true
test "returns false when excludeSmallMatchesType is null", ->
ts = new TurnitinSettings exclude_small_matches_type: null
strictEqual ts.excludesSmallMatches(), false
QUnit.module "TurnitinSettings#present",
setup: ->
@options =
exclude_small_matches_value: 100
exclude_small_matches_type: 'words'
journal_check: false
exclude_quoted: false
exclude_biblio: true
internet_check: true
originality_report_visibility: 'after_grading'
s_paper_check: true
@ts = new TurnitinSettings @options
@view = @ts.present()
test "includes excludesSmallMatches", ->
strictEqual @view.excludesSmallMatches, @ts.excludesSmallMatches()
test "includes all the default fields", ->
for own key,value of @view when key != 'excludesSmallMatches' && key != 'words' && key != 'percent'
strictEqual value, @ts[ key ]