UNPKG

2.23 kBJavaScriptView Raw
1import 'dom4';
2
3import 'angular';
4import 'angular-mocks';
5import {CheckmarkIcon, WarningIcon} from '../icon';
6import styles from '../icon/icon.css';
7
8import Icon from './icon-ng';
9
10const XLINK_NS = 'http://www.w3.org/1999/xlink';
11
12// Temporary turn off until it is not clear how to implement icon-ng inline svg
13describe.skip('Icon Ng', () => {
14 let scope;
15 let element;
16 let $compile;
17
18 beforeEach(window.module(Icon));
19
20 /* global inject */
21 beforeEach(inject(($rootScope, _$compile_) => {
22 scope = $rootScope.$new();
23 scope.icon = CheckmarkIcon;
24 $compile = _$compile_;
25
26 element = $compile(`
27 <rg-icon
28 color="{{color}}"
29 glyph="{{icon}}"
30 loading="loading"
31 ></rg-icon>
32 `)(scope)[0];
33 scope.$digest();
34 }));
35
36 it('should set base class', () => {
37 element.should.match(`rg-icon.${styles.icon}`);
38 });
39
40 it('should contain non-empty use element', () => {
41 // queries like 'use[*|href="#ok"]' do not work in IE
42 element.query('use').getAttributeNS(XLINK_NS, 'href').should.equal(CheckmarkIcon.toString());
43 });
44
45 it('should change use element content', () => {
46 scope.icon = WarningIcon;
47 scope.$digest();
48 element.query('use').getAttributeNS(XLINK_NS, 'href').should.equal(WarningIcon.toString());
49 });
50
51 it('should remove use element content', () => {
52 scope.icon = '';
53 scope.$digest();
54 element.should.not.contain('use[*|href]');
55 });
56
57 it('should not have loading class initially', () => {
58 element.should.not.match(`.${styles.loading}`);
59 });
60
61 it('should set loading class', () => {
62 scope.loading = true;
63 scope.$digest();
64 element.should.match(`.${styles.loading}`);
65 });
66
67 it('should remove loading class', () => {
68 scope.loading = true;
69 scope.$digest();
70 scope.loading = false;
71 scope.$digest();
72 element.should.not.match(`.${styles.loading}`);
73 });
74
75 it('should set color class', () => {
76 scope.color = 'BLUE';
77 scope.$digest();
78 element.should.match(`.${styles.blue}`);
79 });
80
81 it('should remove previous color class', () => {
82 scope.color = 'BLUE';
83 scope.$digest();
84 scope.color = 'MAGENTA';
85 scope.$digest();
86 element.should.not.match('.ring-icon_blue');
87 });
88});