Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
utils
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
EIT-SWE
ux
utils
Commits
23bd9af4
Commit
23bd9af4
authored
Jan 23, 2020
by
Shane Eckenrode
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update style manager tests
parent
67a37a9e
Pipeline
#78933
passed with stages
in 3 minutes and 54 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
14 deletions
+25
-14
libs/utils/theming/src/lib/style-manager.spec.ts
libs/utils/theming/src/lib/style-manager.spec.ts
+25
-14
No files found.
libs/utils/theming/src/lib/style-manager.spec.ts
View file @
23bd9af4
import
{
HttpClientTestingModule
}
from
'
@angular/common/http/testing
'
;
import
{
inject
,
TestBed
}
from
'
@angular/core/testing
'
;
import
{
StyleManager
}
from
'
./style-manager
'
;
import
{
StyleManager
,
STYLE_MANAGER_CONFIG
}
from
'
./style-manager
'
;
describe
(
'
StyleManager
'
,
()
=>
{
let
styleManager
:
StyleManager
;
...
...
@@ -8,7 +8,17 @@ describe('StyleManager', () => {
beforeEach
(()
=>
TestBed
.
configureTestingModule
({
imports
:
[
HttpClientTestingModule
],
providers
:
[
StyleManager
]
providers
:
[
StyleManager
,
{
provide
:
STYLE_MANAGER_CONFIG
,
useValue
:
[
{
name
:
'
default
'
,
primary
:
'
#ffffff
'
,
isDark
:
false
,
isDefault
:
true
},
{
name
:
'
test
'
,
primary
:
'
#123456
'
,
isDark
:
false
,
isDefault
:
false
},
{
name
:
'
new
'
,
primary
:
'
#000055
'
,
isDark
:
true
,
isDefault
:
false
}
]
}
]
})
);
...
...
@@ -27,30 +37,31 @@ describe('StyleManager', () => {
});
it
(
'
should add stylesheet to head
'
,
()
=>
{
styleManager
.
set
Style
(
'
test
'
,
'
test.css
'
);
const
styleEl
=
document
.
head
.
querySelector
(
'
.style-manager-t
est
'
)
as
HTMLLinkElement
;
styleManager
.
set
CurrentTheme
(
'
test
'
);
const
styleEl
=
document
.
head
.
querySelector
(
'
.style-manager-t
heme
'
)
as
HTMLLinkElement
;
expect
(
styleEl
).
not
.
toBeNull
();
expect
(
styleEl
.
href
.
endsWith
(
'
test.css
'
)).
toBe
(
true
);
});
it
(
'
should change existing stylesheet
'
,
()
=>
{
styleManager
.
set
Style
(
'
test
'
,
'
test.css
'
);
const
styleEl
=
document
.
head
.
querySelector
(
'
.style-manager-t
est
'
)
as
HTMLLinkElement
;
styleManager
.
set
CurrentTheme
(
'
test
'
);
const
styleEl
=
document
.
head
.
querySelector
(
'
.style-manager-t
heme
'
)
as
HTMLLinkElement
;
expect
(
styleEl
).
not
.
toBeNull
();
expect
(
styleEl
.
href
.
endsWith
(
'
test.css
'
)).
toBe
(
true
);
styleManager
.
setStyle
(
'
test
'
,
'
new.css
'
);
expect
(
styleEl
.
href
.
endsWith
(
'
new.css
'
)).
toBe
(
true
);
styleManager
.
setCurrentTheme
(
'
new
'
);
const
styleEl2
=
document
.
head
.
querySelector
(
'
.style-manager-theme
'
)
as
HTMLLinkElement
;
expect
(
styleEl2
.
href
.
endsWith
(
'
new.css
'
)).
toBe
(
true
);
});
it
(
'
should remove
existing
stylesheet
'
,
()
=>
{
styleManager
.
set
Style
(
'
test
'
,
'
test.css
'
);
let
styleEl
=
document
.
head
.
querySelector
(
'
.style-manager-test
'
)
as
HTMLLinkElement
;
it
(
'
should remove
alternate
stylesheet
'
,
()
=>
{
styleManager
.
set
CurrentTheme
(
'
test
'
);
const
styleEl
=
document
.
head
.
querySelector
(
'
.style-manager-theme
'
)
as
HTMLLinkElement
;
expect
(
styleEl
).
not
.
toBeNull
();
expect
(
styleEl
.
href
.
endsWith
(
'
test.css
'
)).
toBe
(
true
);
styleManager
.
removeStyle
(
'
tes
t
'
);
styleEl
=
document
.
head
.
querySelector
(
'
.style-manager-test
'
)
as
HTMLLinkElement
;
expect
(
styleEl
).
toBeNull
();
styleManager
.
setCurrentTheme
(
'
defaul
t
'
);
const
styleEl2
=
document
.
head
.
querySelector
(
'
.style-manager-theme
'
)
as
HTMLLinkElement
;
expect
(
styleEl
2
).
toBeNull
();
});
});
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