Browse Source

test(core): add dom-insertion.service.spec

pull/3475/head
mehmet-erim 7 years ago
parent
commit
3b1fa3ba3d
  1. 8
      npm/ng-packs/packages/core/src/lib/tests/content-security.strategy.spec.ts
  2. 15
      npm/ng-packs/packages/core/src/lib/tests/dom-insertion.service.spec.ts
  3. 2
      npm/ng-packs/packages/theme-shared/src/lib/tests/append-content.token.spec.ts

8
npm/ng-packs/packages/core/src/lib/tests/content-security.strategy.spec.ts

@ -18,7 +18,7 @@ describe('LooseContentSecurityStrategy', () => {
}); });
}); });
describe('StrictContentSecurityStrategy', () => { describe('NoContentSecurityStrategy', () => {
describe('#applyCSP', () => { describe('#applyCSP', () => {
it('should not set nonce attribute', () => { it('should not set nonce attribute', () => {
const strategy = new NoContentSecurityStrategy(); const strategy = new NoContentSecurityStrategy();
@ -32,9 +32,9 @@ describe('StrictContentSecurityStrategy', () => {
describe('CONTENT_SECURITY_STRATEGY', () => { describe('CONTENT_SECURITY_STRATEGY', () => {
test.each` test.each`
name | Strategy | nonce name | Strategy | nonce
${'Loose'} | ${LooseContentSecurityStrategy} | ${uuid()} ${'Loose'} | ${LooseContentSecurityStrategy} | ${uuid()}
${'Strict'} | ${NoContentSecurityStrategy} | ${undefined} ${'None'} | ${NoContentSecurityStrategy} | ${undefined}
`('should successfully map $name to $Strategy.name', ({ name, Strategy, nonce }) => { `('should successfully map $name to $Strategy.name', ({ name, Strategy, nonce }) => {
expect(CONTENT_SECURITY_STRATEGY[name](nonce)).toEqual(new Strategy(nonce)); expect(CONTENT_SECURITY_STRATEGY[name](nonce)).toEqual(new Strategy(nonce));
}); });

15
npm/ng-packs/packages/core/src/lib/tests/dom-insertion.service.spec.ts

@ -0,0 +1,15 @@
import { createServiceFactory, SpectatorService } from '@ngneat/spectator';
import { DomInsertionService } from '../services';
import { CONTENT_STRATEGY } from '../strategies';
describe('DomInsertionService', () => {
let spectator: SpectatorService<DomInsertionService>;
const createService = createServiceFactory(DomInsertionService);
beforeEach(() => (spectator = createService()));
it('should be insert an element', () => {
spectator.service.insertElement(CONTENT_STRATEGY.AppendStyleToHead('.test {}'));
expect(spectator.service.inserted.has(1437348290)).toBe(true);
});
});

2
npm/ng-packs/packages/theme-shared/src/lib/tests/append-content.token.spec.ts

@ -23,5 +23,7 @@ describe('AppendContentToken', () => {
expect(loaded).toBe(true); expect(loaded).toBe(true);
done(); done();
}); });
spectator.get(THEME_SHARED_APPEND_CONTENT);
}); });
}); });

Loading…
Cancel
Save