Skip to content

Commit

Permalink
Add more injection tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
tapio committed Jan 9, 2017
1 parent b8d083d commit 58754e6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/acceptance.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ describe('basic functional tests', function(){
.expect(/<script [^]+?live reload enabled[^]+?<\/script>/i)
.expect(200, done);
});
it('should inject to <head> when no <body>', function(done){
request(liveServer)
.get('/index-head.html')
.expect('Content-Type', 'text/html; charset=UTF-8')
.expect(/<script [^]+?live reload enabled[^]+?<\/script>/i)
.expect(200, done);
});
it('should inject also svg files', function(done){
request(liveServer)
.get('/test.svg')
Expand All @@ -38,6 +45,16 @@ describe('basic functional tests', function(){
})
.expect(200, done);
});
it('should not inject html fragments', function(done){
request(liveServer)
.get('/fragment.html')
.expect('Content-Type', 'text/html; charset=UTF-8')
.expect(function(res) {
if (res.text.toString().indexOf("Live reload enabled") > -1)
throw new Error("injected code should not be found");
})
.expect(200, done);
});
xit('should have WebSocket connection', function(done){
done(); // todo
});
Expand Down
2 changes: 2 additions & 0 deletions test/data/fragment.html
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
<h1>
{{this imitates some kind of template fragment}}
</h1>
8 changes: 8 additions & 0 deletions test/data/index-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Live-server Test Page</title>
<link rel="stylesheet" href="style.css" />
</head>
</html>

0 comments on commit 58754e6

Please sign in to comment.