Dieses Repository beinhaltet HTML- und Javascript Code zur einer NotizenWebApp auf Basis von Web Storage. Zudem sind Mocha/Chai Tests im Browser enthalten. https://meinenotizen.netlify.app/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cors.js 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. var request = require('supertest');
  2. var path = require('path');
  3. var liveServer = require('..').start({
  4. root: path.join(__dirname, "data"),
  5. port: 0,
  6. open: false,
  7. cors: true
  8. });
  9. describe('cors tests', function() {
  10. it('should respond with appropriate header', function(done) {
  11. request(liveServer)
  12. .get('/index.html')
  13. .set('Origin', 'http://example.com')
  14. .expect('Content-Type', 'text/html; charset=UTF-8')
  15. .expect('Access-Control-Allow-Origin', 'http://example.com')
  16. .expect(/Hello world/i)
  17. .expect(200, done);
  18. });
  19. it('should support preflighted requests', function(done) {
  20. request(liveServer)
  21. .options('/index.html')
  22. .set('Origin', 'http://example.com')
  23. .set('Access-Control-Request-Method', 'POST')
  24. .set('Access-Control-Request-Headers', 'X-PINGOTHER')
  25. .expect('Access-Control-Allow-Origin', 'http://example.com')
  26. .expect('Access-Control-Allow-Methods', /POST/)
  27. .expect('Access-Control-Allow-Headers', 'X-PINGOTHER')
  28. .expect(204, done);
  29. });
  30. it('should support requests with credentials', function(done) {
  31. request(liveServer)
  32. .options('/index.html')
  33. .set('Origin', 'http://example.com')
  34. .set('Cookie', 'foo=bar')
  35. .expect('Access-Control-Allow-Origin', 'http://example.com')
  36. .expect('Access-Control-Allow-Credentials', 'true')
  37. .expect(204, done);
  38. });
  39. });