Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate workbox-build to TypeScript #2867

Merged
merged 82 commits into from
Jun 17, 2021
Merged
Changes from 1 commit
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
f2009fe
WIP
jeffposnick Dec 23, 2020
56c29b0
Finished getManifest
jeffposnick Dec 23, 2020
e1f6105
GenerateSW migrated
jeffposnick Dec 23, 2020
5a27e31
Getting there
jeffposnick Dec 23, 2020
e6ad7b3
WIP
jeffposnick Dec 23, 2020
b774e0d
Runtime caching TS
jeffposnick Dec 24, 2020
f1bc1a8
More WIP
jeffposnick Jan 16, 2021
85b6aff
More WIP
jeffposnick Jan 16, 2021
65e69c6
Validation, type fixes
jeffposnick Jan 16, 2021
c40c873
Builds!
jeffposnick Jan 16, 2021
1e946bf
No default exports
jeffposnick Jan 17, 2021
1c2df4f
null support in optional strings
jeffposnick Feb 10, 2021
3f52fbc
Merge remote-tracking branch 'origin/v6' into wb-build-ts
jeffposnick Apr 27, 2021
aa9e454
Accept string or buffer again
jeffposnick Apr 30, 2021
d672134
Fix JSDocs
jeffposnick May 5, 2021
63d1be2
Merge remote-tracking branch 'origin/v6' into wb-build-ts
jeffposnick May 23, 2021
7c9c646
CanIUse update
jeffposnick May 23, 2021
b2e0f19
test/additional-manifest-entries-transform
jeffposnick May 23, 2021
06bb97d
lib/bundle
jeffposnick May 23, 2021
0f6c05a
cdnUtils test
jeffposnick Jun 4, 2021
464f0c3
Switched to esModuleInterop
jeffposnick Jun 4, 2021
e5ab8b0
Still WIP
jeffposnick Jun 4, 2021
a49d5cd
get-file-size migration
jeffposnick Jun 7, 2021
b9427d2
get-string-details test migration
jeffposnick Jun 7, 2021
f364a00
A few more
jeffposnick Jun 7, 2021
705e832
populateSWTemplate changes
jeffposnick Jun 7, 2021
1337286
A few more
jeffposnick Jun 8, 2021
6ba9a82
validate options
jeffposnick Jun 8, 2021
3ccfdde
Update ts-auto-guard
jeffposnick Jun 8, 2021
9184df0
Fix dependency-check
jeffposnick Jun 8, 2021
728ca6d
Swapped the exports
jeffposnick Jun 8, 2021
82fbb94
JSON Schema + ajv
jeffposnick Jun 9, 2021
cd28f02
TS 4.1.5
jeffposnick Jun 9, 2021
d258ac1
Getting closer to validation
jeffposnick Jun 9, 2021
0069bba
Some default logic
jeffposnick Jun 9, 2021
2f80549
Switched default quotes
jeffposnick Jun 9, 2021
ed52775
Cleanup optional types
jeffposnick Jun 9, 2021
a8a161c
Figuring out errors
jeffposnick Jun 9, 2021
759b196
Refactor
jeffposnick Jun 9, 2021
cdabfc8
Update validate-options test
jeffposnick Jun 9, 2021
69b9e66
Started integration test migration
jeffposnick Jun 9, 2021
4749d24
Remove joi schema
jeffposnick Jun 9, 2021
48559c8
Fixed some swDest logic
jeffposnick Jun 9, 2021
fae8a0e
Closer to webpack tests working
jeffposnick Jun 9, 2021
f3a4e8b
Fix transformManifest usage
jeffposnick Jun 9, 2021
53aa9a8
Use a copy of the exclude array
jeffposnick Jun 10, 2021
acfbefe
More include/exclude fun
jeffposnick Jun 10, 2021
afdae9f
swDest default fix
jeffposnick Jun 10, 2021
38ac1e6
Function support?
jeffposnick Jun 10, 2021
649985f
modifyURLPrefix workaround
jeffposnick Jun 10, 2021
6a79eb1
Fix an import
jeffposnick Jun 10, 2021
1f780ac
Improve error messages
jeffposnick Jun 10, 2021
311b1d6
Fix test string
jeffposnick Jun 10, 2021
4475aec
New validation unit test
jeffposnick Jun 10, 2021
ad68acc
getManifest working
jeffposnick Jun 10, 2021
19c207a
Working through generateSW
jeffposnick Jun 10, 2021
7d895fc
Function massaging
jeffposnick Jun 14, 2021
fb4aa3e
Cleanup of exclude/include
jeffposnick Jun 14, 2021
a856e6b
Fix a few more gSW tests
jeffposnick Jun 14, 2021
3945e8b
RouteMatchCallback function
jeffposnick Jun 14, 2021
aed3f6a
Expiration w/cacheName check
jeffposnick Jun 14, 2021
a534b13
Optional globDirectory
jeffposnick Jun 14, 2021
dfafd9e
InjectManifest tests
jeffposnick Jun 14, 2021
d50d4db
Test cleanup
jeffposnick Jun 14, 2021
25cfa2f
Fix a test
jeffposnick Jun 14, 2021
0cca507
Fix a config modification
jeffposnick Jun 14, 2021
935ca5e
v5 injectmanifest test
jeffposnick Jun 14, 2021
781e92d
esModuleInterop support
jeffposnick Jun 14, 2021
a7ef09d
Fixes for proxied build
jeffposnick Jun 15, 2021
d812352
Final tweaks
jeffposnick Jun 15, 2021
3ec8ddc
Linting
jeffposnick Jun 16, 2021
a9eee0f
Automated linting fixes
jeffposnick Jun 16, 2021
6a71bb2
Tweak linting rules
jeffposnick Jun 16, 2021
76bc659
Update packages/workbox-build/src/lib/get-file-details.ts
jeffposnick Jun 16, 2021
14cc0ad
Update test/workbox-build/node/generate-sw.js
jeffposnick Jun 16, 2021
8816a4d
Update packages/workbox-build/src/lib/additional-manifest-entries-tra…
jeffposnick Jun 16, 2021
207bb4f
Update packages/workbox-build/src/lib/additional-manifest-entries-tra…
jeffposnick Jun 16, 2021
19a3ff3
Update packages/workbox-build/src/lib/cdn-utils.ts
jeffposnick Jun 16, 2021
4e363bd
Update packages/workbox-build/src/lib/get-file-manifest-entries.ts
jeffposnick Jun 16, 2021
c066941
Update packages/workbox-build/src/lib/stringify-without-comments.ts
jeffposnick Jun 16, 2021
4caaaeb
Update packages/workbox-build/src/lib/validate-options.ts
jeffposnick Jun 16, 2021
4af8d17
Update packages/workbox-build/src/lib/additional-manifest-entries-tra…
jeffposnick Jun 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update validate-options test
  • Loading branch information
jeffposnick committed Jun 9, 2021
commit cdabfc89f811a56e96d9bc858a25a0f8751e30fe
44 changes: 30 additions & 14 deletions test/workbox-build/node/lib/validate-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,51 @@

const expect = require('chai').expect;
const proxyquire = require('proxyquire');
const sinon = require('sinon');

const INJECTED_ERROR = 'Injected error.';
class AJVFailsValidation {
compile() {
const stub = sinon.stub().returns(false);
stub.errors = [INJECTED_ERROR];
return stub;
}
}

class AJVPassesValidation {
compile() {
return sinon.stub().returns(true);
}
}

// The integration tests will exercise the actual validation logic.
describe(`[workbox-build] entry-points/options/validate-options.js`, function() {
const MODULE_PATH = '../../../../packages/workbox-build/build/lib/validate-options';
const testCases = new Map([
['validateGenerateSWOptions', 'isGenerateSWOptions'],
['validateGetManifestOptions', 'isGetManifestOptions'],
['validateInjectManifestOptions', 'isInjectManifestOptions'],
]);
const testCases = [
'validateGenerateSWOptions',
'validateGetManifestOptions',
'validateInjectManifestOptions',
];

for (const [func, guardFunc] of testCases) {
it.skip(`${func}() should throw when ${guardFunc}() returns false`, function() {
for (const func of testCases) {
it(`${func}() should throw when validation fails`, function() {
const validateOptions = proxyquire(MODULE_PATH, {
'../types.guard': {
[guardFunc]: () => false,
'ajv': {
default: AJVFailsValidation,
},
});

expect(() => validateOptions[func]()).to.throw('Validation failed.');
expect(() => validateOptions[func]()).to.throw(INJECTED_ERROR);
});

it.skip(`${func}() should return options with defaults when ${guardFunc}() returns true`, function() {
it(`${func}() should not throw when validation passes`, function() {
const validateOptions = proxyquire(MODULE_PATH, {
'../types.guard': {
[guardFunc]: () => true,
'ajv': {
default: AJVPassesValidation,
},
});

const defaultOptions = validateOptions[func]();
const defaultOptions = validateOptions[func]({});
expect(defaultOptions).to.be.an('object');
});
}
Expand Down