grunt-html-snapshots 4.0.2 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/verify.yml +1 -1
- package/Gruntfile.js +14 -0
- package/package.json +3 -3
- package/test/expected/target3 +3 -0
- package/test/fixtures/test_robots.txt +0 -2
- package/test/fixtures/test_robots_sitemap.txt +15 -0
- package/test/html_snapshots_target3.js +29 -0
- package/test/html_snapshots_test.js +16 -0
- package/test/server/index.js +13 -8
- package/test/server/sitemap.xml +21 -0
package/Gruntfile.js
CHANGED
|
@@ -27,6 +27,12 @@ module.exports = function (grunt) {
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
|
|
30
|
+
test_server3: {
|
|
31
|
+
options: {
|
|
32
|
+
port: 8051
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
|
|
30
36
|
// Configuration to be run (and then tested).
|
|
31
37
|
html_snapshots: {
|
|
32
38
|
options: grunt.file.readJSON("test/input/default_options"),
|
|
@@ -45,6 +51,14 @@ module.exports = function (grunt) {
|
|
|
45
51
|
port: "<%= test_server2.options.port %>",
|
|
46
52
|
force: true
|
|
47
53
|
}
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
target3: {
|
|
57
|
+
options: {
|
|
58
|
+
source: "test/fixtures/test_robots_sitemap.txt",
|
|
59
|
+
outputDir: "tmp/target3/snapshots",
|
|
60
|
+
port: "<%= test_server3.options.port %>"
|
|
61
|
+
}
|
|
48
62
|
}
|
|
49
63
|
},
|
|
50
64
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "grunt-html-snapshots",
|
|
3
3
|
"description": "The grunt task for html-snapshots",
|
|
4
|
-
"version": "4.0
|
|
4
|
+
"version": "4.1.0",
|
|
5
5
|
"homepage": "https://github.com/localnerve/grunt-html-snapshots",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Alex Grant",
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"lint": "eslint ."
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"html-snapshots": "^0.
|
|
28
|
+
"html-snapshots": "^0.19.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"eslint": "^8.
|
|
31
|
+
"eslint": "^8.24.0",
|
|
32
32
|
"grunt-contrib-clean": "^2.0.1",
|
|
33
33
|
"grunt-contrib-nodeunit": "^4.0.0",
|
|
34
34
|
"grunt": ">=1.5.3"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tests, target1
|
|
3
|
+
*/
|
|
4
|
+
/* global Promise */
|
|
5
|
+
const grunt = require('grunt');
|
|
6
|
+
const { pathExists } = require('./utils');
|
|
7
|
+
|
|
8
|
+
exports.html_snapshots = {
|
|
9
|
+
setUp: done => {
|
|
10
|
+
// setup here if necessary
|
|
11
|
+
done();
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
target1: test => {
|
|
15
|
+
test.expect(3);
|
|
16
|
+
|
|
17
|
+
const results = [];
|
|
18
|
+
|
|
19
|
+
grunt.file.read('test/expected/target3').split('\n').forEach(line => {
|
|
20
|
+
results.push(pathExists(line).then(exists => {
|
|
21
|
+
test.equal(true, exists, `${line} should exist`);
|
|
22
|
+
}));
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
Promise.all(results).finally(()=> {
|
|
26
|
+
test.done();
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
};
|
|
@@ -39,6 +39,22 @@ exports.html_snapshots = {
|
|
|
39
39
|
}));
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
+
Promise.all(results).finally(() => {
|
|
43
|
+
test.done();
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
target3: function(test) {
|
|
48
|
+
test.expect(3);
|
|
49
|
+
|
|
50
|
+
const results = [];
|
|
51
|
+
|
|
52
|
+
grunt.file.read('test/expected/target3').split('\n').forEach(line => {
|
|
53
|
+
results.push(pathExists(line).then(exists => {
|
|
54
|
+
test.equal(true, exists, `${line} should exist`);
|
|
55
|
+
}));
|
|
56
|
+
});
|
|
57
|
+
|
|
42
58
|
Promise.all(results).finally(() => {
|
|
43
59
|
test.done();
|
|
44
60
|
});
|
package/test/server/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Create a local web server for tests
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const http = require("http"),
|
|
5
|
+
url = require("url"),
|
|
6
|
+
path = require("path"),
|
|
7
|
+
fs = require("fs");
|
|
8
8
|
|
|
9
9
|
module.exports = {
|
|
10
10
|
|
|
11
11
|
start: function(rootDir, port, end) {
|
|
12
12
|
http.createServer(function(request, response) {
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
const uri = url.parse(request.url).pathname;
|
|
15
|
+
let filename = path.join(rootDir, uri);
|
|
16
16
|
|
|
17
17
|
fs.exists(filename, function(exists) {
|
|
18
18
|
if(!exists) {
|
|
@@ -34,8 +34,13 @@ module.exports = {
|
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
if (path.extname(filename) === '.xml') {
|
|
38
|
+
response.writeHead(200, {"Content-Type": "text/xml"});
|
|
39
|
+
response.write(file);
|
|
40
|
+
} else {
|
|
41
|
+
response.writeHead(200);
|
|
42
|
+
response.write(file, "binary");
|
|
43
|
+
}
|
|
39
44
|
response.end();
|
|
40
45
|
if (typeof end === "function")
|
|
41
46
|
setTimeout(end, 1000);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
3
|
+
<url>
|
|
4
|
+
<loc>http://localhost:8051/</loc>
|
|
5
|
+
<lastmod>2012-08-11T12:16:09+00:00</lastmod>
|
|
6
|
+
<changefreq>daily</changefreq>
|
|
7
|
+
<priority>1.0</priority>
|
|
8
|
+
</url>
|
|
9
|
+
<url>
|
|
10
|
+
<loc>http://localhost:8051/contact</loc>
|
|
11
|
+
<lastmod>2012-11-02T02:53:40+00:00</lastmod>
|
|
12
|
+
<changefreq>weekly</changefreq>
|
|
13
|
+
<priority>0.6</priority>
|
|
14
|
+
</url>
|
|
15
|
+
<url>
|
|
16
|
+
<loc>http://localhost:8051/services/carpets</loc>
|
|
17
|
+
<lastmod>2012-10-19T10:45:23+00:00</lastmod>
|
|
18
|
+
<changefreq>weekly</changefreq>
|
|
19
|
+
<priority>0.6</priority>
|
|
20
|
+
</url>
|
|
21
|
+
</urlset>
|