From 4060087bc6ece3d29815a555a2e8da8abbf32b6b Mon Sep 17 00:00:00 2001 From: Doug Parker Date: Sat, 26 Jun 2021 19:50:28 -0700 Subject: [PATCH] Adds `inlineStyle()` function. Refs #38. The `inlineStyle()` function simply loads the given input from runfiles and returns it in a ` + `.trim(); +} diff --git a/packages/rules_prerender/styles_test.ts b/packages/rules_prerender/styles_test.ts index 0312a6aa..5219e4b5 100644 --- a/packages/rules_prerender/styles_test.ts +++ b/packages/rules_prerender/styles_test.ts @@ -1,14 +1,32 @@ import 'jasmine'; -import { includeStyle } from 'rules_prerender/packages/rules_prerender/styles'; +import { includeStyle, inlineStyle } from 'rules_prerender/packages/rules_prerender/styles'; describe('styles', () => { describe('includeStyle()', () => { it('returns a style annotation in an HTML comment', () => { const annotation = includeStyle('foo/bar/baz.css'); - expect(annotation) - .toBe(''); + expect(annotation).toBe( + ''); + }); + }); + + describe('inlineStyle()', () => { + it('resolves to a ` + `.trim()); + }); + + it('rejects when the given file path is not found in runfiles', async () => { + await expectAsync(inlineStyle('rules_prerender/does/not/exist.css')) + .toBeRejected(); }); }); }); diff --git a/packages/rules_prerender/testdata/BUILD.bazel b/packages/rules_prerender/testdata/BUILD.bazel new file mode 100644 index 00000000..bb54df0c --- /dev/null +++ b/packages/rules_prerender/testdata/BUILD.bazel @@ -0,0 +1,3 @@ +package(default_visibility = ["//packages/rules_prerender:__pkg__"]) + +exports_files(["styles.css"]) diff --git a/packages/rules_prerender/testdata/styles.css b/packages/rules_prerender/testdata/styles.css new file mode 100644 index 00000000..2d130df9 --- /dev/null +++ b/packages/rules_prerender/testdata/styles.css @@ -0,0 +1 @@ +.foo { color: red; }