Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 4.89 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3.   <head>
  4.     <meta charset="utf-8" />
  5.     <meta name="viewport" content="width=device-width, initial-scale=1" />
  6.  
  7.     <title>bbva-branch-navigation test</title>
  8.     <script src="../node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>
  9.     <script src="../node_modules/mocha/mocha.js"></script>
  10.     <script src="../node_modules/wct-mocha/wct-mocha.js"></script>
  11.     <script src="../node_modules/chai/chai.js"></script>
  12.     <script src="../node_modules/sinon/pkg/sinon.js"></script>
  13.     <script src="../node_modules/@polymer/test-fixture/test-fixture.js"></script>
  14.     <script src="../node_modules/sinon-chai/lib/sinon-chai.js"></script>
  15.   </head>
  16.  
  17.   <body>
  18.     <test-fixture id="default">
  19.       <template>
  20.         <bbva-branch-navigation
  21.          title="Link 0"
  22.          links='[{"href":"http://www.google.es/","title":"link1","text":"Link1"},{"href":"http://www.google.es/","title":"link2","text":"Link2"}]'
  23.        ></bbva-branch-navigation>
  24.       </template>
  25.     </test-fixture>
  26.     <test-fixture id="opened">
  27.       <template>
  28.         <bbva-branch-navigation
  29.          title="Link 0"
  30.          links='[{"href":"http://www.google.es/","title":"link1","text":"Link1"},{"href":"http://www.google.es/","title":"link2","text":"Link2"}]'
  31.          always-open
  32.        ></bbva-branch-navigation>
  33.       </template>
  34.     </test-fixture>
  35.  
  36.     <script type="module">
  37.       import './test.js';
  38.       suite('bbva-branch-navigation', () => {
  39.         let el, elOpened;
  40.  
  41.         setup(async () => {
  42.           el = fixture('default');
  43.           elOpened = fixture('opened');
  44.  
  45.           return await elOpened.updateComplete;
  46.         });
  47.  
  48.         test('Asserting attribute "title" is in the header > span.', () => {
  49.           const span = el.shadowRoot.querySelector('header > span');
  50.           assert.equal(span.innerText, 'Link 0');
  51.         });
  52.  
  53.         test('Asserting attribute "aria-hidden" is true or false when header\'s drop down is clicked.', async () => {
  54.           const link = el.shadowRoot.querySelector('header');
  55.           const dropDown = el.shadowRoot.querySelector('cells-collapse');
  56.           assert.equal(dropDown.getAttribute('aria-hidden'), 'true');
  57.           link.click();
  58.           await el.updateComplete;
  59.           assert.equal(dropDown.getAttribute('aria-hidden'), 'false');
  60.         });
  61.  
  62.         test('Asserting collapsible has attribute "always-open" and is open, so never will be closed.', async () => {
  63.           const link = elOpened.shadowRoot.querySelector('header');
  64.           const dropDown = elOpened.shadowRoot.querySelector('cells-collapse');
  65.           assert.equal(dropDown.getAttribute('aria-hidden'), 'false');
  66.           link.click();
  67.           await elOpened.updateComplete;
  68.           assert.equal(dropDown.getAttribute('aria-hidden'), 'false');
  69.         });
  70.  
  71.         test('Asserting the collapsible is opened when the method "open" is called. And it is closed, when method "close" is called.', async () => {
  72.           const dropDown = el.shadowRoot.querySelector('cells-collapse');
  73.           assert.equal(dropDown.getAttribute('aria-hidden'), 'true');
  74.           el.open();
  75.           await el.updateComplete;
  76.           assert.equal(dropDown.getAttribute('aria-hidden'), 'false');
  77.           el.close();
  78.           await el.updateComplete;
  79.           assert.equal(dropDown.getAttribute('aria-hidden'), 'true');
  80.         });
  81.  
  82.  
  83.  
  84.         test('checks property opened is set to true at the beginning', () => {
  85.           const opened = elOpened.opened;
  86.           assert.isTrue(opened)
  87.         });
  88.  
  89.         test('checks property collapsed is set to true at the beginning', () => {
  90.           const collapsed = elOpened.collapsed;
  91.           assert.isTrue(collapsed)
  92.         });
  93.  
  94.         test('checks property collapsed is set to false', () => {
  95.           const collapsed = elOpened.collapsed = false;
  96.           assert.isFalse(collapsed)
  97.         });
  98.  
  99.  
  100.         test('checks property opened is set to false at the beginning', () => {
  101.           const opened = el.opened;
  102.           assert.isFalse(opened)
  103.         });
  104.  
  105.         test('checks property opened is set to true', () => {
  106.           const opened = el.opened = true;
  107.           assert.isTrue(opened)
  108.         });
  109.  
  110.         test('checks property collapsed is set to false', () => {
  111.           const collapsed = el.collapsed;
  112.           assert.isFalse(collapsed)
  113.         });
  114.  
  115.         test('checks property collapsed is set to true', () => {
  116.           const collapsed = el.collapsed = true;
  117.           assert.isTrue(collapsed)
  118.         });
  119.  
  120.  
  121.         test('checks property links is an Array', () => {
  122.           const links = elOpened.links;
  123.           assert.isArray(links)
  124.         });
  125.  
  126.         test('checks property links is an Array', () => {
  127.           const links = el.links;
  128.           assert.isArray(links)
  129.         });
  130.  
  131.       });
  132.     </script>
  133.   </body>
  134. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement