Skip to content

Commit

Permalink
refactor(test): update spec naming
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard committed Nov 30, 2019
1 parent b1f6302 commit 0445f0d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions test/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,48 +13,48 @@ describe('HTML inserter', () => {
output = content;
}

it('should do be a no-op', () => {
it('should noop when no assets', () => {
expect(main(["--out", outFile, "--html", inFile,], read, write)).toBe(0);
expect(output).toBe('<html><head></head><body></body></html>');
});

it('should inject script tag', () => {
it('should inject .js as script tag', () => {
expect(main(["--out", outFile, "--html", inFile, '--assets', 'path/to/my.js'], read, write, () => 123)).toBe(0);
expect(output).toBe(
'<html><head></head><body><script src="/path/to/my.js?v=123"></script></body></html>');
});

it('should allow the "module js" extension', () => {
it('should assume "module js" .mjs extension is type="module"', () => {
expect(main(["--out", outFile, "--html", inFile, '--assets', 'path/to/my.mjs'], read, write, () => 123))
.toBe(0);
expect(output).toBe(
'<html><head></head><body><script type="module" src="/path/to/my.mjs?v=123"></script></body></html>');
});

it('should allow the ".es2015.js" extension', () => {
it('should allow the ".es2015.js" extension is type="module"', () => {
expect(main(
["--out", outFile, "--html", inFile, '--assets', 'path/to/my.es2015.js'], read, write, () => 123))
.toBe(0);
expect(output).toBe(
'<html><head></head><body><script type="module" src="/path/to/my.es2015.js?v=123"></script></body></html>');
});

it('should include --out file dir as default --root', () => {
it('should include --out file dir as a default --root', () => {
expect(main(["--out", outFile, "--html", inFile,
'--assets', 'out/some/file.js'], read, write, () => 123)).toBe(0);
expect(output).toBe(
'<html><head></head><body><script src="/file.js?v=123"></script></body></html>');
});

it('should strip longest prefix', () => {
it('should strip the longest matching prefix', () => {
expect(main(["--out", outFile, "--html", inFile,
"--roots", 'path', 'path/to',
'--assets', 'path/to/my.js'], read, write, () => 123)).toBe(0);
expect(output).toBe(
'<html><head></head><body><script src="/my.js?v=123"></script></body></html>');
});

it('should strip external workspaces', () => {
it('should strip the external workspaces prefix', () => {
expect(main(["--out", outFile, "--html", inFile,
"--roots", 'npm/node_modules/zone.js/dist',
'--assets', 'external/npm/node_modules/zone.js/dist/zone.min.js'], read, write, () => 123)).toBe(0);
Expand All @@ -63,7 +63,7 @@ describe('HTML inserter', () => {

});

it('should inject link tag', () => {
it('should inject .css files as stylesheet link tags', () => {
expect(main(["--out", outFile, "--html", inFile, '--assets', 'path/to/my.css'], read, write, () => 123)).toBe(0);
expect(output).toBe(
'<html><head><link rel="stylesheet" href="/path/to/my.css?v=123"></head><body></body></html>');
Expand Down

0 comments on commit 0445f0d

Please sign in to comment.