test.js (510B)
1 var expect = require('chai').expect; 2 3 describe('has-cors', function() { 4 beforeEach(function() { 5 // make sure result is not cached 6 delete require.cache[require.resolve('./')]; 7 }); 8 9 it('should not have cors', function() { 10 var hasCors = require('./'); 11 12 expect(hasCors).to.be.false; 13 }); 14 15 it('should have cors', function() { 16 global.XMLHttpRequest = function() { 17 this.withCredentials = true; 18 }; 19 20 var hasCors = require('./'); 21 22 expect(hasCors).to.be.true; 23 }); 24 });