-
Notifications
You must be signed in to change notification settings - Fork 404
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(tests): add directive-styles tests
- Loading branch information
1 parent
2c9097d
commit 16d0366
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
projects/cdk/services/test/directive-styles.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import {TuiDirectiveStylesService} from '../directive-styles.service'; | ||
|
||
describe('TuiDirectiveStylesService service', () => { | ||
it('does nothing with renderer if there is no head.querySelector', () => { | ||
let called = 0; | ||
const stub: any = { | ||
head: { | ||
querySelector: () => ++called, | ||
}, | ||
}; | ||
|
||
const service = new TuiDirectiveStylesService(stub, null as any); | ||
|
||
service.addStyle('test', 'test'); | ||
|
||
expect(called).toBe(1); | ||
}); | ||
|
||
it('add styles to renderer', () => { | ||
let called = 0; | ||
|
||
const rendererStub: any = { | ||
createElement: () => document.createElement('div'), | ||
setProperty: () => ++called, | ||
setAttribute: () => ++called, | ||
}; | ||
|
||
const service = new TuiDirectiveStylesService(document, rendererStub); | ||
|
||
service.addStyle('p { color: black; }', 'test'); | ||
|
||
expect(called).toBe(2); | ||
}); | ||
}); |