-
Notifications
You must be signed in to change notification settings - Fork 194
/
view-switcher-test.js
73 lines (61 loc) · 2.06 KB
/
view-switcher-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
'use strict';
var angular = require('angular');
var util = require('../../directive/test/util');
describe('viewSwitcher', function () {
before(function () {
angular.module('app', [])
.component('viewSwitcher', require('../view-switcher'));
});
beforeEach(function () {
var fakeAnnotationUI = {
getState: sinon.stub().returns({
frames: [
{
// The view switcher only shows after the first batch of
// annotations have been fetched.
isAnnotationFetchComplete: true,
},
],
}),
};
var fakeFeatures = {
flagEnabled: sinon.stub().returns(true),
};
angular.mock.module('app', {
annotationUI: fakeAnnotationUI,
features: fakeFeatures,
});
});
context('displays tabs, counts and selected tab', function () {
it('should display the tabs and counts of annotations and notes', function () {
var elem = util.createDirective(document, 'viewSwitcher', {
selectedTab: 'annotation',
totalAnnotations: '123',
totalNotes: '456',
});
var tabs = elem[0].querySelectorAll('button');
assert.include(tabs[0].textContent, 'Annotations');
assert.include(tabs[1].textContent, 'Notes');
assert.include(tabs[0].textContent, '123');
assert.include(tabs[1].textContent, '456');
});
it('should display annotations tab as selected', function () {
var elem = util.createDirective(document, 'viewSwitcher', {
selectedTab: 'annotation',
totalAnnotations: '123',
totalNotes: '456',
});
var tabs = elem[0].querySelectorAll('button');
assert.isTrue(tabs[0].classList.contains('is-selected'));
});
it('should display notes tab as selected', function () {
var elem = util.createDirective(document, 'viewSwitcher', {
selectedTab: 'note',
totalAnnotations: '123',
totalNotes: '456',
});
var tabs = elem[0].querySelectorAll('button');
assert.isTrue(tabs[1].classList.contains('is-selected'));
});
});
});