Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
arsnova-click-v2-frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
ARSnova
arsnova-click-v2-frontend
Commits
9dfc1f2f
Commit
9dfc1f2f
authored
Dec 03, 2019
by
Christopher Fullarton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds more tests
parent
392b98a8
Pipeline
#34622
passed with stages
in 14 minutes and 39 seconds
Changes
13
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
228 additions
and
19 deletions
+228
-19
karma.conf.js
karma.conf.js
+1
-1
QuizAdminFilterPipeMock.ts
src/_mocks/QuizAdminFilterPipeMock.ts
+10
-0
quiz.mock.ts
src/_mocks/_fixtures/quiz.mock.ts
+16
-0
admin.module.spec.ts
src/app/admin/admin.module.spec.ts
+13
-0
quiz-admin.component.html
src/app/admin/quiz-admin/quiz-admin.component.html
+2
-2
quiz-admin.component.spec.ts
src/app/admin/quiz-admin/quiz-admin.component.spec.ts
+37
-12
quiz-admin.component.ts
src/app/admin/quiz-admin/quiz-admin.component.ts
+1
-1
quiz-details-admin.component.spec.ts
...n/quiz-details-admin/quiz-details-admin.component.spec.ts
+24
-0
quiz-details-admin.component.ts
.../admin/quiz-details-admin/quiz-details-admin.component.ts
+1
-1
attendee.spec.ts
src/app/lib/attendee/attendee.spec.ts
+33
-0
attendee.ts
src/app/lib/attendee/attendee.ts
+1
-0
countdown.spec.ts
src/app/lib/countdown/countdown.spec.ts
+29
-0
admin-api.service.spec.ts
src/app/service/api/admin/admin-api.service.spec.ts
+60
-2
No files found.
karma.conf.js
View file @
9dfc1f2f
...
...
@@ -17,7 +17,7 @@ module.exports = function (config) {
captureConsole
:
false
},
coverageIstanbulReporter
:
{
dir
:
require
(
'
path
'
).
join
(
__dirname
,
'
../
coverage
'
),
dir
:
require
(
'
path
'
).
join
(
__dirname
,
'
coverage
'
),
reports
:
[
'
html
'
,
'
lcovonly
'
,
'
text-summary
'
],
fixWebpackSourcePaths
:
true
},
...
...
src/_mocks/QuizAdminFilterPipeMock.ts
0 → 100644
View file @
9dfc1f2f
import
{
Pipe
,
PipeTransform
}
from
'
@angular/core
'
;
@
Pipe
({
name
:
'
quizAdminFilter
'
,
})
export
class
QuizAdminFilterPipeMock
implements
PipeTransform
{
public
transform
(
value
:
any
,
...
args
):
any
{
return
value
;
}
}
src/_mocks/_fixtures/quiz.mock.ts
0 → 100644
View file @
9dfc1f2f
import
{
QuizEntity
}
from
'
../../app/lib/entities/QuizEntity
'
;
import
{
QuizState
}
from
'
../../app/lib/enums/QuizState
'
;
import
{
QuizVisibility
}
from
'
../../app/lib/enums/QuizVisibility
'
;
export
const
QuizMock
:
QuizEntity
=
new
QuizEntity
({
currentQuestionIndex
:
0
,
currentStartTimestamp
:
0
,
description
:
''
,
expiry
:
undefined
,
memberGroups
:
undefined
,
questionList
:
undefined
,
sessionConfig
:
undefined
,
state
:
QuizState
.
Active
,
visibility
:
QuizVisibility
.
Account
,
name
:
'
quiz-test
'
,
});
src/app/admin/admin.module.spec.ts
0 → 100644
View file @
9dfc1f2f
import
{
AdminModule
}
from
'
./admin.module
'
;
describe
(
'
AdminModule
'
,
()
=>
{
let
adminModule
:
AdminModule
;
beforeEach
(()
=>
{
adminModule
=
new
AdminModule
();
});
it
(
'
should create an instance
'
,
()
=>
{
expect
(
adminModule
).
toBeTruthy
();
});
});
src/app/admin/quiz-admin/quiz-admin.component.html
View file @
9dfc1f2f
...
...
@@ -65,7 +65,7 @@
class=
"d-flex"
>
<fa-icon
[icon]=
"'times'"
class=
"cursor-pointer"
(click)=
"deleteElem(
$event,
quiz)"
></fa-icon>
(click)=
"deleteElem(quiz)"
></fa-icon>
<a
class=
"nav-link text-dark p-0 ml-3"
[routerLink]=
"['/admin', 'quiz', quiz.id]"
>
<fa-icon
class=
"cursor-pointer"
...
...
@@ -107,4 +107,4 @@
</div>
</div>
</div>
</div>
\ No newline at end of file
</div>
src/app/admin/quiz-admin/quiz-admin.component.spec.ts
View file @
9dfc1f2f
import
{
HttpClientTestingModule
}
from
'
@angular/common/http/testing
'
;
import
{
P
ipe
,
PipeTransform
,
P
LATFORM_ID
}
from
'
@angular/core
'
;
import
{
PLATFORM_ID
}
from
'
@angular/core
'
;
import
{
async
,
ComponentFixture
,
TestBed
}
from
'
@angular/core/testing
'
;
import
{
RouterTestingModule
}
from
'
@angular/router/testing
'
;
import
{
JWT_OPTIONS
,
JwtHelperService
,
JwtModule
}
from
'
@auth0/angular-jwt
'
;
import
{
TranslateService
}
from
'
@ngx-translate/core
'
;
import
{
RxStompService
}
from
'
@stomp/ng2-stompjs
'
;
import
{
Observable
,
of
}
from
'
rxjs
'
;
import
{
QuizMock
}
from
'
../../../_mocks/_fixtures/quiz.mock
'
;
import
{
QuizAdminFilterPipeMock
}
from
'
../../../_mocks/QuizAdminFilterPipeMock
'
;
import
{
TranslateServiceMock
}
from
'
../../../_mocks/TranslateServiceMock
'
;
import
{
QuizState
}
from
'
../../lib/enums/QuizState
'
;
import
{
jwtOptionsFactory
}
from
'
../../lib/jwt.factory
'
;
import
{
AdminApiService
}
from
'
../../service/api/admin/admin-api.service
'
;
import
{
ConnectionMockService
}
from
'
../../service/connection/connection.mock.service
'
;
import
{
ConnectionService
}
from
'
../../service/connection/connection.service
'
;
import
{
FooterBarService
}
from
'
../../service/footer-bar/footer-bar.service
'
;
...
...
@@ -25,16 +30,6 @@ import { UserService } from '../../service/user/user.service';
import
{
SharedModule
}
from
'
../../shared/shared.module
'
;
import
{
QuizAdminComponent
}
from
'
./quiz-admin.component
'
;
@
Pipe
({
name
:
'
quizAdminFilter
'
,
})
class
QuizAdminFilterPipeMock
implements
PipeTransform
{
public
transform
(
value
:
any
,
...
args
):
any
{
return
value
;
}
}
describe
(
'
QuizAdminComponent
'
,
()
=>
{
let
component
:
QuizAdminComponent
;
let
fixture
:
ComponentFixture
<
QuizAdminComponent
>
;
...
...
@@ -70,7 +65,20 @@ describe('QuizAdminComponent', () => {
},
SharedService
,
{
provide
:
UserService
,
useValue
:
{},
},
JwtHelperService
,
},
JwtHelperService
,
{
provide
:
AdminApiService
,
useValue
:
{
getAvailableQuizzes
:
()
=>
of
([{
...
QuizMock
}]),
deactivateQuiz
:
()
=>
new
Observable
(
subscriber
=>
{
subscriber
.
next
();
subscriber
.
complete
();
}),
deleteQuiz
:
()
=>
new
Observable
(
subscriber
=>
{
subscriber
.
next
();
subscriber
.
complete
();
}),
},
},
],
declarations
:
[
QuizAdminFilterPipeMock
,
QuizAdminComponent
,
...
...
@@ -87,4 +95,21 @@ describe('QuizAdminComponent', () => {
it
(
'
should create
'
,
()
=>
{
expect
(
component
).
toBeTruthy
();
});
it
(
'
should check if a quiz has a state considered as "active"
'
,
()
=>
{
expect
(
component
.
isActiveQuiz
(
component
.
quizzes
[
0
])).
toBeTruthy
();
component
.
quizzes
[
0
].
state
=
QuizState
.
Inactive
;
expect
(
component
.
isActiveQuiz
(
component
.
quizzes
[
0
])).
toBeFalsy
();
});
it
(
'
should deactivate a quiz
'
,
()
=>
{
expect
(
component
.
isActiveQuiz
(
component
.
quizzes
[
0
])).
toBeTruthy
();
component
.
deactivateQuiz
(
component
.
quizzes
[
0
]);
expect
(
component
.
isActiveQuiz
(
component
.
quizzes
[
0
])).
toBeFalsy
();
});
it
(
'
should delete a quiz
'
,
()
=>
{
component
.
deleteElem
(
component
.
quizzes
[
0
]);
expect
(
component
.
quizzes
.
length
).
toEqual
(
0
);
});
});
src/app/admin/quiz-admin/quiz-admin.component.ts
View file @
9dfc1f2f
...
...
@@ -50,7 +50,7 @@ export class QuizAdminComponent implements OnInit {
return
this
.
_deletingElements
.
indexOf
(
quiz
.
name
)
>
-
1
;
}
public
deleteElem
(
$event
:
Event
,
quiz
:
IAdminQuiz
):
void
{
public
deleteElem
(
quiz
:
IAdminQuiz
):
void
{
const
index
=
this
.
_deletingElements
.
push
(
quiz
.
name
)
-
1
;
this
.
adminApiService
.
deleteQuiz
(
quiz
.
name
).
subscribe
(()
=>
{
this
.
_deletingElements
.
splice
(
index
,
1
);
...
...
src/app/admin/quiz-details-admin/quiz-details-admin.component.spec.ts
View file @
9dfc1f2f
import
{
HttpClientTestingModule
}
from
'
@angular/common/http/testing
'
;
import
{
async
,
ComponentFixture
,
TestBed
}
from
'
@angular/core/testing
'
;
import
{
RouterTestingModule
}
from
'
@angular/router/testing
'
;
import
{
AbstractQuestionEntity
}
from
'
../../lib/entities/question/AbstractQuestionEntity
'
;
import
{
SurveyQuestionEntity
}
from
'
../../lib/entities/question/SurveyQuestionEntity
'
;
import
{
FooterBarService
}
from
'
../../service/footer-bar/footer-bar.service
'
;
import
{
UserService
}
from
'
../../service/user/user.service
'
;
import
{
QuizDetailsAdminComponent
}
from
'
./quiz-details-admin.component
'
;
...
...
@@ -37,4 +39,26 @@ describe('QuizDetailsAdminComponent', () => {
it
(
'
should create
'
,
()
=>
{
expect
(
component
).
toBeTruthy
();
});
it
(
'
should select "general" as default viewed info tab
'
,
()
=>
{
expect
(
component
[
'
_isSelected
'
]).
toEqual
(
'
general
'
);
});
it
(
'
should select "questions" as currently viewed info tab
'
,
()
=>
{
component
.
select
(
'
questions
'
);
expect
(
component
[
'
_isSelected
'
]).
toEqual
(
'
questions
'
);
});
it
(
'
should should check if a value is set (not null or undefined)
'
,
()
=>
{
expect
(
component
.
isSet
(
null
)).
toBeFalsy
();
expect
(
component
.
isSet
(
undefined
)).
toBeFalsy
();
expect
(
component
.
isSet
(
0
)).
toBeTruthy
();
expect
(
component
.
isSet
(
''
)).
toBeTruthy
();
expect
(
component
.
isSet
(
true
)).
toBeTruthy
();
});
it
(
'
should convert the type of a question to a SurveyQuestion
'
,
()
=>
{
const
question
=
{}
as
AbstractQuestionEntity
;
expect
(
component
.
getQuestionAsSurvey
(
question
)).
toEqual
(
question
as
unknown
as
SurveyQuestionEntity
);
});
});
src/app/admin/quiz-details-admin/quiz-details-admin.component.ts
View file @
9dfc1f2f
...
...
@@ -41,7 +41,7 @@ export class QuizDetailsAdminComponent implements OnInit {
}
public
isSet
(
value
:
any
):
boolean
{
return
!
[
'
undefined
'
,
'
null
'
].
includes
(
typeof
value
)
;
return
value
!==
null
&&
typeof
value
!==
'
undefined
'
;
}
public
getQuestionAsSurvey
(
question
:
AbstractQuestionEntity
):
SurveyQuestionEntity
{
...
...
src/app/lib/attendee/attendee.spec.ts
0 → 100644
View file @
9dfc1f2f
import
{
IMemberSerialized
}
from
'
../interfaces/entities/Member/IMemberSerialized
'
;
import
{
Attendee
}
from
'
./attendee
'
;
describe
(
'
Attendee
'
,
()
=>
{
let
attendee
:
Attendee
;
const
member
:
IMemberSerialized
=
{
id
:
'
id
'
,
colorCode
:
'
colorCode
'
,
currentQuizName
:
'
test-quiz
'
,
groupName
:
'
groupName
'
,
name
:
'
string
'
,
responses
:
[],
ticket
:
'
ticket
'
,
};
beforeEach
(()
=>
{
attendee
=
new
Attendee
(
member
);
});
it
(
'
should create
'
,
()
=>
{
expect
(
attendee
).
toBeTruthy
();
});
it
(
'
should set all correct properties of the attendee
'
,
()
=>
{
expect
(
attendee
.
id
).
toEqual
(
member
.
id
);
expect
(
attendee
.
colorCode
).
toEqual
(
member
.
colorCode
);
expect
(
attendee
.
currentQuizName
).
toEqual
(
member
.
currentQuizName
);
expect
(
attendee
.
groupName
).
toEqual
(
member
.
groupName
);
expect
(
attendee
.
name
).
toEqual
(
member
.
name
);
expect
(
attendee
.
responses
).
toEqual
(
member
.
responses
);
expect
(
attendee
.
ticket
).
toEqual
(
member
.
ticket
);
});
});
src/app/lib/attendee/attendee.ts
View file @
9dfc1f2f
...
...
@@ -79,6 +79,7 @@ export class Attendee implements IMemberSerialized {
this
.
_id
=
member
.
id
;
this
.
_name
=
member
.
name
;
this
.
_groupName
=
member
.
groupName
;
this
.
_currentQuizName
=
member
.
currentQuizName
;
this
.
_colorCode
=
member
.
colorCode
;
this
.
_responses
=
member
.
responses
||
[];
this
.
_ticket
=
member
.
ticket
;
...
...
src/app/lib/countdown/countdown.spec.ts
0 → 100644
View file @
9dfc1f2f
import
{
Countdown
}
from
'
./countdown
'
;
describe
(
'
Countdown
'
,
()
=>
{
let
countdown
:
Countdown
;
beforeEach
(()
=>
{
countdown
=
new
Countdown
(
10
);
});
it
(
'
should create
'
,
()
=>
{
expect
(
countdown
).
toBeTruthy
();
});
it
(
'
should run the countdown
'
,
done
=>
{
expect
(
countdown
.
isRunning
).
toBeTruthy
();
countdown
.
onChange
.
subscribe
(
val
=>
{
expect
(
countdown
.
remainingTime
).
toEqual
(
val
);
clearInterval
(
countdown
[
'
_interval
'
]);
done
();
});
});
it
(
'
should stop the countdown
'
,
()
=>
{
countdown
.
stop
();
expect
(
countdown
.
remainingTime
).
toEqual
(
0
);
expect
(
countdown
.
isRunning
).
toEqual
(
false
);
expect
(
countdown
.
hasFinished
).
toEqual
(
true
);
});
});
src/app/service/api/admin/admin-api.service.spec.ts
View file @
9dfc1f2f
import
{
HttpClient
}
from
'
@angular/common/http
'
;
import
{
HttpClientTestingModule
}
from
'
@angular/common/http/testing
'
;
import
{
PLATFORM_ID
}
from
'
@angular/core
'
;
import
{
TestBed
}
from
'
@angular/core/testing
'
;
import
{
RouterTestingModule
}
from
'
@angular/router/testing
'
;
import
{
JWT_OPTIONS
,
JwtHelperService
,
JwtModule
}
from
'
@auth0/angular-jwt
'
;
import
{
of
}
from
'
rxjs
'
;
import
{
jwtOptionsFactory
}
from
'
../../../lib/jwt.factory
'
;
import
{
StorageService
}
from
'
../../storage/storage.service
'
;
import
{
UserService
}
from
'
../../user/user.service
'
;
...
...
@@ -24,8 +26,7 @@ describe('AdminApiService', () => {
{
provide
:
UserService
,
useValue
:
{},
},
JwtHelperService
,
},
JwtHelperService
,
],
});
});
...
...
@@ -34,4 +35,61 @@ describe('AdminApiService', () => {
const
service
:
AdminApiService
=
TestBed
.
get
(
AdminApiService
);
expect
(
service
).
toBeTruthy
();
});
it
(
'
#getAvailableUsers
'
,
()
=>
{
const
service
:
AdminApiService
=
TestBed
.
get
(
AdminApiService
);
const
http
:
HttpClient
=
TestBed
.
get
(
HttpClient
);
spyOn
(
http
,
'
get
'
).
and
.
callFake
(()
=>
of
(
null
));
service
.
getAvailableUsers
();
expect
(
http
.
get
).
toHaveBeenCalledWith
(
service
[
'
_getAvailableUsersUrl
'
],
{
headers
:
{
authorization
:
undefined
}
});
});
it
(
'
#getAvailableQuizzes
'
,
()
=>
{
const
service
:
AdminApiService
=
TestBed
.
get
(
AdminApiService
);
const
http
:
HttpClient
=
TestBed
.
get
(
HttpClient
);
spyOn
(
http
,
'
get
'
).
and
.
callFake
(()
=>
of
(
null
));
service
.
getAvailableQuizzes
();
expect
(
http
.
get
).
toHaveBeenCalledWith
(
service
[
'
_getAvailableQuizzesUrl
'
],
{
headers
:
{
authorization
:
undefined
}
});
});
it
(
'
#deleteQuiz
'
,
()
=>
{
const
service
:
AdminApiService
=
TestBed
.
get
(
AdminApiService
);
const
http
:
HttpClient
=
TestBed
.
get
(
HttpClient
);
spyOn
(
http
,
'
delete
'
).
and
.
callFake
(()
=>
of
(
null
));
service
.
deleteQuiz
(
'
test-quiz
'
);
expect
(
http
.
delete
).
toHaveBeenCalledWith
(
service
[
'
_deleteQuizUrl
'
]
+
'
/test-quiz
'
,
{
headers
:
{
authorization
:
undefined
}
});
});
it
(
'
#deleteUser
'
,
()
=>
{
const
service
:
AdminApiService
=
TestBed
.
get
(
AdminApiService
);
const
http
:
HttpClient
=
TestBed
.
get
(
HttpClient
);
spyOn
(
http
,
'
delete
'
).
and
.
callFake
(()
=>
of
(
null
));
service
.
deleteUser
(
'
test-user
'
);
expect
(
http
.
delete
).
toHaveBeenCalledWith
(
service
[
'
_deleteUserUrl
'
]
+
'
/test-user
'
,
{
headers
:
{
authorization
:
undefined
}
});
});
it
(
'
#updateUser
'
,
()
=>
{
const
service
:
AdminApiService
=
TestBed
.
get
(
AdminApiService
);
const
http
:
HttpClient
=
TestBed
.
get
(
HttpClient
);
spyOn
(
http
,
'
put
'
).
and
.
callFake
(()
=>
of
(
null
));
const
newUser
=
{};
service
.
updateUser
(
newUser
);
expect
(
http
.
put
).
toHaveBeenCalledWith
(
service
[
'
_putUserUrl
'
],
newUser
,
{
headers
:
{
authorization
:
undefined
}
});
});
it
(
'
#getQuiz
'
,
()
=>
{
const
service
:
AdminApiService
=
TestBed
.
get
(
AdminApiService
);
const
http
:
HttpClient
=
TestBed
.
get
(
HttpClient
);
spyOn
(
http
,
'
get
'
).
and
.
callFake
(()
=>
of
(
null
));
service
.
getQuiz
(
'
test-quiz
'
);
expect
(
http
.
get
).
toHaveBeenCalledWith
(
service
[
'
_getQuizUrl
'
]
+
'
/test-quiz
'
,
{
headers
:
{
authorization
:
undefined
}
});
});
it
(
'
#deactivateQuiz
'
,
()
=>
{
const
service
:
AdminApiService
=
TestBed
.
get
(
AdminApiService
);
const
http
:
HttpClient
=
TestBed
.
get
(
HttpClient
);
spyOn
(
http
,
'
post
'
).
and
.
callFake
(()
=>
of
(
null
));
service
.
deactivateQuiz
(
'
test-quiz
'
);
expect
(
http
.
post
).
toHaveBeenCalledWith
(
service
[
'
_postQuizDeactivateUrl
'
],
{
quizname
:
'
test-quiz
'
},
{
headers
:
{
authorization
:
undefined
}
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment