Skip to content

Commit

Permalink
chore(tests): add directive-styles tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MarsiBarsi committed Oct 12, 2020
1 parent 2c9097d commit 16d0366
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions projects/cdk/services/test/directive-styles.service.spec.ts
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);
});
});

0 comments on commit 16d0366

Please sign in to comment.