Skip to content
This repository has been archived by the owner on Sep 30, 2021. It is now read-only.

Commit

Permalink
WIP extended test
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanpenner committed Nov 17, 2015
1 parent dc2f8f1 commit 4111cdb
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 1 deletion.
30 changes: 30 additions & 0 deletions test/fixtures/output2/test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!-- styles -->
<link rel="stylesheet" href="https://example.com/thing.css">
<link rel="stylesheet" href="https://example.com/thing.css">
<link rel="stylesheet" href="vendor.css" />
<link rel="stylesheet" href="other.css" integrity="sha256-XgGI+esC0dkjsvC9cEqmQcHBWj7I6t+f24SPjtLYJxQ= sha512-KDs3Tn6m3NFDJscGjWvcD3gzxvt1H+QizMN+5GbiYi7hiTMIxbXd+ptD8857TTWcTJtZvwVZCD3BHqjmPZeVTA==" />
<link rel="stylesheet" hresf="other.css" />
<link href="other.css" />
<linkhref="other.css" rel="stylesheet" />
<link h="other.css" rel="stylesheet" />
<link hsref="other.css" rel="stylesheet" />
<link href="other.css" rel="stylesheet" integrity="sha256-XgGI+esC0dkjsvC9cEqmQcHBWj7I6t+f24SPjtLYJxQ= sha512-KDs3Tn6m3NFDJscGjWvcD3gzxvt1H+QizMN+5GbiYi7hiTMIxbXd+ptD8857TTWcTJtZvwVZCD3BHqjmPZeVTA==" />
<link href="other.css" rel="stylesheet" integrity="sha256-XgGI+esC0dkjsvC9cEqmQcHBWj7I6t+f24SPjtLYJxQ= sha512-KDs3Tn6m3NFDJscGjWvcD3gzxvt1H+QizMN+5GbiYi7hiTMIxbXd+ptD8857TTWcTJtZvwVZCD3BHqjmPZeVTA==" >
<link href="other.css" rel="stylesheet" integrity="sha256-XgGI+esC0dkjsvC9cEqmQcHBWj7I6t+f24SPjtLYJxQ= sha512-KDs3Tn6m3NFDJscGjWvcD3gzxvt1H+QizMN+5GbiYi7hiTMIxbXd+ptD8857TTWcTJtZvwVZCD3BHqjmPZeVTA==" >
<link rel="stylesheet" href="https://example.com/vendor.css" />
<link rel="stylesheet" href="https://subdomain.cloudfront.net/assets/vendor-d41d8cd98f00b204e9800998ecf8427e.css">

<!-- scripts -->
<script src="thing.js" integrity="sha256-oFeuE/P+XJMjkMS5pAPudQOMGJQ323nQt+DQ+9zbdAg= sha512-+EXjzt0I7g6BjvqqjkkboGyRlFSfIuyzY2SQ43HQKZBrHsjmRzEdjSHhiDzVs30nXL9H0tKw6WbMPc6RfzUumQ==" ></script>
<script src="moment-with-locales.min.js"></script>
<script src="unicode-chars.js"></script>
<script srsc="unicode-chars.js"></script>
<script s="unicode-chars.js"></script>
<script src="https://example.com/thing-5e1978f9cfa158d9841d7b6d8a4e5c57.js" integrity="sha256-oFeuE/P+XJMjkMS5pAPudQOMGJQ323nQt+DQ+9zbdAg= sha512-+EXjzt0I7g6BjvqqjkkboGyRlFSfIuyzY2SQ43HQKZBrHsjmRzEdjSHhiDzVs30nXL9H0tKw6WbMPc6RfzUumQ==" crossorigin="anonymous" ></script>
<script src="https://example.com/thing-5e1978f9cfa158d9841d7b6d8a4e5c57.js" integrity="sha256-oFeuE/P+XJMjkMS5pAPudQOMGJQ323nQt+DQ+9zbdAg= sha512-+EXjzt0I7g6BjvqqjkkboGyRlFSfIuyzY2SQ43HQKZBrHsjmRzEdjSHhiDzVs30nXL9H0tKw6WbMPc6RfzUumQ==" crossorigin="anonymous" ></script>
<script src="https://example.com/thing-5e1978f9cfa158d9841d7b6d8a4e5c57.js" crossorigin="use-credentials" integrity="sha256-oFeuE/P+XJMjkMS5pAPudQOMGJQ323nQt+DQ+9zbdAg= sha512-+EXjzt0I7g6BjvqqjkkboGyRlFSfIuyzY2SQ43HQKZBrHsjmRzEdjSHhiDzVs30nXL9H0tKw6WbMPc6RfzUumQ==" ></script>
<script src="https://example.com/thing"></script>
<script src="https://example.com/thing" integrity="thing"></script>

<!-- other -->
<link rel="icon" type="image/png" href="favicon.png" sizes="16x16" />
1 change: 1 addition & 0 deletions test/fixtures/output2/thing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('test');
1 change: 1 addition & 0 deletions test/fixtures/output2/unicode-chars.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('I ♡ WebAppSec!');
20 changes: 19 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('broccoli-sri-hash', function () {
builder.cleanup();
});

it('rule outputs match', function () {
it('rule outputs match (initial build)', function () {
return builder.build().then(function(output) {
var actual = file(output.directory + '/test.html');
var expected = file('test/fixtures/output/test.html');
Expand All @@ -32,6 +32,24 @@ describe('broccoli-sri-hash', function () {
});
});

it('rule outputs match (rebuild)', function () {
var pathToMutate = 'test/fixtures/input/other.css';
var originalContent = fs.readFileSync(pathToMutate);
return builder.build().then(function(output) {
// mutate input File
fs.writeFileSync('test/fixtures/input/other.css', '* { display: none; }');

return builder.build();
}).then(function(output) {
var actual = file(output.directory + '/test.html');
var expected = file('test/fixtures/output2/test.html');

assert.equal(actual, expected);
}).finally(function() {
fs.writeFileSync(pathToMutate, originalContent);
});
});

lint([
'index.js',
'tests/index.js'
Expand Down

0 comments on commit 4111cdb

Please sign in to comment.