How to test service files using wct in polymer if it doesn't contain any custom component

99 Views Asked by At

I would like to write unit test case for a service file named session.js, where there is no custom element is defined. Can we call functions defined in service file from Polymer WCT.

export const ValidateSession=()=>{  
       try{   
           return (logindate <= session);   
       }
       catch(e){   
           console.log(e.message);   
       }   
   }

In my service file, function is defined like above. How to write unit test case to check above function is being called or not.

1

There are 1 best solutions below

0
On BEST ANSWER

Do everything you would do to test an element, but without an element fixture, or perhaps using a JS-only test suite:

suite('AwesomeLib', function() {
  test('is awesome', function() {
    assert.isTrue(AwesomeLib.awesome);
  });
});

Such test suites are described in the WCT README.